lhinv - Hardware Inventory for Linux 2.2.x (Version 1.1)

[Download] [FAQ] [w3hinv] [TODO] [Links]

Have you ever tried to determine exactly what hardware is configured on a server you've connected to over the network? Have you ever had to keep track of the memory installed in a cluster of 250 Linux boxes? How about trying to get a user you are supporting over the telephone to tell you whether his root disk is SCSI or IDE? These are the kind of questions that lhinv is designed to answer.

Based on the excellent IRIX utility, 'hinv', lhinv generates a standardized listing of configured hardware on your Linux 2.2.x or higher system by parsing the proc filesystem. It also allows you to write scripts that test for the existence of a certain subsystem automatically. When doing end-user support, or managing a large number of boxes, this can be an valuable tool.

The default behaviour of 'lhinv' when called without arguments, is to provide a one line listing of every hardware subsystem found represented in the proc filesystem:

CPU: GenuineIntel 00/07 Processor
FPU: GenuineIntel 00/07 Floating Point Processor
2 500 MHz i686 Processors 
  Secondary cache: 512 Kbytes
Main memory size: 256 Mbytes
SCSI controller 2: Version ncr53c8xx
SCSI controller 1: Version ncr53c8xx
  Device 00 on SCSI controller 1, Lun 00
  Device 01 on SCSI controller 1, Lun 00
  Device 06 on SCSI controller 1, Lun 00
SCSI controller 0: Version ncr53c8xx
IDE controller 0: PCI
  CDROM Device: unit a on IDE controller 0
2 16550A UART serial ports
Configured SPP mode parallel port at 0x378 
1 Graphics board: VGA detected at 03c0-03df
 VGA compatible controller: Cirrus Logic GD 5480
Ethernet interface configured: eth0 

For sysadmins who are integrating Linux into an SGI environment, lhinv supports all the most commonly used flags of IRIX 'hinv'. This allows for specific tests to be conducted. The options supported currently are as follows:

-v Verbose. This flag will provide a more verbose description of some subsystems. It will also explicitly state which subsystems are not found.

-c Class. This flag displays only the subsystems included in the supplied class. Classes currently are: processor, disk, memory, serial, parallel, graphics, network, scsi, ide, and all. If the hardware class is present on the system, the script exits 0, else it will exit 1.

-t Type. Only display information about the supplied type. Types currently are: arch, cpu, fpu, and scache. If information about the type is available, the script exits 0, else it will exit 1.

-s Suppress. This option will suppress the output of the -t and -c flags, and is used when called by a script that simply evaluates the exit status.

-e Email. Rather then printing to STDOUT, this flag will cause the system configuration to be emailed to the supplied address.

With version 1.1 of lhinv I've included a CGI wrapper for the script's output, in a manner similar to the MachineInfo script provided with IRIS Outbox. The w3hinv is written to be easily customized by whoever sees fit to use it, and allows you to easily display a usesage disclaimer to anyone who connects to your webserver. The output looks something like this.

It should be noted that displaying the OS revision and hardware you run may not be the best idea, from a security standpoint. I use this script as a quick way to get Hardware Information on a Linux cluster behind our firewall. The disclaimer option is useful for legal purposes: Allowing you to explicitly state your usage policy/limitations to those who connect to your site.


I am really interested in the possibility of rewriting this tool in C. There are some problems with doing this without having to recompile the thing every time the kernel is rebuilt. The IRIX kernel has a data structure that is built when the system boots and it's devices are probed, which makes it very easy to print out the entries in a list. While the /proc filesystem does this to a certain extent in what is arguably a superior way, the lack of standardization of what data is presented and how it is stored makes it a little messy for grokking.

I would love to discuss the requirements/issues of providing some functionality to linux similar to IRIX_INVEN, and how this could be implemented in a sane sort of way.

Various and Sundry Link Type Things:

Similar sorts of things:

A few other folks, some of them at SGI, have also put together hardware inventory commands using proc. For a variety of reasons, primarily that I wanted all the same features that were available on my IRIX systems, I wrote my own, but you may find these useful.