Choose whether to ignore/warn/crit on failed actions

This commit adds a new option to check_crm named --failedactions
Possible options are 'warning', 'critical', or anything else (which is
considered equivalent to 'ignore').
The default is 'critical' to be backward compatible.

Change-Id: I5908f5f4b7d77219280dfe896ea938459c6b23bd
Partial-Bug: #1796400
This commit is contained in:
Andrea Ieri 2018-11-06 18:43:06 +01:00
parent 535777651b
commit 9483383555
1 changed files with 18 additions and 8 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# check_crm_v0_7
# check_crm_v0_8
#
# Copyright © 2013 Philip Garner, Sysnix Consultants Limited
#
@ -31,6 +31,7 @@
# v0.7 01/09/2013 - In testing as still not fully tested. Adds optional
# constraints check (Boris Wesslowski). Adds fail count
# threshold ( Zoran Bosnjak & Marko Hrastovec )
# v0.8 06/11/2018 - Choose whether to ignore/warn/crit on failed actions
#
# NOTE:- Requires Perl 5.8 or higher & either the Perl Module Nagios::Plugin
# or Monitoring::Plugin, whichever is available for your system.
@ -78,13 +79,13 @@ my $np;
if ($plugin_provider eq 'Monitoring') {
$np = Monitoring::Plugin->new(
shortname => 'check_crm',
version => '0.7',
version => '0.8',
usage => "Usage: %s <ARGS>\n\t\t--help for help\n",
);
} else {
$np = Nagios::Plugin->new(
shortname => 'check_crm',
version => '0.7',
version => '0.8',
usage => "Usage: %s <ARGS>\n\t\t--help for help\n",
);
}
@ -115,6 +116,14 @@ $np->add_arg(
default => 1,
);
$np->add_arg(
spec => 'failedactions=s',
help => q{What to do if failed actions are detected: ignore/warning/critical [default = critical].
Any value that is not 'warning' or 'critical' will be considered equivalent to 'ignore'},
required => 0,
default => 'CRITICAL',
);
$np->getopts;
my $ConstraintsFlag = $np->opts->constraint;
@ -173,11 +182,12 @@ foreach my $line (<$fh>) {
# Check Master/Slave stopped
$np->add_message( $warn_or_crit, ": $1 Stopped" );
}
elsif ( $line =~ m/^Failed actions\:/ ) {
# Check Failed Actions
$np->add_message("CRITICAL",
": FAILED actions detected or not cleaned up" );
elsif ( $line =~ m/^failed actions\:/i ) {
if ($np->opts->failedactions =~ /^(warning|critical)$/i) {
# Check Failed Actions
$np->add_message( uc $np->opts->failedactions,
": FAILED actions detected or not cleaned up" );
}
}
elsif ( $line =~ m/\s*(\S+?)\s+ \(.*\)\:\s+\w+\s+\w+\s+\(unmanaged\)\s+/i )
{