+ Ref #634 : add proxy options
This commit is contained in:
parent
ad92ba94ef
commit
0b84ff6b12
|
@ -26,7 +26,6 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::http;
|
use centreon::plugins::http;
|
||||||
use JSON;
|
use JSON;
|
||||||
use Data::Dumper;
|
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
|
@ -36,14 +35,16 @@ sub new {
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments =>
|
||||||
{
|
{
|
||||||
"hostname:s" => { name => 'hostname' },
|
"hostname:s" => { name => 'hostname' },
|
||||||
"port:s" => { name => 'port', default => 443 },
|
"port:s" => { name => 'port', default => 443 },
|
||||||
"proto:s" => { name => 'proto', default => 'https' },
|
"proto:s" => { name => 'proto', default => 'https' },
|
||||||
"username:s" => { name => 'username' },
|
"proxyurl:s" => { name => 'proxyurl' },
|
||||||
"password:s" => { name => 'password' },
|
"proxypac:s" => { name => 'proxypac' },
|
||||||
"phonenumber:s" => { name => 'phonenumber' },
|
"username:s" => { name => 'username' },
|
||||||
"message:s" => { name => 'message' },
|
"password:s" => { name => 'password' },
|
||||||
"sender:s" => { name => 'sender', default => 'API_HIGHSMS' },
|
"phonenumber:s" => { name => 'phonenumber' },
|
||||||
|
"message:s" => { name => 'message' },
|
||||||
|
"sender:s" => { name => 'sender', default => 'API_HIGHSMS' },
|
||||||
});
|
});
|
||||||
|
|
||||||
$self->{http} = centreon::plugins::http->new(output => $self->{output});
|
$self->{http} = centreon::plugins::http->new(output => $self->{output});
|
||||||
|
@ -56,7 +57,6 @@ sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if ((!defined($self->{option_results}->{username}) && !defined($self->{option_results}->{password}))) {
|
if ((!defined($self->{option_results}->{username}) && !defined($self->{option_results}->{password}))) {
|
||||||
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= option");
|
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= option");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
@ -78,7 +78,6 @@ sub check_options {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{http}->set_options(%{$self->{option_results}});
|
$self->{http}->set_options(%{$self->{option_results}});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
|
@ -94,13 +93,13 @@ sub run {
|
||||||
sender="$self->{option_results}->{sender}"
|
sender="$self->{option_results}->{sender}"
|
||||||
>
|
>
|
||||||
<message>
|
<message>
|
||||||
<text>$self->{option_results}->{message}</text>
|
<text><![CDATA[$self->{option_results}->{message}]]></text>
|
||||||
<to>$self->{option_results}->{phonenumber}</to>
|
<to>$self->{option_results}->{phonenumber}</to>
|
||||||
</message>
|
</message>
|
||||||
</push>
|
</push>
|
||||||
END_MESSAGE
|
END_MESSAGE
|
||||||
|
|
||||||
my $api_path='/api';
|
my $api_path = '/api';
|
||||||
my $url = $self->{option_results}->{proto} . '://' . $self->{option_results}->{hostname} . $api_path;
|
my $url = $self->{option_results}->{proto} . '://' . $self->{option_results}->{hostname} . $api_path;
|
||||||
|
|
||||||
my $response = $self->{http}->request(full_url => $url, method => 'POST', query_form_post => $xml_arg);
|
my $response = $self->{http}->request(full_url => $url, method => 'POST', query_form_post => $xml_arg);
|
||||||
|
@ -108,9 +107,7 @@ END_MESSAGE
|
||||||
$self->{output}->output_add(short_msg => 'push_id : ' . $response);
|
$self->{output}->output_add(short_msg => 'push_id : ' . $response);
|
||||||
$self->{output}->display(force_ignore_perfdata => 1);
|
$self->{output}->display(force_ignore_perfdata => 1);
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
@ -134,6 +131,14 @@ Port used by HighSMS API. (Default: 443)
|
||||||
|
|
||||||
Specify http or https protocol. (Default: https)
|
Specify http or https protocol. (Default: https)
|
||||||
|
|
||||||
|
=item B<--proxyurl>
|
||||||
|
|
||||||
|
Proxy URL
|
||||||
|
|
||||||
|
=item B<--proxypac>
|
||||||
|
|
||||||
|
Proxy pac file (can be an url or local file)
|
||||||
|
|
||||||
=item B<--username>
|
=item B<--username>
|
||||||
|
|
||||||
Specify username for API authentification.
|
Specify username for API authentification.
|
||||||
|
|
|
@ -31,7 +31,7 @@ sub new {
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
$self->{version} = '0.1';
|
||||||
%{$self->{modes}} = (
|
%{$self->{modes}} = (
|
||||||
'alert' => 'notification::highsms::mode::alert',
|
'alert' => 'notification::highsms::mode::alert',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
|
Loading…
Reference in New Issue