mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 23:54:18 +02:00
change httplib class to http class
This commit is contained in:
parent
033a939b77
commit
670ab30c54
@ -18,13 +18,13 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
package docker::docker::mode::blockio;
|
package cloud::docker::mode::blockio;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::httplib;
|
use centreon::plugins::http;
|
||||||
use centreon::plugins::statefile;
|
use centreon::plugins::statefile;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
@ -53,11 +53,11 @@ sub new {
|
|||||||
"cert-file:s" => { name => 'cert_file' },
|
"cert-file:s" => { name => 'cert_file' },
|
||||||
"key-file:s" => { name => 'key_file' },
|
"key-file:s" => { name => 'key_file' },
|
||||||
"cacert-file:s" => { name => 'cacert_file' },
|
"cacert-file:s" => { name => 'cacert_file' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout' },
|
||||||
});
|
});
|
||||||
|
|
||||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
$self->{http} = centreon::plugins::http->new(output => $self->{output});
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,14 +65,6 @@ sub check_options {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{hostname})) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the hostname option");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
if ((defined($self->{option_results}->{credentials})) && (!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
if ((defined($self->{option_results}->{name})) && (defined($self->{option_results}->{id}))) {
|
if ((defined($self->{option_results}->{name})) && (defined($self->{option_results}->{id}))) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the name or id option");
|
$self->{output}->add_option_msg(short_msg => "Please set the name or id option");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
@ -98,6 +90,15 @@ sub check_options {
|
|||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{option_results}->{get_param} = [];
|
||||||
|
push @{$self->{option_results}->{get_param}}, "stream=false";
|
||||||
|
if (defined($self->{option_results}->{id})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats";
|
||||||
|
} elsif (defined($self->{option_results}->{name})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats";
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{http}->set_options(%{$self->{option_results}});
|
||||||
$self->{statefile_value}->check_options(%options);
|
$self->{statefile_value}->check_options(%options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,21 +108,12 @@ sub run {
|
|||||||
my $new_datas = {};
|
my $new_datas = {};
|
||||||
|
|
||||||
if (defined($self->{option_results}->{id})) {
|
if (defined($self->{option_results}->{id})) {
|
||||||
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{id} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
|
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{id} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
|
||||||
} elsif (defined($self->{option_results}->{name})) {
|
} elsif (defined($self->{option_results}->{name})) {
|
||||||
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{name} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
|
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{name} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
|
||||||
}
|
}
|
||||||
|
|
||||||
my $jsoncontent;
|
my $jsoncontent = $self->{http}->request();
|
||||||
my $query_form_get = { stream => 'false' };
|
|
||||||
|
|
||||||
if (defined($self->{option_results}->{id})) {
|
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats";
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
|
||||||
} elsif (defined($self->{option_results}->{name})) {
|
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats";
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
|
||||||
}
|
|
||||||
|
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::httplib;
|
use centreon::plugins::http;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
my $thresholds = {
|
my $thresholds = {
|
||||||
@ -59,10 +59,11 @@ sub new {
|
|||||||
"cert-file:s" => { name => 'cert_file' },
|
"cert-file:s" => { name => 'cert_file' },
|
||||||
"key-file:s" => { name => 'key_file' },
|
"key-file:s" => { name => 'key_file' },
|
||||||
"cacert-file:s" => { name => 'cacert_file' },
|
"cacert-file:s" => { name => 'cacert_file' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout' },
|
||||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$self->{http} = centreon::plugins::http->new(output => $self->{output});
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,16 +71,6 @@ sub check_options {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{hostname})) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the hostname option");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{credentials})) && (!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{name})) && ($self->{option_results}->{name} eq '')) {
|
if ((defined($self->{option_results}->{name})) && ($self->{option_results}->{name} eq '')) {
|
||||||
$self->{output}->add_option_msg(short_msg => "You need to specify the name option");
|
$self->{output}->add_option_msg(short_msg => "You need to specify the name option");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
@ -104,6 +95,18 @@ sub check_options {
|
|||||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
|
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{id})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/json";
|
||||||
|
} elsif (defined($self->{option_results}->{name})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/json";
|
||||||
|
} else {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/json";
|
||||||
|
$self->{option_results}->{get_param} = [];
|
||||||
|
push @{$self->{option_results}->{get_param}}, "all=true";
|
||||||
|
}
|
||||||
|
$self->{http}->set_options(%{$self->{option_results}});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_severity {
|
sub get_severity {
|
||||||
@ -130,19 +133,7 @@ sub get_severity {
|
|||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $jsoncontent;
|
my $jsoncontent = $self->{http}->request();
|
||||||
|
|
||||||
if (defined($self->{option_results}->{id})) {
|
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/json";
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
|
|
||||||
} elsif (defined($self->{option_results}->{name})) {
|
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/json";
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
|
|
||||||
} else {
|
|
||||||
$self->{option_results}->{url_path} = "/containers/json";
|
|
||||||
my $query_form_get = { all => 'true' };
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
|
||||||
}
|
|
||||||
|
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::httplib;
|
use centreon::plugins::http;
|
||||||
use centreon::plugins::statefile;
|
use centreon::plugins::statefile;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
@ -51,10 +51,11 @@ sub new {
|
|||||||
"cert-file:s" => { name => 'cert_file' },
|
"cert-file:s" => { name => 'cert_file' },
|
||||||
"key-file:s" => { name => 'key_file' },
|
"key-file:s" => { name => 'key_file' },
|
||||||
"cacert-file:s" => { name => 'cacert_file' },
|
"cacert-file:s" => { name => 'cacert_file' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout' },
|
||||||
});
|
});
|
||||||
|
|
||||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
$self->{http} = centreon::plugins::http->new(output => $self->{output});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
@ -63,16 +64,6 @@ sub check_options {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{hostname})) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the hostname option");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{credentials})) && (!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{name})) && (defined($self->{option_results}->{id}))) {
|
if ((defined($self->{option_results}->{name})) && (defined($self->{option_results}->{id}))) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the name or id option");
|
$self->{output}->add_option_msg(short_msg => "Please set the name or id option");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
@ -93,25 +84,29 @@ sub check_options {
|
|||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{option_results}->{get_param} = [];
|
||||||
|
push @{$self->{option_results}->{get_param}}, "stream=false";
|
||||||
|
if (defined($self->{option_results}->{id})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats";
|
||||||
|
} elsif (defined($self->{option_results}->{name})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats";
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{http}->set_options(%{$self->{option_results}});
|
||||||
$self->{statefile_value}->check_options(%options);
|
$self->{statefile_value}->check_options(%options);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $jsoncontent;
|
|
||||||
my $query_form_get = { stream => 'false' };
|
|
||||||
|
|
||||||
if (defined($self->{option_results}->{id})) {
|
if (defined($self->{option_results}->{id})) {
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats";
|
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{id} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
|
||||||
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{id} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
|
|
||||||
} elsif (defined($self->{option_results}->{name})) {
|
} elsif (defined($self->{option_results}->{name})) {
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats";
|
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{name} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
|
||||||
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{name} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $jsoncontent = $self->{http}->request();
|
||||||
|
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
my $webcontent;
|
my $webcontent;
|
||||||
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::httplib;
|
use centreon::plugins::http;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -52,9 +52,10 @@ sub new {
|
|||||||
"cert-file:s" => { name => 'cert_file' },
|
"cert-file:s" => { name => 'cert_file' },
|
||||||
"key-file:s" => { name => 'key_file' },
|
"key-file:s" => { name => 'key_file' },
|
||||||
"cacert-file:s" => { name => 'cacert_file' },
|
"cacert-file:s" => { name => 'cacert_file' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$self->{http} = centreon::plugins::http->new(output => $self->{output});
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,16 +63,6 @@ sub check_options {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{hostname})) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the hostname option");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{credentials})) && (!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{name})) && (defined($self->{option_results}->{id}))) {
|
if ((defined($self->{option_results}->{name})) && (defined($self->{option_results}->{id}))) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the name or id option");
|
$self->{output}->add_option_msg(short_msg => "Please set the name or id option");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
@ -96,25 +87,25 @@ sub check_options {
|
|||||||
$self->{output}->add_option_msg(short_msg => "Please set the registry-proto option");
|
$self->{output}->add_option_msg(short_msg => "Please set the registry-proto option");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{id})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/json";
|
||||||
|
} elsif (defined($self->{option_results}->{name})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/json";
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{http}->set_options(%{$self->{option_results}});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my ($jsoncontent,$jsoncontent2);
|
my ($jsoncontent,$jsoncontent2, $webcontent, $webcontent2);
|
||||||
|
|
||||||
if (defined($self->{option_results}->{id})) {
|
$jsoncontent = $self->{http}->request();
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/json";
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
|
|
||||||
} elsif (defined($self->{option_results}->{name})) {
|
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/json";
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
|
|
||||||
}
|
|
||||||
|
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
my ($webcontent,$webcontent2);
|
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
$webcontent = $json->decode($jsoncontent);
|
$webcontent = $json->decode($jsoncontent);
|
||||||
};
|
};
|
||||||
@ -131,7 +122,7 @@ sub run {
|
|||||||
$self->{option_results}->{proto} = $self->{option_results}->{registry_proto};
|
$self->{option_results}->{proto} = $self->{option_results}->{registry_proto};
|
||||||
$self->{option_results}->{hostname} = $self->{option_results}->{registry_hostname};
|
$self->{option_results}->{hostname} = $self->{option_results}->{registry_hostname};
|
||||||
|
|
||||||
$jsoncontent2 = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
|
$jsoncontent2 = $self->{http}->request();
|
||||||
|
|
||||||
my $json2 = JSON->new;
|
my $json2 = JSON->new;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::httplib;
|
use centreon::plugins::http;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -46,9 +46,10 @@ sub new {
|
|||||||
"cert-file:s" => { name => 'cert_file' },
|
"cert-file:s" => { name => 'cert_file' },
|
||||||
"key-file:s" => { name => 'key_file' },
|
"key-file:s" => { name => 'key_file' },
|
||||||
"cacert-file:s" => { name => 'cacert_file' },
|
"cacert-file:s" => { name => 'cacert_file' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$self->{http} = centreon::plugins::http->new(output => $self->{output});
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,22 +57,13 @@ sub check_options {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{hostname})) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the hostname option");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{credentials})) && (!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
|
||||||
my $jsoncontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
|
my $jsoncontent = $self->{http}->request();;
|
||||||
|
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::httplib;
|
use centreon::plugins::http;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -46,9 +46,10 @@ sub new {
|
|||||||
"cert-file:s" => { name => 'cert_file' },
|
"cert-file:s" => { name => 'cert_file' },
|
||||||
"key-file:s" => { name => 'key_file' },
|
"key-file:s" => { name => 'key_file' },
|
||||||
"cacert-file:s" => { name => 'cacert_file' },
|
"cacert-file:s" => { name => 'cacert_file' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$self->{http}->set_options(%{$self->{option_results}});
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,25 +57,17 @@ sub check_options {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{hostname})) {
|
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."containers/json";
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the hostname option");
|
$self->{option_results}->{get_param} = [];
|
||||||
$self->{output}->option_exit();
|
push @{$self->{option_results}->{get_param}}, "all=true";
|
||||||
}
|
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{credentials})) && (!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) {
|
$self->{http}->set_options(%{$self->{option_results}})
|
||||||
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $jsoncontent;
|
my $jsoncontent = $self->{http}->request();
|
||||||
|
|
||||||
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."containers/json";
|
|
||||||
my $query_form_get = { all => 'true' };
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
|
||||||
|
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::httplib;
|
use centreon::plugins::http;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -50,7 +50,7 @@ sub new {
|
|||||||
"cert-file:s" => { name => 'cert_file' },
|
"cert-file:s" => { name => 'cert_file' },
|
||||||
"key-file:s" => { name => 'key_file' },
|
"key-file:s" => { name => 'key_file' },
|
||||||
"cacert-file:s" => { name => 'cacert_file' },
|
"cacert-file:s" => { name => 'cacert_file' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
@ -60,16 +60,6 @@ sub check_options {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{hostname})) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the hostname option");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{credentials})) && (!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{name})) && (defined($self->{option_results}->{id}))) {
|
if ((defined($self->{option_results}->{name})) && (defined($self->{option_results}->{id}))) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the name or id option");
|
$self->{output}->add_option_msg(short_msg => "Please set the name or id option");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
@ -89,21 +79,22 @@ sub check_options {
|
|||||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{option_results}->{get_param} = [];
|
||||||
|
push @{$self->{option_results}->{get_param}}, "stream=false";
|
||||||
|
if (defined($self->{option_results}->{id})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats";
|
||||||
|
} elsif (defined($self->{option_results}->{name})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats";
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{http}->set_options(%{$self->{option_results}});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $jsoncontent;
|
my $jsoncontent = $self->{http}->request();
|
||||||
my $query_form_get = { stream => 'false' };
|
|
||||||
|
|
||||||
if (defined($self->{option_results}->{id})) {
|
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats";
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
|
||||||
} elsif (defined($self->{option_results}->{name})) {
|
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats";
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
|
||||||
}
|
|
||||||
|
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::httplib;
|
use centreon::plugins::http;
|
||||||
use centreon::plugins::statefile;
|
use centreon::plugins::statefile;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
@ -53,11 +53,11 @@ sub new {
|
|||||||
"cert-file:s" => { name => 'cert_file' },
|
"cert-file:s" => { name => 'cert_file' },
|
||||||
"key-file:s" => { name => 'key_file' },
|
"key-file:s" => { name => 'key_file' },
|
||||||
"cacert-file:s" => { name => 'cacert_file' },
|
"cacert-file:s" => { name => 'cacert_file' },
|
||||||
"timeout:s" => { name => 'timeout', default => '3' },
|
"timeout:s" => { name => 'timeout' },
|
||||||
});
|
});
|
||||||
|
|
||||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
|
$self->{http} = centreon::plugins::http->new(output => $self->{output});
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,14 +65,6 @@ sub check_options {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{hostname})) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the hostname option");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
if ((defined($self->{option_results}->{credentials})) && (!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
if ((defined($self->{option_results}->{name})) && (defined($self->{option_results}->{id}))) {
|
if ((defined($self->{option_results}->{name})) && (defined($self->{option_results}->{id}))) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set the name or id option");
|
$self->{output}->add_option_msg(short_msg => "Please set the name or id option");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
@ -98,6 +90,15 @@ sub check_options {
|
|||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{option_results}->{get_param} = [];
|
||||||
|
push @{$self->{option_results}->{get_param}}, "stream=false";
|
||||||
|
if (defined($self->{option_results}->{id})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats";
|
||||||
|
} elsif (defined($self->{option_results}->{name})) {
|
||||||
|
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats";
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{http}->set_options(%{$self->{option_results}});
|
||||||
$self->{statefile_value}->check_options(%options);
|
$self->{statefile_value}->check_options(%options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,21 +108,12 @@ sub run {
|
|||||||
my $new_datas = {};
|
my $new_datas = {};
|
||||||
|
|
||||||
if (defined($self->{option_results}->{id})) {
|
if (defined($self->{option_results}->{id})) {
|
||||||
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{id} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
|
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{id} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
|
||||||
} elsif (defined($self->{option_results}->{name})) {
|
} elsif (defined($self->{option_results}->{name})) {
|
||||||
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{name} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
|
$self->{statefile_value}->read(statefile => 'docker_' . $self->{option_results}->{name} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
|
||||||
}
|
}
|
||||||
|
|
||||||
my $jsoncontent;
|
my $jsoncontent = $self->{http}->request();
|
||||||
my $query_form_get = { stream => 'false' };
|
|
||||||
|
|
||||||
if (defined($self->{option_results}->{id})) {
|
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{id}."/stats";
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
|
||||||
} elsif (defined($self->{option_results}->{name})) {
|
|
||||||
$self->{option_results}->{url_path} = "/containers/".$self->{option_results}->{name}."/stats";
|
|
||||||
$jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
|
||||||
}
|
|
||||||
|
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user