--- projects/cms/source/host/generic/statgrab.pl 2001/02/28 12:26:36 1.35 +++ projects/cms/source/host/generic/statgrab.pl 2001/03/03 21:26:55 1.36 @@ -3,7 +3,7 @@ #----------------------------------------------------------------- # Machine statistics grabber # $Author: tdb $ -# $Id: statgrab.pl,v 1.35 2001/02/28 12:26:36 tdb Exp $ +# $Id: statgrab.pl,v 1.36 2001/03/03 21:26:55 tdb Exp $ # # A Perl script to return various information about a host machine # by examining the output of some common Unix/Linux commands. @@ -76,7 +76,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.35 $'; + print 'version statgrab.pl $Revision: 1.36 $'; print "\n"; } @@ -195,10 +195,15 @@ sub include_top() { &print_pair(0, "packet.processes.stopped", $top =~ / ([^\s]+?) stopped/); &print_pair(0, "packet.processes.cpu", $top =~ /([^\s]+?)\s*running/); &print_pair(0, "packet.cpu.idle", $top =~ /([^\s]+?)% idle/); - &print_pair(0, "packet.cpu.user", $top =~ /([^\s]+?)% user/); &print_pair(0, "packet.cpu.kernel", $top =~ /([^\s]+?)% system/); &print_pair(0, "packet.cpu.iowait", $top =~ /([^\s]+?)% interrupt/); &print_pair(0, "packet.cpu.swap", $top =~ /([^\s]+?)% swap/); + + # FreeBSD is a bit different, we need to get user and nice. + my($user) = 0; + if($top =~ /([^\s]+?)% user/) { $user += $1; } + if($top =~ /([^\s]+?)% nice/) { $user += $1; } + &print_pair(0, "packet.cpu.user", $user); # The following need to be specified in megabytes. # If they are preceeded by a G, then multiply by 1024.