[Novalug] script for getting hardware info

Jon LaBadie novalugml@jgcomp.com
Thu May 27 16:30:12 EDT 2010


On Thu, May 27, 2010 at 06:05:00PM +0000, Miguel Gonzalez wrote:
> I'm trying to write a plugin for GLPI that retrieves some hardware info from a specific machine. Right now I just need CPU, total memory and total hard drive. I'm trying to get this info from a non-root account so there is no risk involved since GLPI is web-based.
> 
> /proc/cpuinfo can be a little cumbersome to parse since it shows an entry for each core or cpu in the machine but it's still helpful
> 
> /proc/meminfo - you can get the total.
> 
> the problem is to get the total hard drive (either IDE, SATA, SAS o SCSI). Is this possible as a non-root? /sbin/fdisk -l doesn't work as non-root.
> 

If only mounted file systems can satisfy your needs, a df to list
only specific FS types may work.

$ df -T -t ext2 -t ext3 -t vfat
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/sda1     ext3    49594196  31930360  15103880  68% /
/dev/sda2     ext3    49594228  17334824  29699448  37% /home
/dev/sda4     ext3   126233528 100334660  19486524  84% /vb
/dev/sdb3     ext3    65207684  18705452  43189820  31% /media/SuSE _
/dev/sdb1     vfat     6820868   5572020   1248848  82% /media/PRESARIO_RP
/dev/sdb6     ext3    39735504   2587168  35129820   7% /media/SuSE _home


hdinfo can generate reports that includes the disk's model.  For some
models, that can be parsed into the capacity.

-- 
Jon H. LaBadie                  novalugml@jgcomp.com
 JG Computing
 12027 Creekbend Drive		(703) 787-0884
 Reston, VA  20194		(703) 787-0922 (fax)



More information about the Novalug mailing list