diff --git a/check_json.pl b/check_json.pl index 02f9a6f..87e87f6 100755 --- a/check_json.pl +++ b/check_json.pl @@ -11,6 +11,7 @@ use Data::Dumper; my $np = Nagios::Plugin->new( usage => "Usage: %s -u|--url -a|--attributes " . "[ -c|--critical ] [ -w|--warning ] " + . "[ -e|--expect ] " . "[ -p|--perfvars ] " . "[ -o|--outputvars ] " . "[ -t|--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 " @@ -154,6 +160,10 @@ foreach my $attribute (sort keys %attributes){ if ($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); } my $resultTmp = $np->check_threshold(