mirror of
https://github.com/c-kr/check_json.git
synced 2024-11-23 19:03:49 +01:00
Added flag --ignoressl to ignore bad ssl certificates and fixed help text
This commit is contained in:
parent
1cd13015dc
commit
4a7e1ffb56
@ -14,8 +14,9 @@ my $np = Nagios::Plugin->new(
|
|||||||
. "[ -t|--timeout <timeout> ] "
|
. "[ -t|--timeout <timeout> ] "
|
||||||
. "[ -d|--divisor <divisor> ] "
|
. "[ -d|--divisor <divisor> ] "
|
||||||
. "[ -T|--contenttype <content-type> ] "
|
. "[ -T|--contenttype <content-type> ] "
|
||||||
|
. "[ --ignoressl ] "
|
||||||
. "[ -h|--help ] ",
|
. "[ -h|--help ] ",
|
||||||
version => '0.2',
|
version => '0.3',
|
||||||
blurb => 'Nagios plugin to check JSON attributes via http(s)',
|
blurb => 'Nagios plugin to check JSON attributes via http(s)',
|
||||||
extra => "\nExample: \n"
|
extra => "\nExample: \n"
|
||||||
. "check_json.pl --url http://192.168.5.10:9332/local_stats --attribute '{shares}->{dead}' "
|
. "check_json.pl --url http://192.168.5.10:9332/local_stats --attribute '{shares}->{dead}' "
|
||||||
@ -29,7 +30,7 @@ my $np = Nagios::Plugin->new(
|
|||||||
# add valid command line options and build them into your usage/help documentation.
|
# add valid command line options and build them into your usage/help documentation.
|
||||||
$np->add_arg(
|
$np->add_arg(
|
||||||
spec => 'url|u=s',
|
spec => 'url|u=s',
|
||||||
help => '-u, --url (eg. http://192.168.5.10:9332/local_stats}',
|
help => '-u, --url http://192.168.5.10:9332/local_stats',
|
||||||
required => 1,
|
required => 1,
|
||||||
);
|
);
|
||||||
$np->add_arg(
|
$np->add_arg(
|
||||||
@ -56,14 +57,19 @@ $np->add_arg(
|
|||||||
|
|
||||||
$np->add_arg(
|
$np->add_arg(
|
||||||
spec => 'perfvars|p=s',
|
spec => 'perfvars|p=s',
|
||||||
help => '-p, --perfvars . CSV list of fields from JSON response to include in perfdata '
|
help => "-p, --perfvars eg. '{shares}->{dead},{shares}->{live}'\n "
|
||||||
. '{shares}->{dead},{shares}->{live}',
|
. "CSV list of fields from JSON response to include in perfdata "
|
||||||
);
|
);
|
||||||
|
|
||||||
$np->add_arg(
|
$np->add_arg(
|
||||||
spec => 'contenttype|T=s',
|
spec => 'contenttype|T=s',
|
||||||
default => 'application/json',
|
default => 'application/json',
|
||||||
help => '-T, --contenttype . content-type accepted if different from application/json ',
|
help => "-T, --contenttype application/json \n "
|
||||||
|
. "Content-type accepted if different from application/json ",
|
||||||
|
);
|
||||||
|
$np->add_arg(
|
||||||
|
spec => 'ignoressl',
|
||||||
|
help => "--ignoressl\n Ignore bad ssl certificates",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -74,11 +80,16 @@ if ($np->opts->verbose) { (print Dumper ($np))};
|
|||||||
## GET URL
|
## GET URL
|
||||||
my $ua = LWP::UserAgent->new;
|
my $ua = LWP::UserAgent->new;
|
||||||
|
|
||||||
$ua->agent('check_json/0.2');
|
$ua->agent('check_json/0.3');
|
||||||
$ua->default_header('Accept' => 'application/json');
|
$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);
|
||||||
|
|
||||||
|
if ($np->opts->ignoressl) {
|
||||||
|
$ua->ssl_opts(verify_hostname => 0, SSL_verify_mode => 0x00);
|
||||||
|
}
|
||||||
|
|
||||||
if ($np->opts->verbose) { (print Dumper ($ua))};
|
if ($np->opts->verbose) { (print Dumper ($ua))};
|
||||||
|
|
||||||
my $response = ($ua->get($np->opts->url));
|
my $response = ($ua->get($np->opts->url));
|
||||||
|
Loading…
Reference in New Issue
Block a user