AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  Get Hardware Information in AIX within C++

    Posted Mon July 06, 2009 09:54 AM

    Originally posted by: SystemAdmin


    Hello,

    The last days I was searching the internet for possibilities to get hardware information within my C++ programm. I wasn't very successful. I found a few calls, which I can use for the command line, but I wanted to avoid system calls.

    In Linux I found some information with the /proc folder. It's a pity that this folder doesn't exist in AIX. Does anybody know how I could get access to system and hardware information in AIX? Are there any usefull libraries?

    I found already the "perfstat" library and i could use it to get the number of cpu's, but that is all ;-(

    These are the information I would need:
    • Hard disk information (for example: name)
    • Bios: caption etc.
    • Mainboard information (for example: name)
    • CPU ID
    • Video/sound card information
    • Mac-Address (I found an example for AIX to use "#include kinfo.h" But I couldn't use it because it doesn't exist within my AIX..)

    I hope you can help me, I am totally new to AIX..

    Thank you and best regards,
    Maria
    #AIX-Forum


  • 2.  Re: Get Hardware Information in AIX within C++

    Posted Wed July 08, 2009 04:46 AM

    Originally posted by: Sumanth.Sharma


    You can use libodm and liblvm to get lot of information.

    I have used odm_get_list; allows you to use the same odm command line like queries.
    You can get, disk, CPU information quite easily. I have also used /dev/kmem, struct _system_configuration for additional CPU and Disk IO information etc.

    The system command "prtconf" gives a lot of system information, pasring this command will give you good amount of information about system.
    "lscfg -p -vl sysplanar0" command will give you good information about machine model/mainboard etc.

    If you want to avoid using command parsing then ODM is the way to go.

    Let me know your preference, I will see if I could be of any help.

    Thanks,
    Sumanth
    #AIX-Forum


  • 3.  Re: Get Hardware Information in AIX within C++

    Posted Wed July 08, 2009 07:20 AM

    Originally posted by: SystemAdmin


    Hello Sumanth!
    Thank you a lot for your answer!
    But I don't really understand what you mean with the ODM Library. Isn't it an Object Data Manager, is it?A library where you can handle data like a database? That is how I understood it..
    How can I use it to read system information? Have you got more information about it? I searched for it in the net, but I couldn't find anything.

    I would prefer to not use system calls, that's why I use the commands you mentioned just to check my solution. But for that they are very useful.

    Thanks!
    Maria
    #AIX-Forum


  • 4.  Re: Get Hardware Information in AIX within C++

    Posted Wed July 08, 2009 08:48 AM

    Originally posted by: Sumanth.Sharma


    Hi Maria,

    Please download the IBM Redbook 'SC23-4896-04' "5.3General Programming Concepts: Writing and Debugging Programs". In chapter 15 it tells you how to use ODM. The ODM Classes CuDv and CuAt have a lot of information. library calls (not system calls) to libodm would be more efficient than parsing text (command output).

    I can give you some more tips on developing code using libodm with some snippets but that's when you have looked into the documentation and done your bit, I would have loved to share my code if it was open source but I am bound by my NDA :)

    The same redbook is available as html content in this link http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.genprogc/doc/genprogc/odm.htm&tocNode=toc:front/front.cmb/0/0/10/3/15/

    I missed you point 'but for that they are very useful'. Let me know if you are OK parsing command outputs ? Aad if so, are you looking for any other information available through commands.

    Thanks,
    Sumanth
    #AIX-Forum


  • 5.  Re: Get Hardware Information in AIX within C++

    Posted Wed July 08, 2009 10:13 AM

    Originally posted by: SystemAdmin


    I found a way to get the ODM library to work. I tried it, but I get a strange error.
    I tried the example in this thread: http://unix.derkeiler.com/Newsgroups/comp.unix.aix/2003-08/0422.html

    But now I read the P.S. in this thread:
    "P.S. Be aware that the odmi.h header file declares structures with field
    names like 'class' in them, making odmi.h only available in pure C code
    since the C++ compiler will puke because 'class' is a reserved word. "

    I think that could be the reason for my error. Maybe I can't use this library within my c++ code?

    So if this is the only possibility, i have to use the command output. It shouldn't be too difficult with popen() I think. I found already a wide range of commands for aix. I will try them, let's see if it work :)

    Thank you very, very much for your responses!
    Best regards,
    Maria
    #AIX-Forum


  • 6.  Re: Get Hardware Information in AIX within C++

    Posted Fri July 24, 2009 02:25 PM

    Originally posted by: styerd


    Using "IBM(R) XL C/C++ Enterprise Edition V8.0" simply "#include <sys/sys/systemcfg.h>".
    The "_system_configuration" structure is magically populated.

    #include <sys/systemcfg.h>
    #include <iostream.h>
    main()
    {
    cout << "Cpus: " << _system_configuration.ncpus << endl;
    cout << "Memory: " << _system_configuration.physmem << endl;
    }
    #AIX-Forum