|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
Getting system info for multiple flavors of Unix
Does anyone know of how I can obtain system info?
The script I'm writing is going to be used on Linux, AIX and SunOS. It seems each flavor has it's own way of doing things, and I can probably code the script to execute different methods based on which os I'm on, but I can't seem to find a way to get what I want. I've looked at sysinfo, but my attempts to make it work have failed (I made a shell script on SunOS with the following, but it failed.) Code:
#include <sys/systeminfo.h> long sysinfo (int command, char *buf, long count); I found a post here how to do it on linux, but I haven't been able to test it yet. Oh, and the info I need to get:
|
|
#2
|
|||
|
|||
|
sysinfo() would likely be a pretty good way to start but you're programming in C now. So your program would look something like:
Code:
#include <sys/systeminfo.h>
int main( int argc, char** argv )
{
char[1024] genericBuffer;
memset( genericBuffer, 0, 1024 );
sysinfo(SI_SYSNAME, genericBuffer, 1024);
printf( "O/S name is %s\n", genericBuffer );
memset( genericBuffer, 0, 1024 );
sysinfo(SI_HOSTNAME, genericBuffer, 1024);
printf( "Hostname is %s\n", genericBuffer );
...
return( 0 );
}
And, of course, since this isn't Java you will need to compile this with a C compiler on each platform you want it on. However, sysinfo can't get you everything you want. In fact, I'm not even sure what all you want. For example, what is "Node Model" and "Node Type". Let us know. |
|
#3
|
||||
|
||||
|
Oops, model and type are vendor specific, not something to do with the OS.
It's the model is the something like what you'd see on a dell: Dell D600 for instance. |
|
#4
|
|||
|
|||
|
I'm not sure either - about what you want. You said Linux.
The kernel creates 'virtual' files in the /proc directory. CPU information, memory and a lot of other stuff is in those files. You can cat most of them to see what you need. SunOS has a /proc directory as well - but with different files. AIX (I think) also has a /proc tree. The point is: some of the stuff you want is configuration information, and the /proc directory usually has that information. Otherwise - you're going to have to write some really complex C code to find out what you want. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Getting system info for multiple flavors of Unix |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|