mirror of
https://github.com/c-kr/check_json.git
synced 2024-11-23 10:53:47 +01:00
add expect
This commit is contained in:
parent
a4529419db
commit
f6db970909
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user