diff --git a/check_json.pl b/check_json.pl index 95553e4..f2cd564 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 " @@ -156,6 +162,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); } if ( $check_value eq "true" or $check_value eq "false" ) {