Hardware Inventory Collection on Linux

Posted on 2005-04-30
Last Modified: 2012-05-05
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
Question by:CodingExperts
    LVL 9

    Expert Comment

    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.
    LVL 6

    Author Comment

    How can I find all the information of all the services running. I mean all .so processes running....

    LVL 9

    Expert Comment

    Not sure about .so processes.  I use "ps -elf" to show all running processes.
    LVL 7

    Accepted Solution

    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.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
    Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now