#1
  1. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0

    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:
    • OS name
    • OS Version
    • CPU Quantity
    • Memory
    • Node Model
    • Node Type
    • Serial Number
    • IP Address
    • Gateway Address
  2. #2
  3. Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    May 2004
    Location
    Superior, CO, USA
    Posts
    2,419
    Rep Power
    1717
    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.
  4. #3
  5. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0
    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.
  6. #4
  7. No Profile Picture
    ......@.........
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2004
    Posts
    1,345
    Rep Power
    60
    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.

IMN logo majestic logo threadwatch logo seochat tools logo