mirror of
https://github.com/c-kr/check_json.git
synced 2024-11-23 10:53:47 +01:00
commit
3c0e5b5252
@ -11,6 +11,7 @@ use Data::Dumper;
|
|||||||
my $np = Nagios::Plugin->new(
|
my $np = Nagios::Plugin->new(
|
||||||
usage => "Usage: %s -u|--url <http://user:pass\@host:port/url> -a|--attributes <attributes> "
|
usage => "Usage: %s -u|--url <http://user:pass\@host:port/url> -a|--attributes <attributes> "
|
||||||
. "[ -c|--critical <thresholds> ] [ -w|--warning <thresholds> ] "
|
. "[ -c|--critical <thresholds> ] [ -w|--warning <thresholds> ] "
|
||||||
|
. "[ -e|--expect <value> ] "
|
||||||
. "[ -p|--perfvars <fields> ] "
|
. "[ -p|--perfvars <fields> ] "
|
||||||
. "[ -o|--outputvars <fields> ] "
|
. "[ -o|--outputvars <fields> ] "
|
||||||
. "[ -t|--timeout <timeout> ] "
|
. "[ -t|--timeout <timeout> ] "
|
||||||
@ -63,6 +64,11 @@ $np->add_arg(
|
|||||||
. 'for the threshold format. ',
|
. 'for the threshold format. ',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$np->add_arg(
|
||||||
|
spec => 'expect|e=s',
|
||||||
|
help => '-e, --expect expected value to see for attribute.',
|
||||||
|
);
|
||||||
|
|
||||||
$np->add_arg(
|
$np->add_arg(
|
||||||
spec => 'perfvars|p=s',
|
spec => 'perfvars|p=s',
|
||||||
help => "-p, --perfvars eg. '* or {shares}->{dead},{shares}->{live}'\n "
|
help => "-p, --perfvars eg. '* or {shares}->{dead},{shares}->{live}'\n "
|
||||||
@ -158,6 +164,10 @@ foreach my $attribute (sort keys %attributes){
|
|||||||
$check_value = $check_value/$attributes{$attribute}{'divisor'};
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
if ( $check_value eq "true" or $check_value eq "false" ) {
|
if ( $check_value eq "true" or $check_value eq "false" ) {
|
||||||
if ( $check_value eq "true") {
|
if ( $check_value eq "true") {
|
||||||
$resultTmp = 0;
|
$resultTmp = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user