From f6db970909ef827da40dcd31b09ba5581f51f864 Mon Sep 17 00:00:00 2001 From: Patrick McAndrew Date: Fri, 16 May 2014 16:39:08 +0100 Subject: [PATCH] add expect --- check_json.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/check_json.pl b/check_json.pl index ea5ff90..a99e51b 100755 --- a/check_json.pl +++ b/check_json.pl @@ -10,6 +10,7 @@ use Data::Dumper; my $np = Nagios::Plugin->new( usage => "Usage: %s -u|--url -a|--attribute " . "[ -c|--critical ] [ -w|--warning ] " + . "[ -e|--expect ] " . "[ -p|--perfvars ] " . "[ -o|--outputvars ] " . "[ -t|--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;