|
Revision ae22e3bd765158b778bd93baa267afae17fe7fa2, 0.8 kB
(checked in by Mark Harrison <mark@omniti.com>, 5 years ago)
|
Moving the fresh_status and set_status code outside of the modules themselves,
making module development simpler. Also fixed an issue with the fresh_status
function where it didn't return a cached message, and resmon showed nothing
for the message. refs #1
git-svn-id: https://labs.omniti.com/resmon/trunk@135 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55
|
- Property mode set to
100755
|
| Line | |
|---|
| 1 |
package Resmon::Module::ZPOOLFREE; |
|---|
| 2 |
|
|---|
| 3 |
use Resmon::Module; |
|---|
| 4 |
use Resmon::ExtComm qw/cache_command/; |
|---|
| 5 |
|
|---|
| 6 |
use vars qw/@ISA/; |
|---|
| 7 |
@ISA = qw/Resmon::Module/; |
|---|
| 8 |
|
|---|
| 9 |
# Version of the free space module that uses zpool list instead of df |
|---|
| 10 |
# Sample config: |
|---|
| 11 |
# |
|---|
| 12 |
# ZPOOLFREE { |
|---|
| 13 |
# intmirror : limit => 90% |
|---|
| 14 |
# storage1 : limit => 90% |
|---|
| 15 |
# } |
|---|
| 16 |
|
|---|
| 17 |
sub handler { |
|---|
| 18 |
my $self = shift; |
|---|
| 19 |
my $object = $self->{object}; |
|---|
| 20 |
my $output = cache_command("zpool list", 120); |
|---|
| 21 |
my ($line) = grep(/$object\s*/, split(/\n/, $output)); |
|---|
| 22 |
if($line =~ /(\d+)%/) { |
|---|
| 23 |
if($1 > $self->{'limit'}) { |
|---|
| 24 |
return "BAD", "$1% full"; |
|---|
| 25 |
} |
|---|
| 26 |
if(exists $self->{'warnat'} && $1 > $self->{'warnat'}) { |
|---|
| 27 |
return "WARNING", "$1% full"; |
|---|
| 28 |
} |
|---|
| 29 |
return "OK", "$1% full"; |
|---|
| 30 |
} |
|---|
| 31 |
return "BAD", "0 no data"; |
|---|
| 32 |
} |
|---|
| 33 |
|
|---|
| 34 |
1; |
|---|