--- projects/cms/source/host/generic/statgrab.pl 2001/01/22 16:51:02 1.8 +++ projects/cms/source/host/generic/statgrab.pl 2001/01/22 17:29:28 1.12 @@ -3,7 +3,7 @@ #----------------------------------------------------------------- # Machine statistics grabber # $Author: pjm2 $ -# $Id: statgrab.pl,v 1.8 2001/01/22 16:51:02 pjm2 Exp $ +# $Id: statgrab.pl,v 1.12 2001/01/22 17:29:28 pjm2 Exp $ # # A Perl script to return various information about a host machine # by examining the output of some common Unix/Linux commands. @@ -42,7 +42,7 @@ exit(0); # the host should check this when reading data # means the host must be checked and updated to work with newer versions. sub print_ident() { - print 'version statgrab.pl $Revision: 1.8 $'; + print 'version statgrab.pl $Revision: 1.12 $'; print "\n"; } @@ -55,7 +55,7 @@ sub print_pair($$$) { if (!defined $value) { if ($type) { - $value = 0; + $value = "0.00"; } else { $value = "unknown"; @@ -133,11 +133,32 @@ sub include_top() { &print_pair(1, "packet.cpu.kernel", $top =~ /([^\s]+?)% kernel/); &print_pair(1, "packet.cpu.iowait", $top =~ /([^\s]+?)% iowait/); &print_pair(1, "packet.cpu.swap", $top =~ /([^\s]+?)% swap/); - &print_pair(1, "packet.memory.real", $top =~ /([^\s]+?)[MG] real/); - &print_pair(1, "packet.memory.free", $top =~ /([^\s]+?)[MG] free/); - &print_pair(1, "packet.memory.swap_in_use", $top =~ /([^\s]+?)[MG] swap in use/); - &print_pair(1, "packet.memory.swap_free", $top =~ /([^\s]+?)[MG] swap free/); - + + # The following need to be specified in megabytes. + # If they are preceeded by a G, then multiply by 1024. + + $top =~ /([^\s]+?)([MG]) real/; + my($real) = $1; + $real*=1024 if $2 eq "G"; + &print_pair(1, "packet.memory.real", $real); + + $top =~ /([^\s]+?)([MG]) free/; + my($free) = $1; + $free*=1024 if $2 eq "G"; + &print_pair(1, "packet.memory.free", $free); + + $top =~ /([^\s]+?)([MG]) swap in use/; + my($swap_in_use) = $1; + $swap_in_use*=1024 if $2 eq "G"; + # DO NOT print this one out... save it for in a moment... + + $top =~ /([^\s]+?)([MG]) swap free/; + my($swap_free) = $1; + $swap_free*=1024 if $2 eq "G"; + &print_pair(1, "packet.memory.swap_free", $swap_free); + + # AJ requested total swap instead of swap_in_use, so here we go! + &print_pair(1, "packet.memory.swap_total", $swap_free + $swap_in_use); } # sub to get details of the machine's operating system.