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

my $dfcmd;
my $dfregex;

switch ($^O) {
    case 'solaris'  { $dfcmd = 'df -Fufs -oi';
                      $dfregex = '(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%'}
    case 'openbsd'  { $dfcmd = 'df -i';
                      $dfregex = '(\d+)\s+(\d+)\s+(-?\d+)\s+(\d+)%\s+(\d+)\s+(\d+)\s+(\d+)%'}
    else            { $dfcmd = 'df -iP';
                      $dfregex = '(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%'}
}

sub handler {
  my $arg = shift;
  my $devorpart = $arg->{'object'};
  my $output = cache_command($dfcmd, 30);
  my ($line) = grep(/$devorpart\s*/, split(/\n/, $output));
  if($line =~ /$dfregex/) {
    if($4 <= $arg->{'limit'}) {
      return "OK($2 $4% full)";
    }
    return "BAD($2 $4% full)";
  }
  return "BAD(no data)";
}

1;

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

my $dfcmd;
my $dfregex;

switch ($^O) {
    case 'solaris'  { $dfcmd = 'df -Fufs -oi';
                      $dfregex = '(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%'}
    case 'openbsd'  { $dfcmd = 'df -i';
                      $dfregex = '\d+\s+\d+\s+-?\d+\s+\d+%\s+()(\d+)\s+(\d+)\s+(\d+)%'}
    else            { $dfcmd = 'df -iP';
                      $dfregex = '(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%'}
}

sub handler {
  my $arg = shift;
  my $devorpart = $arg->{'object'};
  my $output = cache_command($dfcmd, 30);
  my ($line) = grep(/$devorpart\s*/, split(/\n/, $output));
  if($line =~ /$dfregex/) {
    if($4 <= $arg->{'limit'}) {
      return "OK($2 $4% full)";
    }
    return "BAD($2 $4% full)";
  }
  return "BAD(no data)";
}

1;

Fix the inodes check on openbsd
Fix the inodes check on openbsd

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