mirror of
https://github.com/c-kr/check_json.git
synced 2026-02-05 22:55:15 +01:00
Added Accept application/json
Some APIs output only cleartext if a correct accept-header is missing.
This commit is contained in:
@@ -7,7 +7,7 @@ use JSON 'decode_json';
|
|||||||
use Nagios::Plugin;
|
use Nagios::Plugin;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
my $np = Nagios::Plugin->new(
|
my $np = Nagios::Plugin->new(
|
||||||
usage => "Usage: %s [ -v|--verbose ] [-U <URL>] [-t <timeout>] "
|
usage => "Usage: %s [ -v|--verbose ] [-U <URL>] [-t <timeout>] "
|
||||||
. "[ -c|--critical <threshold> ] [ -w|--warning <threshold> ] "
|
. "[ -c|--critical <threshold> ] [ -w|--warning <threshold> ] "
|
||||||
. "[ -a | --attribute ] <attribute>",
|
. "[ -a | --attribute ] <attribute>",
|
||||||
@@ -56,6 +56,7 @@ $np->getopts;
|
|||||||
my $ua = LWP::UserAgent->new;
|
my $ua = LWP::UserAgent->new;
|
||||||
|
|
||||||
$ua->agent('check_json/0.1');
|
$ua->agent('check_json/0.1');
|
||||||
|
$ua->default_header('Accept' => 'application/json');
|
||||||
$ua->protocols_allowed( [ 'http', 'https'] );
|
$ua->protocols_allowed( [ 'http', 'https'] );
|
||||||
$ua->parse_head(0);
|
$ua->parse_head(0);
|
||||||
$ua->timeout($np->opts->timeout);
|
$ua->timeout($np->opts->timeout);
|
||||||
@@ -88,7 +89,7 @@ if (defined $np->opts->divisor) {
|
|||||||
|
|
||||||
my $result = $np->check_threshold($value);
|
my $result = $np->check_threshold($value);
|
||||||
|
|
||||||
$np->add_perfdata(
|
$np->add_perfdata(
|
||||||
label => 'value',
|
label => 'value',
|
||||||
value => $value,
|
value => $value,
|
||||||
threshold => $np->threshold(),
|
threshold => $np->threshold(),
|
||||||
|
|||||||
Reference in New Issue
Block a user