-# $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
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 = <P>;
+ 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";