1
0
mirror of https://github.com/c-kr/check_json.git synced 2024-11-27 04:43:49 +01:00

Merge pull request #1 from PeerJ/AddExpect

add expect
This commit is contained in:
Patrick McAndrew 2014-05-16 16:40:09 +01:00
commit f7850203b8

View File

@ -10,6 +10,7 @@ use Data::Dumper;
my $np = Nagios::Plugin->new(
usage => "Usage: %s -u|--url <URL> -a|--attribute <attribute> "
. "[ -c|--critical <threshold> ] [ -w|--warning <threshold> ] "
. "[ -e|--expect <value> ] "
. "[ -p|--perfvars <fields> ] "
. "[ -o|--outputvars <fields> ] "
. "[ -t|--timeout <timeout> ] "
@ -61,6 +62,11 @@ $np->add_arg(
. 'for the threshold format. ',
);
$np->add_arg(
spec => 'expect|e=s',
help => '-e, --expect expected value to see for attribute.',
);
$np->add_arg(
spec => 'perfvars|p=s',
help => "-p, --perfvars eg. '{shares}->{dead},{shares}->{live}'\n "
@ -132,6 +138,10 @@ if (defined $np->opts->divisor) {
$check_value = $check_value/$np->opts->divisor;
}
if (defined $np->opts->expect && $np->opts->expect ne $check_value) {
$np->nagios_exit(CRITICAL, "Expected value (" . $np->opts->expect . ") not found. Actual: " . $check_value);
}
my $result = $np->check_threshold($check_value);
my @statusmsg;