--- projects/cms/source/host/generic/statgrab.pl 2001/01/22 17:23:25 1.11 +++ projects/cms/source/host/generic/statgrab.pl 2001/01/22 23:21:34 1.13 @@ -2,8 +2,8 @@ #----------------------------------------------------------------- # Machine statistics grabber -# $Author: pjm2 $ -# $Id: statgrab.pl,v 1.11 2001/01/22 17:23:25 pjm2 Exp $ +# $Author: tdb $ +# $Id: statgrab.pl,v 1.13 2001/01/22 23:21:34 tdb Exp $ # # A Perl script to return various information about a host machine # by examining the output of some common Unix/Linux commands. @@ -21,6 +21,12 @@ $| = 1; # You'd be silly not to use this ;) use strict; +# Path's +my($topbin) = "/usr/local/sbin/top"; +my($dfbin) = "/usr/bin/df"; +my($usersbin) = "/usr/ucb/users"; +my($unamebin) = "/usr/bin/uname"; + # Run the following components: - &print_ident(); &include_osver(); @@ -42,7 +48,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.11 $'; + print 'version statgrab.pl $Revision: 1.13 $'; print "\n"; } @@ -74,7 +80,7 @@ sub print_pair($$$) { sub include_disk() { # Run the df program. - my(@df) = `df -ak`; + my(@df) = `$dfbin -ak`; # Go through each line of the program, looking for each thing we want. my($partition_no) = 0; @@ -100,7 +106,7 @@ sub include_disk() { sub include_users() { # Find out all users on this machine. - my($users) = `users`; + my($users) = `$usersbin`; my(@users) = split(/\s+/, $users); my($users_count) = $#users + 1; @@ -116,7 +122,7 @@ sub include_users() { sub include_top() { # Find out some numbers from top. - my(@top) = `top -d2 -s1 0`; + my(@top) = `$topbin -d2 -s1 0`; my($top) = join(" ", @top); $top =~ s/\n//g; @@ -150,12 +156,15 @@ sub include_top() { $top =~ /([^\s]+?)([MG]) swap in use/; my($swap_in_use) = $1; $swap_in_use*=1024 if $2 eq "G"; - &print_pair(1, "packet.memory.swap_in_use", $swap_in_use); + # 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. @@ -164,11 +173,11 @@ sub include_osver() { # Find out details about the operating system # If these values remain undefined, then the print_pair # function shall show the value to be the string "unknown". - my($os_name) = `uname -s`; - my($os_release) = `uname -r`; - my($os_platform) = `uname -m`; - my($os_sysname) = `uname -n`; - my($os_version) = `uname -v`; + my($os_name) = `$unamebin -s`; + my($os_release) = `$unamebin -r`; + my($os_platform) = `$unamebin -m`; + my($os_sysname) = `$unamebin -n`; + my($os_version) = `$unamebin -v`; &print_pair(0, "packet.os.name", $os_name); &print_pair(0, "packet.os.release", $os_release);