root/lib/Resmon/Module/DISK.pm

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

Making the df command specify the device it is looking for so it doesn't hang
on some other directory/device we aren't concerned with.

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

  • Property mode set to 100644
Line 
1 package Resmon::Module::DISK;
2 use Resmon::ExtComm qw/cache_command/;
3 use vars qw/@ISA/;
4 @ISA = qw/Resmon::Module/;
5
6 my $dfcmd = ($^O eq 'linux') ? 'df -kP' : 'df -k';
7
8 sub handler {
9   my $arg = shift;
10   my $os = $arg->fresh_status();
11   return $os if $os;
12   my $devorpart = $arg->{'object'};
13   my $output = cache_command("$dfcmd $devorpart", 120);
14   my ($line) = grep(/$devorpart\s*/, split(/\n/, $output));
15   if($line =~ /(\d+)%/) {
16     if($1 > $arg->{'limit'}) {
17       return $arg->set_status("BAD($1% full)");
18     }
19     if(exists $arg->{'warnat'} && $1 > $arg->{'warnat'}) {
20       return $arg->set_status("WARNING($1% full)");
21     }
22     return $arg->set_status("OK($1% full)");
23   }
24   return $arg->set_status("BAD(0 -- no data)");
25 }
26 1;
Note: See TracBrowser for help on using the browser.