Any way to detect server model?

Chmouel Boudjnah cboudjnah at squiz.net
Thu Mar 1 17:55:53 CST 2007


Hi,

Ray Van Dolson <rvandolson at esri.com> writes:

> FYI, here's the awk script I ended up writing to pull this information out.
> Maybe useful to others down the line.

I use that script to find most of the stuff i need from dmidecode
(yeah not really strict perl -w compliant but well) :
,----
| 
| #!/usr/bin/perl
| my $f = "dmidecode|";
| local *F;
| open F, $f or die "cannot do stuff: $!\n";
| 
| while (<F>) {
| 
|     if (/\s*System Information/) {
|         $system = defined;
|     }
|     if ($system and /^Handle/) {
|         $system = undef;
|     }
|     if ($system and /^\s*Manufacturer:\s*(.*)/) {
|         $vendor = $1;
|     }
|     if ($system and /^\s*Product Name:\s*(.*)/) {
|         $product = $1;
|     }
|     if ($system and /^\s*Serial Number:\s*(.*)/) {
|         $serial = $1;
|     }
| 
|     if (/^\s*Processor Information/) {
|         $processor = defined;
|         $processors++;
|     }
| 
|     if ($processor and /^\s*Family:\s*(.*)/) {
|         $processor_type = $1;
|     }
|     if ($processor and /^\s*Manufacturer:\s*(.*)/) {
|         $processor_type = "$1 $processor_type";
|     }
|     if ($processor_type and /^\s*Current Speed:\s*(\d+)\s*MHz/) {
|         $processor_type = "$processor_type ${1}Mhz";
|     }
| 
|     if ($processor and /^Handle/) {
|         $processor = undef;
|     }
|     if (/^\s*Memory Device$/) {
|         $memory = defined;
|         $memory_device++;
|     }
|     if ($memory and /^\s*Size:\s*(\d+)\s*MB/) {
|         $total_memory += $1;
|     }
|     if ($memory and /^Handle/) {
|         $memory = undef;
|     }
| }
| close F;
| 
| print "Vendor: ${vendor}\n";
| print "Product: ${product}\n";
| print "Serial: ${serial}\n";
| print "Processor: $processor_type\n";
| print "Memory: ${total_memory}M\n";
`----

-- 
Chmouel Boudjnah - Head Sysadmin - Squiz.net



More information about the Linux-PowerEdge mailing list