mirror of
https://github.com/c-kr/check_json.git
synced 2024-11-23 19:03:49 +01:00
added x-auth option
This commit is contained in:
parent
2e8e519493
commit
f6d603b6e7
@ -19,6 +19,7 @@ my $np = Nagios::Plugin->new(
|
||||
. "[ -m|--metadata <content> ] "
|
||||
. "[ -T|--contenttype <content-type> ] "
|
||||
. "[ --ignoressl ] "
|
||||
. "[ -x|--xauth <X-Auth-Token> ] "
|
||||
. "[ -h|--help ] ",
|
||||
version => '0.5',
|
||||
blurb => 'Nagios plugin to check JSON attributes via http(s)',
|
||||
@ -99,20 +100,29 @@ $np->add_arg(
|
||||
help => "--ignoressl\n Ignore bad ssl certificates",
|
||||
);
|
||||
|
||||
$np->add_arg(
|
||||
spec => 'xauth|x=s',
|
||||
help => "-x|--xauth\n Use X-Auth-Token in header",
|
||||
);
|
||||
|
||||
|
||||
## Parse @ARGV and process standard arguments (e.g. usage, help, version)
|
||||
$np->getopts;
|
||||
if ($np->opts->verbose) { (print Dumper ($np))};
|
||||
|
||||
## GET URL
|
||||
my $ua = LWP::UserAgent->new;
|
||||
|
||||
$ua->env_proxy;
|
||||
$ua->agent('check_json/0.5');
|
||||
$ua->default_header('Accept' => 'application/json');
|
||||
$ua->default_header('Accept' => 'application/json' );
|
||||
$ua->protocols_allowed( [ 'http', 'https'] );
|
||||
$ua->parse_head(0);
|
||||
$ua->timeout($np->opts->timeout);
|
||||
|
||||
if ($np->opts->xauth) {
|
||||
$ua->default_header('Accept' => 'application/json', 'X-Auth-Token' => $np->opts->xauth );
|
||||
}
|
||||
|
||||
if ($np->opts->ignoressl) {
|
||||
$ua->ssl_opts(verify_hostname => 0, SSL_verify_mode => 0x00);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user