From 23a7580f2e55f49ac0b0eb65b1aa973a0bcc8415 Mon Sep 17 00:00:00 2001 From: "mail@denisu.jp" Date: Wed, 26 Jun 2013 20:06:21 +0900 Subject: [PATCH] Added Accept application/json Some APIs output only cleartext if a correct accept-header is missing. --- check_json.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/check_json.pl b/check_json.pl index fa8ef3c..dd13c05 100755 --- a/check_json.pl +++ b/check_json.pl @@ -7,7 +7,7 @@ use JSON 'decode_json'; use Nagios::Plugin; use Data::Dumper; -my $np = Nagios::Plugin->new( +my $np = Nagios::Plugin->new( usage => "Usage: %s [ -v|--verbose ] [-U ] [-t ] " . "[ -c|--critical ] [ -w|--warning ] " . "[ -a | --attribute ] ", @@ -56,6 +56,7 @@ $np->getopts; my $ua = LWP::UserAgent->new; $ua->agent('check_json/0.1'); +$ua->default_header('Accept' => 'application/json'); $ua->protocols_allowed( [ 'http', 'https'] ); $ua->parse_head(0); $ua->timeout($np->opts->timeout); @@ -88,7 +89,7 @@ if (defined $np->opts->divisor) { my $result = $np->check_threshold($value); -$np->add_perfdata( +$np->add_perfdata( label => 'value', value => $value, threshold => $np->threshold(),