package Resmon::Module::PGREP;
use Resmon::ExtComm qw/cache_command/;
use vars qw/@ISA/;
@ISA = qw/Resmon::Module/;

sub handler {
  my $arg = shift;
  my $proc = $arg->{'object'};
  my $args = join(' ',$arg->{'arg0'},$arg->{'arg1'},$arg->{'arg2'});
  $args =~s/\s+$//;
  my $output = cache_command("pgrep -f -l '$proc $args' | grep -v sh | head -1", 500);
  if($output) {
    chomp $output;
    return("OK(pid:$output)");
  }
  return("BAD(no output)");
};
1;

package Resmon::Module::PGREP;
use Resmon::ExtComm qw/cache_command/;
use vars qw/@ISA/;
@ISA = qw/Resmon::Module/;

sub handler {
  my $arg = shift;
  my $proc = $arg->{'object'};
  my $args = join(' ',$arg->{'arg0'},$arg->{'arg1'},$arg->{'arg2'});
  $args =~s/\s+$//;
  $proc .= " $args" if $args;
  my $output = cache_command("pgrep -f -l '$proc' | grep -v sh | head -1", 500);
  if($output) {
    chomp $output;
    return("OK(pid:$output)");
  }
  return("BAD(no output)");
};
1;

Work with processes that have no arguments
Work with processes that have no arguments

git-svn-id: f288825eac1cbbbc51b99d82d097385cba0e17f8@172 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55
