1
0
mirror of https://github.com/c-kr/check_json.git synced 2024-11-23 10:53:47 +01:00

Merge remote-tracking branch 'PeerJ/master'

Conflicts:
	check_json.pl
This commit is contained in:
Ilya Margolin 2015-04-02 18:52:29 +02:00
commit b625118e1e

View File

@ -11,6 +11,7 @@ use Data::Dumper;
my $np = Nagios::Plugin->new(
usage => "Usage: %s -u|--url <URL> -a|--attributes <attributes> "
. "[ -c|--critical <thresholds> ] [ -w|--warning <thresholds> ] "
. "[ -e|--expect <value> ] "
. "[ -p|--perfvars <fields> ] "
. "[ -o|--outputvars <fields> ] "
. "[ -t|--timeout <timeout> ] "
@ -63,6 +64,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. '* or {shares}->{dead},{shares}->{live}'\n "
@ -156,6 +162,10 @@ foreach my $attribute (sort keys %attributes){
$check_value = $check_value/$attributes{$attribute}{'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 $resultTmp = $np->check_threshold(
check => $check_value,
warning => $attributes{$attribute}{'warning'},