Hardware Inventory Collection on Linux

Hello Experts.

I want to write a program preferably in C using which I can query various Hardware infrastructure present on the machine where Linux is installed, say how much ram does the machine has, processor speed, no of hard disks etc.

How should I go about doing this.

Thanks for any help
CE
LVL 6
CodingExpertsAsked:
Who is Participating?
 
macker-Connect With a Mentor Commented:
Take a look at the output of 'lspci' for hardware devices.  The /proc filesystem probably contains all of the data you want, since you're going to want to access it in a low-level manner.

Not clear what you mean by .so processes; .so commonly refers to shared object, i.e. libraries.  'ps -elf' is one common format of the ps command, 'ps -awwux' is another.  /proc contains a list of all process id's (/proc/###) as directories, and specifics about the process is contained within the pid's directory.  E.g. /proc/1 is the init process, and the files within (cmdline, cwd, environ, exe, etc.) contain information about the environment variables of the process, current working directory, command line, and the source (executable) file.

For extremely detailed (formatted) information, look at the lsof command; it will show what file handles are open by what processes, including TCP sockets.
0
 
kfullartonCommented:
Not sure if this will help you as I'm not a programmer.  To get memory info, the "free" command will give you information on memory and swap.  For more details, run "cat /proc/meminfo".  If you run "cat /proc/cpuinfo" that will provide info on the cpu.  In the file "/etc/sysconfig/hwconf", all hardware that is detected, is listed.  Hope that helps.
0
 
CodingExpertsAuthor Commented:
How can I find all the information of all the services running. I mean all .so processes running....



CodingExpert
0
 
kfullartonCommented:
Not sure about .so processes.  I use "ps -elf" to show all running processes.
0
All Courses

From novice to tech pro — start learning today.