LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Best way to retrieve system and hardware info (https://www.linuxquestions.org/questions/programming-9/best-way-to-retrieve-system-and-hardware-info-311931/)

vharishankar 04-11-2005 04:24 AM

Best way to retrieve system and hardware info
 
I have been poking around the Linux programming manuals for some time now, but there seems to be a lack of function calls that retrieves system information like CPU info, hardware info, memory, hard disk, devices and so on.

I know that some of the information can be retrieved from configuration files, but the problem is that there is no generic location for certain config files in Linux. Also this seems to be a somewhat unsatisfactory solution.

What is the best way to retrieve system information in a generic way in Linux?
  1. Call the command-line system information calls from and retrieve info from the shell?
  2. Functions calls from within C?
  3. Reading configuration files and/or other directories?

Thank you.

TMH 04-11-2005 04:34 AM

Loads, and loads of info can be obtained through /proc

vharishankar 04-11-2005 04:38 AM

Yes. I saw /proc. Is this generic on all systems?

Also how do I retrieve these files from programming. Just open them or pipe them from a shell output?

XavierP 04-11-2005 05:01 AM

As per request, moved to Programming

TMH 04-11-2005 05:23 AM

How you retrieve these files depends on your programming language of choice.

This is not generic on all systems, as there is the option to not compile /proc into the linux kernel. However, just about everyone compiles it in because it's just so useful. I know it's definately there by default on a SuSE system.

vharishankar 04-11-2005 06:29 AM

I will be using C.


All times are GMT -5. The time now is 04:59 AM.