From: Stephen L Johnson Date: Tue, 7 Nov 2000 05:57:59 +0000 (+0000) Subject: critical counts for processes added and processing improved X-Git-Tag: spong-2_7_1~11 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90c30bd5007b025230e171562ae52fe428a50e78;p=spong.git critical counts for processes added and processing improved --- diff --git a/src/lib/Spong/Client/plugins/check_processes b/src/lib/Spong/Client/plugins/check_processes index 06ca97e..95565d9 100755 --- a/src/lib/Spong/Client/plugins/check_processes +++ b/src/lib/Spong/Client/plugins/check_processes @@ -1,4 +1,4 @@ -# $Id: check_processes,v 1.2 2000/11/07 05:53:35 sljohnson Exp $ +# $Id: check_processes,v 1.3 2000/11/07 05:57:59 sljohnson Exp $ # Register this routine with the plugin registery @@ -10,20 +10,33 @@ $CHECKFUNCS{'processes'} = \&check_processes; sub check_processes { my $color = "green"; - my( $message, $summary, $check, $ret, $down, @down, $time, $critical ); + my( $message, $summary, $check, @ret, $down, @down, $time, $critical ); + my (@plist); - system( "$PS > $SPONGTMP/PS.$$" ); + open (P, "$PSEF |"); + @plist =

; + close P; + foreach $check ( @JOBSWARN, @PROCSWARN ) { - $ret = `$GREP '$check' $SPONGTMP/PS.$$`; - if( $ret =~ /^\s*$/ ) { $color = "yellow"; push( @down, $check ); } - else { $message .= $ret; } + $cnt = 1; + if ($check =~ /^([^:]+):(.*)$/o) { + $cnt = $2; + $check = $1; + } + @ret = grep (/$check/, @plist); + if( scalar @ret < $cnt ) { $color = "yellow"; push( @down, "$check:$cnt" ); } + else { $message .= join ('',@ret); } } foreach $check ( @JOBSCRIT, @PROCSCRIT ) { - $ret = `$GREP '$check' $SPONGTMP/PS.$$`; - if( $ret =~ /^\s*$/ ) { $color = "red"; push( @down, $check ); } - else { $message .= $ret; } + $cnt = 1; + if ($check =~ /^([^:]+):(.*)$/o) { + $cnt = $2; + $check = $1; + } + @ret = grep (/$check/, @plist); + if( scalar @ret < $cnt ) { $color = "red"; push( @down, "$check:$cnt" ); } + else { $message .= join ('',@ret); } } - unlink "$SPONGTMP/PS.$$"; $summary = "processes ok" if $color eq "green"; $summary = "(@down) not running" if $color ne "green";