root/lib/Resmon/Module/INODES.pm

Revision 748aca8e44f7a19fb38f861ea67990fb00933a94, 1.0 kB (checked in by Mark Harrison <mark@omniti.com>, 6 years ago)

Split out the modules from Modules.pm to the Modules/ directory. Also made
sure each module returned a true value.

git-svn-id: https://labs.omniti.com/resmon/trunk@92 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

  • Property mode set to 100644
Line 
1 package Resmon::Module::INODES;
2 use Resmon::ExtComm qw/cache_command/;
3 use Resmon::Module;
4 use Switch;
5 use vars qw/@ISA/;
6 @ISA = qw/Resmon::Module/;
7
8 my $dfcmd;
9 my $dfregex;
10
11 switch ($^O) {
12     case 'solaris'  { $dfcmd = 'df -Fufs -oi';
13                       $dfregex = '(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%'}
14     case 'openbsd'  { $dfcmd = 'df -i';
15                       $dfregex = '(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%\s+(\d+)\s+(\d+)\s+(\d+)%'}
16     else            { $dfcmd = 'df -iP';
17                       $dfregex = '(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%'}
18 }
19
20 sub handler {
21   my $arg = shift;
22   my $os = $arg->fresh_status();
23   return $os if $os;
24   my $devorpart = $arg->{'object'};
25   my $output = cache_command($dfcmd, 30);
26   my ($line) = grep(/$devorpart\s*/, split(/\n/, $output));
27   if($line =~ /$dfregex/) {
28     if($4 <= $arg->{'limit'}) {
29       return $arg->set_status("OK($2 $4% full)");
30     }
31     return $arg->set_status("BAD($2 $4% full)");
32   }
33   return $arg->set_status("BAD(no data)");
34 }
35
36 1;
Note: See TracBrowser for help on using the browser.