mirror of https://github.com/jimsalterjrs/sanoid
Revert "allow monitor-health to optionally check zpool capacity too by providing limits along the flag"
This reverts commit 6c695f1a86.
This commit is contained in:
parent
6c695f1a86
commit
6f29bed441
|
|
@ -60,7 +60,7 @@ Which would be enough to tell sanoid to take and keep 36 hourly snapshots, 30 da
|
||||||
|
|
||||||
+ --monitor-health
|
+ --monitor-health
|
||||||
|
|
||||||
This option is designed to be run by a Nagios monitoring system. It reports on the health of the zpool your filesystems are on. It only monitors filesystems that are configured in the sanoid.conf file. Optionally it can check capacity limits too by appending them like '=80,95" (>= 80% warning, >=95% critical).
|
This option is designed to be run by a Nagios monitoring system. It reports on the health of the zpool your filesystems are on. It only monitors filesystems that are configured in the sanoid.conf file.
|
||||||
|
|
||||||
+ --force-update
|
+ --force-update
|
||||||
|
|
||||||
|
|
|
||||||
89
sanoid
89
sanoid
|
|
@ -17,7 +17,7 @@ use Time::Local; # to parse dates in reverse
|
||||||
|
|
||||||
my %args = ("configdir" => "/etc/sanoid");
|
my %args = ("configdir" => "/etc/sanoid");
|
||||||
GetOptions(\%args, "verbose", "debug", "cron", "readonly", "quiet",
|
GetOptions(\%args, "verbose", "debug", "cron", "readonly", "quiet",
|
||||||
"monitor-health:s", "force-update", "configdir=s",
|
"monitor-health", "force-update", "configdir=s",
|
||||||
"monitor-snapshots", "take-snapshots", "prune-snapshots"
|
"monitor-snapshots", "take-snapshots", "prune-snapshots"
|
||||||
) or pod2usage(2);
|
) or pod2usage(2);
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ my @params = ( \%config, \%snaps, \%snapsbytype, \%snapsbypath );
|
||||||
|
|
||||||
if ($args{'debug'}) { $args{'verbose'}=1; blabber (@params); }
|
if ($args{'debug'}) { $args{'verbose'}=1; blabber (@params); }
|
||||||
if ($args{'monitor-snapshots'}) { monitor_snapshots(@params); }
|
if ($args{'monitor-snapshots'}) { monitor_snapshots(@params); }
|
||||||
if (defined($args{'monitor-health'})) { monitor_health(@params); }
|
if ($args{'monitor-health'}) { monitor_health(@params); }
|
||||||
if ($args{'force-update'}) { my $snaps = getsnaps( \%config, $cacheTTL, 1 ); }
|
if ($args{'force-update'}) { my $snaps = getsnaps( \%config, $cacheTTL, 1 ); }
|
||||||
|
|
||||||
if ($args{'cron'}) {
|
if ($args{'cron'}) {
|
||||||
|
|
@ -76,32 +76,13 @@ sub monitor_health {
|
||||||
my @messages;
|
my @messages;
|
||||||
my $errlevel=0;
|
my $errlevel=0;
|
||||||
|
|
||||||
my %capacitylimits;
|
|
||||||
|
|
||||||
# if provided, parse capacity limits
|
|
||||||
if ($args{'monitor-health'} ne "") {
|
|
||||||
my @values = split(',', $args{'monitor-health'});
|
|
||||||
|
|
||||||
if (!check_capacity_limit($values[0])) {
|
|
||||||
die "ERROR: invalid zpool capacity warning limit!\n";
|
|
||||||
}
|
|
||||||
$capacitylimits{"warn"} = $values[0];
|
|
||||||
|
|
||||||
if (scalar @values > 1) {
|
|
||||||
if (!check_capacity_limit($values[1])) {
|
|
||||||
die "ERROR: invalid zpool capacity critical limit!\n";
|
|
||||||
}
|
|
||||||
$capacitylimits{"crit"} = $values[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $path (keys %{ $snapsbypath}) {
|
foreach my $path (keys %{ $snapsbypath}) {
|
||||||
my @pool = split ('/',$path);
|
my @pool = split ('/',$path);
|
||||||
$pools{$pool[0]}=1;
|
$pools{$pool[0]}=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $pool (keys %pools) {
|
foreach my $pool (keys %pools) {
|
||||||
my ($exitcode, $msg) = check_zpool($pool,2,\%capacitylimits);
|
my ($exitcode, $msg) = check_zpool($pool,2);
|
||||||
if ($exitcode > $errlevel) { $errlevel = $exitcode; }
|
if ($exitcode > $errlevel) { $errlevel = $exitcode; }
|
||||||
chomp $msg;
|
chomp $msg;
|
||||||
push (@messages, $msg);
|
push (@messages, $msg);
|
||||||
|
|
@ -767,8 +748,6 @@ sub check_zpool() {
|
||||||
|
|
||||||
my $pool=shift;
|
my $pool=shift;
|
||||||
my $verbose=shift;
|
my $verbose=shift;
|
||||||
my $capacitylimitsref=shift;
|
|
||||||
my %capacitylimits=%$capacitylimitsref;
|
|
||||||
|
|
||||||
my $size="";
|
my $size="";
|
||||||
my $used="";
|
my $used="";
|
||||||
|
|
@ -820,21 +799,15 @@ sub check_zpool() {
|
||||||
if ($health eq "ONLINE" ) {
|
if ($health eq "ONLINE" ) {
|
||||||
$state = "OK";
|
$state = "OK";
|
||||||
|
|
||||||
if (%capacitylimits) {
|
# check capacity
|
||||||
# check capacity
|
my $capn = $cap;
|
||||||
my $capn = $cap;
|
$capn =~ s/\D//g;
|
||||||
$capn =~ s/\D//g;
|
|
||||||
|
|
||||||
if ($capacitylimits{"warn"}) {
|
if ($capn >= 80) {
|
||||||
if ($capn >= $capacitylimits{"warn"}) {
|
$state = "WARNING";
|
||||||
$state = "WARNING";
|
}
|
||||||
}
|
if ($capn >= 95) {
|
||||||
}
|
$state = "CRITICAL";
|
||||||
if ($capacitylimits{"crit"}) {
|
|
||||||
if ($capn >= $capacitylimits{"crit"}) {
|
|
||||||
$state = "CRITICAL";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($health eq "DEGRADED") {
|
if ($health eq "DEGRADED") {
|
||||||
|
|
@ -938,20 +911,6 @@ sub check_zpool() {
|
||||||
return ($ERRORS{$state},$msg);
|
return ($ERRORS{$state},$msg);
|
||||||
} # end check_zpool()
|
} # end check_zpool()
|
||||||
|
|
||||||
sub check_capacity_limit() {
|
|
||||||
my $value = shift;
|
|
||||||
|
|
||||||
if ($value !~ /^\d+\z/) {
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($value < 1 || $value > 100) {
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
|
|
@ -1122,19 +1081,19 @@ Assumes --cron --verbose if no other arguments (other than configdir) are specif
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
--configdir=DIR Specify a directory to find config file sanoid.conf
|
--configdir=DIR Specify a directory to find config file sanoid.conf
|
||||||
|
|
||||||
--cron Creates snapshots and purges expired snapshots
|
--cron Creates snapshots and purges expired snapshots
|
||||||
--verbose Prints out additional information during a sanoid run
|
--verbose Prints out additional information during a sanoid run
|
||||||
--readonly Simulates creation/deletion of snapshots
|
--readonly Simulates creation/deletion of snapshots
|
||||||
--quiet Suppresses non-error output
|
--quiet Suppresses non-error output
|
||||||
--force-update Clears out sanoid's zfs snapshot cache
|
--force-update Clears out sanoid's zfs snapshot cache
|
||||||
|
|
||||||
--monitor-health[=wlimit[,climit]] Reports on zpool "health", in a Nagios compatible format
|
--monitor-health Reports on zpool "health", in a Nagios compatible format
|
||||||
--monitor-snapshots Reports on snapshot "health", in a Nagios compatible format
|
--monitor-snapshots Reports on snapshot "health", in a Nagios compatible format
|
||||||
--take-snapshots Creates snapshots as specified in sanoid.conf
|
--take-snapshots Creates snapshots as specified in sanoid.conf
|
||||||
--prune-snapshots Purges expired snapshots as specified in sanoid.conf
|
--prune-snapshots Purges expired snapshots as specified in sanoid.conf
|
||||||
|
|
||||||
--help Prints this helptext
|
--help Prints this helptext
|
||||||
--version Prints the version number
|
--version Prints the version number
|
||||||
--debug Prints out a lot of additional information during a sanoid run
|
--debug Prints out a lot of additional information during a sanoid run
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue