mirror of
https://github.com/c-kr/check_json.git
synced 2024-11-23 10:53:47 +01:00
now exit critical on connection error
This commit is contained in:
parent
1f4757d1dc
commit
45d107edc1
@ -57,13 +57,17 @@ $ua->protocols_allowed( [ 'http', 'https'] );
|
||||
$ua->parse_head(0);
|
||||
$ua->timeout($np->opts->timeout);
|
||||
|
||||
my $response = $ua->get($np->opts->URL);
|
||||
my $response = ($ua->get($np->opts->URL));
|
||||
|
||||
if ($response->header("content-type") ne 'application/json') {
|
||||
$np->nagios_exit(UNKNOWN,"Content type is not JSON: ".$response->header("content-type"));
|
||||
if ($response->is_success) {
|
||||
if ($response->header("content-type") ne 'application/json') {
|
||||
$np->nagios_exit(UNKNOWN,"Content type is not JSON: ".$response->header("content-type"));
|
||||
}
|
||||
} else {
|
||||
$np->nagios_exit(CRITICAL, "Connection failed: ".$response->status_line);
|
||||
}
|
||||
|
||||
my $json_response = decode_json($response->content) ; #NAG-EXIT;
|
||||
my $json_response = decode_json($response->content);
|
||||
if ($np->opts->verbose) { (print Dumper ($json_response))};
|
||||
|
||||
my $value;
|
||||
|
Loading…
Reference in New Issue
Block a user