Merge pull request #1 from centreon/master

update
This commit is contained in:
Stéphane Duret 2015-08-06 16:50:10 +02:00
commit 08b45ca222
151 changed files with 5686 additions and 4482 deletions

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,7 +36,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/server-status/?auto" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -44,8 +44,9 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -61,20 +62,13 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
# If not present: cpuload is 0
my ($cpuload) = 0;

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use centreon::plugins::statefile;
sub new {
@ -37,7 +37,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/server-status/?auto" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -49,8 +49,9 @@ sub new {
"critical-bytes:s" => { name => 'critical_bytes' },
"warning-access:s" => { name => 'warning_access' },
"critical-access:s" => { name => 'critical_access' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
return $self;
}
@ -83,22 +84,15 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical-access threshold '" . $self->{option_results}->{critical_access} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
$self->{statefile_value}->check_options(%options);
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my ($rPerSec, $bPerReq, $total_access, $total_bytes, $avg_bPerSec);
$total_access = $1 if ($webcontent =~ /^Total Accesses:\s+([^\s]+)/mi);
@ -121,7 +115,7 @@ sub run {
$avg_bPerSec = '0' . $avg_bPerSec if ($avg_bPerSec =~ /^\./);
$bPerReq = '0' . $bPerReq if ($bPerReq =~ /^\./);
$self->{statefile_value}->read(statefile => 'apache_' . $self->{option_results}->{hostname} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
$self->{statefile_value}->read(statefile => 'apache_' . $self->{option_results}->{hostname} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
my $old_total_access = $self->{statefile_value}->get(name => 'total_access');
my $old_total_bytes = $self->{statefile_value}->get(name => 'total_bytes');

View File

@ -25,7 +25,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Time::HiRes qw(gettimeofday tv_interval);
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -37,7 +37,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/server-status/?auto" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -45,8 +45,12 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"unknown-status:s" => { name => 'unknown_status', default => '' },
"warning-status:s" => { name => 'warning_status' },
"critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -63,19 +67,7 @@ sub check_options {
$self->{output}->option_exit();
}
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
@ -83,18 +75,19 @@ sub run {
my $timing0 = [gettimeofday];
my $webcontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
my $webcontent = $self->{http}->request();
my $timeelapsed = tv_interval ($timing0, [gettimeofday]);
my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Response time %fs ", $timeelapsed));
$self->{output}->perfdata_add(label => "time",
value => $timeelapsed,
short_msg => sprintf("Response time %.3fs", $timeelapsed));
$self->{output}->perfdata_add(label => "time", unit => 's',
value => sprintf('%.3f', $timeelapsed),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
$self->{output}->display();
$self->{output}->exit();
@ -146,6 +139,18 @@ Proxy URL if any
Threshold for HTTP timeout
=item B<--unknown-status>
Threshold warning for http response code
=item B<--warning-status>
Threshold warning for http response code
=item B<--critical-status>
Threshold critical for http response code (Default: '%{http_code} < 200 or %{http_code} >= 300')
=item B<--warning>
Threshold warning in seconds (server-status page response time)

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,7 +36,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/server-status/?auto" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -44,8 +44,9 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -61,26 +62,14 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my $ScoreBoard = "";
if ($webcontent =~ /^Scoreboard:\s+([^\s]+)/mi) {
$ScoreBoard = $1;

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,7 +36,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/server-status/?auto" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -44,8 +44,9 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -61,25 +62,13 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my ($BusyWorkers, $IdleWorkers, $ScoreBoard);
if ($webcontent =~ /^BusyWorkers:\s+([^\s]+)/mi) {
$BusyWorkers = $1;

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use centreon::plugins::statefile;
use JSON;
@ -38,18 +38,18 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '8086'},
"proto:s" => { name => 'proto', default => 'http' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/db" },
"database:s" => { name => 'database' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -65,10 +65,6 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
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}->{database})) {
$self->{output}->add_option_msg(short_msg => "Please set the database option");
$self->{output}->option_exit();
@ -77,14 +73,20 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= option");
$self->{output}->option_exit();
}
my $query = 'select sum("success") as "success_sum", sum("failure") as "failure_sum" from lmtpd.deliveries where time > '.$old_timestamp.'s and time < now()';
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."/".$self->{option_results}->{database}."/series";
$self->{option_results}->{get_param} = [];
push @{$self->{option_results}->{get_param}}, "q=" . $query, "p=" . $self->{option_results}->{password}, "u=" . $self->{option_results}->{username};
$self->{http}->set_options(%{$self->{option_results}});
$self->{statefile_value}->check_options(%options);
}
sub run {
my ($self, %options) = @_;
$self->{statefile_value}->read(statefile => 'bluemind_' . $self->{option_results}->{hostname} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
$self->{statefile_value}->read(statefile => 'bluemind_' . $self->{option_results}->{hostname} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
my $new_datas = {};
@ -98,14 +100,9 @@ sub run {
$self->{output}->exit();
}
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."/".$self->{option_results}->{database}."/series";
$self->{option_results}->{query} = 'select sum("success") as "success_sum", sum("failure") as "failure_sum" from lmtpd.deliveries where time > '.$old_timestamp.'s and time < now()';
my $query_form_get = { q => $self->{option_results}->{query}, p => $self->{option_results}->{password}, u => $self->{option_results}->{username} };
my $jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get);
my $jsoncontent = $self->{http}->request();
my $json = JSON->new;
my $webcontent;
eval {

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use JSON;
my $thresholds = {
@ -50,10 +50,11 @@ sub new {
"urlpath:s" => { name => 'url_path', default => "/api/status" },
"proxyurl:s" => { name => 'proxyurl' },
"uid:s" => { name => 'uid' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"threshold-overload:s@" => { name => 'threshold_overload' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -88,19 +89,19 @@ sub check_options {
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
}
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."/".$self->{option_results}->{uid};
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."/".$self->{option_results}->{uid};
my $jsoncontent = centreon::plugins::httplib::connect($self);
my $jsoncontent = $self->{http}->request();
my $json = JSON->new;
my $webcontent;
eval {
$webcontent = $json->decode($jsoncontent);
};
@ -214,7 +215,7 @@ ID for checkmyws API
=item B<--timeout>
Threshold for HTTP timeout (Default: '3')
Threshold for HTTP timeout (Default: 5)
=item B<--threshold-overload>

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use JSON;
my $thresholds = {
@ -45,15 +45,16 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '9200'},
"proto:s" => { name => 'proto', default => 'http' },
"urlpath:s" => { name => 'url_path', default => '/' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"threshold-overload:s@" => { name => 'threshold_overload' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -61,15 +62,6 @@ sub check_options {
my ($self, %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();
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
if ($val !~ /^(.*?),(.*?),(.*)$/) {
@ -84,6 +76,9 @@ sub check_options {
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
}
$self->{option_results}->{url_path} = $self->{option_results}->{url_path} . "_cluster/health/";
$self->{http}->set_options(%{$self->{option_results}});
}
sub get_severity {
@ -111,9 +106,7 @@ sub get_severity {
sub run {
my ($self, %options) = @_;
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."_cluster/health/";
my $jsoncontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
my $jsoncontent = $self->{http}->request();
my $json = JSON->new;
@ -199,7 +192,7 @@ Specify password for API authentification
=item B<--timeout>
Threshold for HTTP timeout (Default: 3)
Threshold for HTTP timeout (Default: 5)
=item B<--threshold-overload>

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use JSON;
use Data::Dumper;
@ -52,15 +52,16 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '9200'},
"proto:s" => { name => 'proto', default => 'http' },
"urlpath:s" => { name => 'url_path', default => '/' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"threshold-overload:s@" => { name => 'threshold_overload' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -68,15 +69,6 @@ sub check_options {
my ($self, %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();
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
if ($val !~ /^(.*?),(.*?),(.*)$/) {
@ -92,6 +84,9 @@ sub check_options {
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
}
$self->{option_results}->{url_path} = $self->{option_results}->{url_path} . "_cluster/health";
$self->{option_results}->{get_param} = ['level=indices'];
$self->{http}->set_options(%{$self->{option_results}});
}
sub get_severity {
@ -119,10 +114,7 @@ sub get_severity {
sub run {
my ($self, %options) = @_;
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."_cluster/health";
my $query_form_get = { level => 'indices' };
my $jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
my $jsoncontent = $self->{http}->request();
my $json = JSON->new;
my $webcontent;
@ -130,7 +122,6 @@ sub run {
eval {
$webcontent = $json->decode($jsoncontent);
};
if ($@) {
$self->{output}->add_option_msg(short_msg => "Cannot decode json response");
$self->{output}->option_exit();

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use JSON;
sub new {
@ -37,16 +37,17 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '9200'},
"proto:s" => { name => 'proto', default => 'http' },
"urlpath:s" => { name => 'url_path', default => '/' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -54,15 +55,6 @@ sub check_options {
my ($self, %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 (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
@ -71,17 +63,17 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
$self->{option_results}->{url_path} = $self->{option_results}->{url_path} . "_cluster/stats/";
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."_cluster/stats/";
my $jsoncontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
my $jsoncontent = $self->{http}->request();
my $json = JSON->new;
my $webcontent;
eval {
@ -173,7 +165,7 @@ Threshold critical.
=item B<--timeout>
Threshold for HTTP timeout (Default: 3)
Threshold for HTTP timeout (Default: 5)
=back

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use centreon::plugins::statefile;
use JSON;
use DateTime;
@ -45,9 +45,10 @@ sub new {
"password:s" => { name => 'password' },
"owner:s" => { name => 'owner' },
"repository:s" => { name => 'repository' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
return $self;
@ -57,14 +58,6 @@ sub check_options {
my ($self, %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}->{repository})) {
$self->{output}->add_option_msg(short_msg => "Please set the repository option");
$self->{output}->option_exit();
@ -74,13 +67,15 @@ sub check_options {
$self->{output}->option_exit();
}
$self->{option_results}->{url_path} = "/repos/" . $self->{option_results}->{owner} . "/" . $self->{option_results}->{repository}."/commits";
$self->{http}->set_options(%{$self->{option_results}});
$self->{statefile_value}->check_options(%options);
}
sub run {
my ($self, %options) = @_;
$self->{statefile_value}->read(statefile => 'github_' . $self->{option_results}->{repository} . '_' . $self->{option_results}->{owner} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
$self->{statefile_value}->read(statefile => 'github_' . $self->{option_results}->{repository} . '_' . $self->{option_results}->{owner} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
my $new_datas = {};
@ -97,15 +92,10 @@ sub run {
# Change date format from epoch to iso8601
my $old_iso8601 = DateTime->from_epoch(epoch => $old_timestamp)."Z";
$self->{option_results}->{url_path} = "/repos/".$self->{option_results}->{owner}."/".$self->{option_results}->{repository}."/commits";
my $query_form_get = { per_page => '1000', since => $old_iso8601 };
my $jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get , connection_exit => 'critical');
my $jsoncontent = $self->{http}->request(get_param => ['per_page=1000', 'since=' . $old_iso8601]);
my $json = JSON->new;
my $webcontent;
eval {
$webcontent = $json->decode($jsoncontent);
};
@ -127,7 +117,6 @@ sub run {
$self->{output}->display();
$self->{output}->exit();
}
1;
@ -174,7 +163,7 @@ Specify GitHub's repository
=item B<--timeout>
Threshold for HTTP timeout (Default: 3)
Threshold for HTTP timeout (Default: 5)
=back

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use JSON;
sub new {
@ -46,9 +46,10 @@ sub new {
"owner:s" => { name => 'owner' },
"repository:s" => { name => 'repository' },
"label:s" => { name => 'label', default => '' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -56,14 +57,6 @@ sub check_options {
my ($self, %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}->{repository})) {
$self->{output}->add_option_msg(short_msg => "Please set the repository option");
$self->{output}->option_exit();
@ -73,33 +66,30 @@ sub check_options {
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
$self->{option_results}->{url_path} = "/repos/" . $self->{option_results}->{owner} . "/" . $self->{option_results}->{repository} . "/issues";
if (defined($self->{option_results}->{label}) && $self->{option_results}->{label} ne '') {
$self->{option_results}->{get_param} = ['state=open', 'labels=' . $self->{option_results}->{label}, 'per_page=1000'];
} else {
$self->{option_results}->{get_param} = ['state=open', 'per_page=1000'];
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
$self->{option_results}->{url_path} = "/repos/".$self->{option_results}->{owner}."/".$self->{option_results}->{repository} . "/issues";
my $query_form_get;
if (defined($self->{option_results}->{label}) && $self->{option_results}->{label} ne '') {
$query_form_get = { state => 'open', labels => $self->{option_results}->{label}, per_page => '1000' };
} else {
$query_form_get = { state => 'open', per_page => '1000' };
}
my $jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get , connection_exit => 'critical');
my $jsoncontent = $self->{http}->request();
my $json = JSON->new;
my $webcontent;
eval {
$webcontent = $json->decode($jsoncontent);
};
@ -136,7 +126,6 @@ sub run {
$self->{output}->display();
$self->{output}->exit();
}
1;

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use JSON;
sub new {
@ -36,7 +36,7 @@ sub new {
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname', default => 'api.github.com' },
"port:s" => { name => 'port', default => '443'},
"port:s" => { name => 'port', default => '443' },
"proto:s" => { name => 'proto', default => 'https' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -45,9 +45,10 @@ sub new {
"critical:s" => { name => 'critical' },
"owner:s" => { name => 'owner' },
"repository:s" => { name => 'repository' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -55,14 +56,6 @@ sub check_options {
my ($self, %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}->{repository})) {
$self->{output}->add_option_msg(short_msg => "Please set the repository option");
$self->{output}->option_exit();
@ -79,21 +72,19 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
$self->{option_results}->{url_path} = "/repos/".$self->{option_results}->{owner}."/".$self->{option_results}->{repository}."/pulls";
$self->{option_results}->{get_param} = ['state=open', 'per_page=1000'];
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
$self->{option_results}->{url_path} = "/repos/".$self->{option_results}->{owner}."/".$self->{option_results}->{repository}."/pulls";
my $query_form_get = { state => 'open', per_page => '1000' };
my $jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get , connection_exit => 'critical');
my $jsoncontent = $self->{http}->request();
my $json = JSON->new;
my $webcontent;
eval {
$webcontent = $json->decode($jsoncontent);
};
@ -118,7 +109,6 @@ sub run {
);
$self->{output}->display();
$self->{output}->exit();
}
1;
@ -173,7 +163,7 @@ Specify GitHub's repository
=item B<--timeout>
Threshold for HTTP timeout (Default: 3)
Threshold for HTTP timeout (Default: 5)
=back

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use JSON;
my $thresholds = {
@ -50,10 +50,11 @@ sub new {
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"threshold-overload:s@" => { name => 'threshold_overload' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -61,15 +62,6 @@ sub check_options {
my ($self, %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();
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
if ($val !~ /^(.*?),(.*)$/) {
@ -84,6 +76,8 @@ sub check_options {
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub get_severity {
@ -110,12 +104,10 @@ sub get_severity {
sub run {
my ($self, %options) = @_;
my $jsoncontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
my $jsoncontent = $self->{http}->request();
my $json = JSON->new;
my $webcontent;
eval {
$webcontent = $json->decode($jsoncontent);
};
@ -132,7 +124,6 @@ sub run {
$self->{output}->display();
$self->{output}->exit();
}
1;
@ -175,7 +166,7 @@ Specify password
=item B<--timeout>
Threshold for HTTP timeout (Default: 3)
Threshold for HTTP timeout (Default: 5
=item B<--threshold-overload>

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use centreon::plugins::statefile;
use JSON;
@ -37,8 +37,8 @@ sub new {
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '80'},
"proto:s" => { name => 'proto', default => 'http' },
"port:s" => { name => 'port' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path' },
"jobname:s" => { name => 'jobname' },
"credentials" => { name => 'credentials' },
@ -47,9 +47,10 @@ sub new {
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"checkstyle" => { name => 'checkstyle' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -65,32 +66,23 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
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}->{jobname})) {
$self->{output}->add_option_msg(short_msg => "Please set the jobname 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();
}
$self->{option_results}->{url_path} = $self->{option_results}->{url_path} . "/job/" . $self->{option_results}->{jobname} . "/api/json";
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."/job/".$self->{option_results}->{jobname}."/api/json";
my $jsoncontent = centreon::plugins::httplib::connect($self);
my $jsoncontent = $self->{http}->request();
my $json = JSON->new;
my $webcontent;
eval {
$webcontent = $json->decode($jsoncontent);
};
@ -187,7 +179,7 @@ Add checkstyle's violation output and perfdata
=item B<--timeout>
Threshold for HTTP timeout (Default: 3)
Threshold for HTTP timeout (Default: 5)
=back

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use XML::XPath;
use Digest::SHA qw(hmac_sha256_base64);
@ -38,74 +38,49 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port' },
"proto:s" => { name => 'proto', default => "http" },
"urlpath:s" => { name => 'url_path', default => '/api/index.php?' },
"kayako-api-key:s" => { name => 'kayako_api_key' },
"kayako-secret-key:s" => { name => 'kayako_secret_key' },
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => '/api/index.php?' },
"kayako-api-key:s" => { name => 'kayako_api_key' },
"kayako-secret-key:s" => { name => 'kayako_secret_key' },
});
$self->set_signal_handlers;
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
sub set_signal_handlers {
my $self = shift;
$SIG{ALRM} = \&class_handle_ALRM;
$handlers{ALRM}->{$self} = sub { $self->handle_ALRM() };
}
sub class_handle_ALRM {
foreach (keys %{$handlers{ALRM}}) {
&{$handlers{ALRM}->{$_}}();
}
}
sub handle_ALRM {
my $self = shift;
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => sprintf("Cannot finished API execution (timeout received)"));
$self->{output}->display();
$self->{output}->exit();
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{timeout}) && $self->{option_results}->{timeout} =~ /^\d+$/ &&
$self->{option_results}->{timeout} > 0) {
alarm($self->{option_results}->{timeout});
}
if (!defined($self->{option_results}->{'kayako_api_key'})) {
if (!defined($self->{option_results}->{kayako_api_key})) {
$self->{output}->add_option_msg(short_msg => "Please specify an API key for Kayako.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{'kayako_secret_key'})) {
if (!defined($self->{option_results}->{kayako_secret_key})) {
$self->{output}->add_option_msg(short_msg => "Please specify a secret key for Kayako.");
$self->{output}->option_exit();
}
my $salt = '';
$salt .= int(rand(10)) for 1..10;
my $digest = hmac_sha256_base64($salt, $self->{option_results}->{kayako_secret_key});
$self->{option_results}->{url_path} .= "/Base/Department&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=";
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $salt;
$salt .= int(rand(10)) for 1..10;
my $digest = hmac_sha256_base64 ($salt, $self->{option_results}->{'kayako_secret_key'});
$self->{option_results}->{'url_path'} .= "/Base/Department&apikey=" . $self->{option_results}->{'kayako_api_key'} . "&salt=" . $salt . "&signature=" . $digest . "=";
my $webcontent = centreon::plugins::httplib::connect($self);
my $xp = XML::XPath->new( $webcontent );
my $nodes = $xp->find('departments/department');
my $webcontent = $self->{http}->set_options(%{$self->{option_results}});
my $xp = XML::XPath->new($webcontent);
my $nodes = $xp->find('departments/department');
foreach my $actionNode ($nodes->get_nodelist) {
my ($id) = $xp->find('./id', $actionNode)->get_nodelist;
my $trim_id = centreon::plugins::misc::trim($id->string_value);
my ($title) = $xp->find('./title', $actionNode)->get_nodelist;
my $trim_title = centreon::plugins::misc::trim($title->string_value);
foreach my $actionNode ($nodes->get_nodelist) {
my ($id) = $xp->find('./id', $actionNode)->get_nodelist;
my $trim_id = centreon::plugins::misc::trim($id->string_value);
my ($title) = $xp->find('./title', $actionNode)->get_nodelist;
my $trim_title = centreon::plugins::misc::trim($title->string_value);
# print $trim_id." : ". $trim_title."\n";
# }
$self->{output}->output_add(long_msg => "'" . $trim_title . "' [id = " . $trim_id . "]");
}

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use XML::XPath;
use Digest::SHA qw(hmac_sha256_base64);
@ -38,72 +38,49 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port' },
"proto:s" => { name => 'proto', default => "http" },
"urlpath:s" => { name => 'url_path', default => '/api/index.php?' },
"kayako-api-key:s" => { name => 'kayako_api_key' },
"kayako-secret-key:s" => { name => 'kayako_secret_key' },
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => '/api/index.php?' },
"kayako-api-key:s" => { name => 'kayako_api_key' },
"kayako-secret-key:s" => { name => 'kayako_secret_key' },
});
$self->set_signal_handlers;
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
sub set_signal_handlers {
my $self = shift;
$SIG{ALRM} = \&class_handle_ALRM;
$handlers{ALRM}->{$self} = sub { $self->handle_ALRM() };
}
sub class_handle_ALRM {
foreach (keys %{$handlers{ALRM}}) {
&{$handlers{ALRM}->{$_}}();
}
}
sub handle_ALRM {
my $self = shift;
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => sprintf("Cannot finished API execution (timeout received)"));
$self->{output}->display();
$self->{output}->exit();
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{timeout}) && $self->{option_results}->{timeout} =~ /^\d+$/ &&
$self->{option_results}->{timeout} > 0) {
alarm($self->{option_results}->{timeout});
}
if (!defined($self->{option_results}->{'kayako_api_key'})) {
if (!defined($self->{option_results}->{kayako_api_key})) {
$self->{output}->add_option_msg(short_msg => "Please specify an API key for Kayako.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{'kayako_secret_key'})) {
if (!defined($self->{option_results}->{kayako_secret_key})) {
$self->{output}->add_option_msg(short_msg => "Please specify a secret key for Kayako.");
$self->{output}->option_exit();
}
my $salt;
$salt .= int(rand(10)) for 1..10;
my $digest = hmac_sha256_base64 ($salt, $self->{option_results}->{kayako_secret_key});
$self->{option_results}->{url_path} .= "/Tickets/TicketPriority&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=";
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $salt;
$salt .= int(rand(10)) for 1..10;
my $digest = hmac_sha256_base64 ($salt, $self->{option_results}->{'kayako_secret_key'});
$self->{option_results}->{'url_path'} .= "/Tickets/TicketPriority&apikey=" . $self->{option_results}->{'kayako_api_key'} . "&salt=" . $salt . "&signature=" . $digest . "=";
my $webcontent = centreon::plugins::httplib::connect($self);
my $xp = XML::XPath->new( $webcontent );
my $nodes = $xp->find('ticketpriorities/ticketpriority');
my $webcontent = $self->{http}->request();
my $xp = XML::XPath->new( $webcontent );
my $nodes = $xp->find('ticketpriorities/ticketpriority');
foreach my $actionNode ($nodes->get_nodelist) {
my ($id) = $xp->find('./id', $actionNode)->get_nodelist;
my $trim_id = centreon::plugins::misc::trim($id->string_value);
my ($title) = $xp->find('./title', $actionNode)->get_nodelist;
my $trim_title = centreon::plugins::misc::trim($title->string_value);
foreach my $actionNode ($nodes->get_nodelist) {
my ($id) = $xp->find('./id', $actionNode)->get_nodelist;
my $trim_id = centreon::plugins::misc::trim($id->string_value);
my ($title) = $xp->find('./title', $actionNode)->get_nodelist;
my $trim_title = centreon::plugins::misc::trim($title->string_value);
$self->{output}->output_add(long_msg => "'" . $trim_title . "' [id = " . $trim_id . "]");
}

View File

@ -24,12 +24,10 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use XML::XPath;
use Digest::SHA qw(hmac_sha256_base64);
my %handlers = (ALRM => {} );
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -38,72 +36,50 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port' },
"proto:s" => { name => 'proto', default => "http" },
"urlpath:s" => { name => 'url_path', default => '/api/index.php?' },
"kayako-api-key:s" => { name => 'kayako_api_key' },
"kayako-secret-key:s" => { name => 'kayako_secret_key' },
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => '/api/index.php?' },
"kayako-api-key:s" => { name => 'kayako_api_key' },
"kayako-secret-key:s" => { name => 'kayako_secret_key' },
});
$self->set_signal_handlers;
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
sub set_signal_handlers {
my $self = shift;
$SIG{ALRM} = \&class_handle_ALRM;
$handlers{ALRM}->{$self} = sub { $self->handle_ALRM() };
}
sub class_handle_ALRM {
foreach (keys %{$handlers{ALRM}}) {
&{$handlers{ALRM}->{$_}}();
}
}
sub handle_ALRM {
my $self = shift;
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => sprintf("Cannot finished API execution (timeout received)"));
$self->{output}->display();
$self->{output}->exit();
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{timeout}) && $self->{option_results}->{timeout} =~ /^\d+$/ &&
$self->{option_results}->{timeout} > 0) {
alarm($self->{option_results}->{timeout});
}
if (!defined($self->{option_results}->{'kayako_api_key'})) {
if (!defined($self->{option_results}->{kayako_api_key})) {
$self->{output}->add_option_msg(short_msg => "Please specify an API key for Kayako.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{'kayako_secret_key'})) {
if (!defined($self->{option_results}->{kayako_secret_key})) {
$self->{output}->add_option_msg(short_msg => "Please specify a secret key for Kayako.");
$self->{output}->option_exit();
}
my $salt;
$salt .= int(rand(10)) for 1..10;
my $digest = hmac_sha256_base64 ($salt, $self->{option_results}->{'kayako_secret_key'});
$self->{option_results}->{url_path} .= "/Base/Staff&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=";
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $salt;
$salt .= int(rand(10)) for 1..10;
my $digest = hmac_sha256_base64 ($salt, $self->{option_results}->{'kayako_secret_key'});
$self->{option_results}->{'url_path'} .= "/Base/Staff&apikey=" . $self->{option_results}->{'kayako_api_key'} . "&salt=" . $salt . "&signature=" . $digest . "=";
my $webcontent = centreon::plugins::httplib::connect($self);
my $xp = XML::XPath->new( $webcontent );
my $nodes = $xp->find('staffusers/staff');
my $webcontent = $self->{http}->request();
my $xp = XML::XPath->new( $webcontent );
my $nodes = $xp->find('staffusers/staff');
foreach my $actionNode ($nodes->get_nodelist) {
my ($id) = $xp->find('./id', $actionNode)->get_nodelist;
my $trim_id = centreon::plugins::misc::trim($id->string_value);
my ($title) = $xp->find('./username', $actionNode)->get_nodelist;
my $trim_title = centreon::plugins::misc::trim($title->string_value);
foreach my $actionNode ($nodes->get_nodelist) {
my ($id) = $xp->find('./id', $actionNode)->get_nodelist;
my $trim_id = centreon::plugins::misc::trim($id->string_value);
my ($title) = $xp->find('./username', $actionNode)->get_nodelist;
my $trim_title = centreon::plugins::misc::trim($title->string_value);
$self->{output}->output_add(long_msg => "'" . $trim_title . "' [id = " . $trim_id . "]");
}

View File

@ -24,12 +24,10 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use XML::XPath;
use Digest::SHA qw(hmac_sha256_base64);
my %handlers = (ALRM => {} );
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -38,72 +36,50 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port' },
"proto:s" => { name => 'proto', default => "http" },
"urlpath:s" => { name => 'url_path', default => '/api/index.php?' },
"kayako-api-key:s" => { name => 'kayako_api_key' },
"kayako-secret-key:s" => { name => 'kayako_secret_key' },
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => '/api/index.php?' },
"kayako-api-key:s" => { name => 'kayako_api_key' },
"kayako-secret-key:s" => { name => 'kayako_secret_key' },
});
$self->set_signal_handlers;
return $self;
}
sub set_signal_handlers {
my $self = shift;
$SIG{ALRM} = \&class_handle_ALRM;
$handlers{ALRM}->{$self} = sub { $self->handle_ALRM() };
}
sub class_handle_ALRM {
foreach (keys %{$handlers{ALRM}}) {
&{$handlers{ALRM}->{$_}}();
}
}
sub handle_ALRM {
my $self = shift;
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => sprintf("Cannot finished scenario execution (timeout received)"));
$self->{output}->display();
$self->{output}->exit();
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{timeout}) && $self->{option_results}->{timeout} =~ /^\d+$/ &&
$self->{option_results}->{timeout} > 0) {
alarm($self->{option_results}->{timeout});
}
if (!defined($self->{option_results}->{'kayako_api_key'})) {
if (!defined($self->{option_results}->{kayako_api_key})) {
$self->{output}->add_option_msg(short_msg => "Please specify an API key for Kayako.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{'kayako_secret_key'})) {
if (!defined($self->{option_results}->{kayako_secret_key})) {
$self->{output}->add_option_msg(short_msg => "Please specify a secret key for Kayako.");
$self->{output}->option_exit();
}
my $salt;
$salt .= int(rand(10)) for 1..10;
my $digest = hmac_sha256_base64 ($salt, $self->{option_results}->{'kayako_secret_key'});
$self->{option_results}->{'url_path'} .= "/Tickets/TicketStatus&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=";
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $salt;
$salt .= int(rand(10)) for 1..10;
my $digest = hmac_sha256_base64 ($salt, $self->{option_results}->{'kayako_secret_key'});
$self->{option_results}->{'url_path'} .= "/Tickets/TicketStatus&apikey=" . $self->{option_results}->{'kayako_api_key'} . "&salt=" . $salt . "&signature=" . $digest . "=";
my $webcontent = centreon::plugins::httplib::connect($self);
my $xp = XML::XPath->new( $webcontent );
my $nodes = $xp->find('ticketstatuses/ticketstatus');
foreach my $actionNode ($nodes->get_nodelist) {
my ($id) = $xp->find('./id', $actionNode)->get_nodelist;
my $trim_id = centreon::plugins::misc::trim($id->string_value);
my ($title) = $xp->find('./title', $actionNode)->get_nodelist;
my $trim_title = centreon::plugins::misc::trim($title->string_value);
my $webcontent = $self->{http}->request();
my $xp = XML::XPath->new($webcontent);
my $nodes = $xp->find('ticketstatuses/ticketstatus');
foreach my $actionNode ($nodes->get_nodelist) {
my ($id) = $xp->find('./id', $actionNode)->get_nodelist;
my $trim_id = centreon::plugins::misc::trim($id->string_value);
my ($title) = $xp->find('./title', $actionNode)->get_nodelist;
my $trim_title = centreon::plugins::misc::trim($title->string_value);
$self->{output}->output_add(long_msg => "'" . $trim_title . "' [id = " . $trim_id . "]");
}

View File

@ -25,7 +25,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::statefile;
use centreon::plugins::httplib;
use centreon::plugins::http;
use XML::XPath;
use Digest::SHA qw(hmac_sha256_base64);
use Time::Local;
@ -38,7 +38,6 @@ my @priority_filters;
my $ticket_total = 0;
my %tickets;
my $label;
my %handlers = (ALRM => {} );
sub new {
my ($class, %options) = @_;
@ -50,7 +49,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port' },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => '/api/index.php?' },
"kayako-api-key:s" => { name => 'kayako_api_key' },
"kayako-secret-key:s" => { name => 'kayako_secret_key' },
@ -64,82 +63,56 @@ sub new {
"start-date:s" => { name => 'start_date' },
"end-date:s" => { name => 'end_date' },
});
$self->set_signal_handlers;
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
sub set_signal_handlers {
my $self = shift;
$SIG{ALRM} = \&class_handle_ALRM;
$handlers{ALRM}->{$self} = sub { $self->handle_ALRM() };
}
sub class_handle_ALRM {
foreach (keys %{$handlers{ALRM}}) {
&{$handlers{ALRM}->{$_}}();
}
}
sub handle_ALRM {
my $self = shift;
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => sprintf("Cannot finished API execution (timeout received)"));
$self->{output}->display();
$self->{output}->exit();
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{timeout}) && $self->{option_results}->{timeout} =~ /^\d+$/ &&
$self->{option_results}->{timeout} > 0) {
alarm($self->{option_results}->{timeout});
}
if (!defined($self->{option_results}->{'kayako_api_key'})) {
if (!defined($self->{option_results}->{kayako_api_key})) {
$self->{output}->add_option_msg(short_msg => "Please specify an API key for Kayako.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{'kayako_secret_key'})) {
if (!defined($self->{option_results}->{kayako_secret_key})) {
$self->{output}->add_option_msg(short_msg => "Please specify a secret key for Kayako.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{'department_id'})) {
if (!defined($self->{option_results}->{department_id})) {
$self->{output}->add_option_msg(short_msg => "Please specify at least one department ID.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{'staff_id'})) {
$self->{option_results}->{'staff_id'} = "-1";
if (!defined($self->{option_results}->{staff_id})) {
$self->{option_results}->{staff_id} = "-1";
}
if (!defined($self->{option_results}->{'status_id'})) {
$self->{option_results}->{'status_id'} = "-1";
if (!defined($self->{option_results}->{status_id})) {
$self->{option_results}->{status_id} = "-1";
}
if (defined($self->{option_results}->{'priority_id'})) {
@priority_filters = split(/,/, $self->{option_results}->{'priority_id'});
if (defined($self->{option_results}->{priority_id})) {
@priority_filters = split(/,/, $self->{option_results}->{priority_id});
}
if (defined($self->{option_results}->{'start_date'})) {
if ($self->{option_results}->{'start_date'} !~ m/^\d{1,2}-\d{1,2}-\d{4}$/){
if (defined($self->{option_results}->{start_date})) {
if ($self->{option_results}->{start_date} !~ m/^\d{1,2}-\d{1,2}-\d{4}$/){
$self->{output}->add_option_msg(short_msg => "Please specify a valid date (DD-MM-YYYY).");
$self->{output}->option_exit();
} else {
my ($mday,$mon,$year) = split(/-/, $self->{option_results}->{'start_date'});
$start = $self->{option_results}->{'start_date'};
$self->{option_results}->{'start_date'} = timelocal(0,0,0,$mday,$mon-1,$year);
my ($mday,$mon,$year) = split(/-/, $self->{option_results}->{start_date});
$start = $self->{option_results}->{start_date};
$self->{option_results}->{start_date} = timelocal(0,0,0,$mday,$mon-1,$year);
}
}
if (defined($self->{option_results}->{'end_date'})) {
if ($self->{option_results}->{'end_date'} !~ m/^\d{1,2}-\d{1,2}-\d{4}$/){
if (defined($self->{option_results}->{end_date})) {
if ($self->{option_results}->{end_date} !~ m/^\d{1,2}-\d{1,2}-\d{4}$/){
$self->{output}->add_option_msg(short_msg => "Please specify a valid date (DD-MM-YYYY).");
$self->{output}->option_exit();
} else {
my ($mday,$mon,$year) = split(/-/, $self->{option_results}->{'end_date'});
$end = $self->{option_results}->{'end_date'};
$self->{option_results}->{'end_date'} = timelocal(59,59,23,$mday,$mon-1,$year);
my ($mday,$mon,$year) = split(/-/, $self->{option_results}->{end_date});
$end = $self->{option_results}->{end_date};
$self->{option_results}->{end_date} = timelocal(59,59,23,$mday,$mon-1,$year);
}
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
@ -153,6 +126,9 @@ sub check_options {
$self->{statefile_cache}->check_options(%options);
$self->{statefile_value}->check_options(%options);
$self->{http}->set_options(%{$self->{option_results}});
}
sub reload_cache {
@ -161,12 +137,12 @@ sub reload_cache {
$datas->{last_timestamp} = time();
my $salt;
my $salt = '';
$salt .= int(rand(10)) for 1..10;
my $digest = hmac_sha256_base64 ($salt, $self->{option_results}->{'kayako_secret_key'});
$self->{option_results}->{'url_path'} = $url_original_path . "/Base/Department&apikey=" . $self->{option_results}->{'kayako_api_key'} . "&salt=" . $salt . "&signature=" . $digest . "=";
my $webcontent = centreon::plugins::httplib::connect($self);
my $xp = XML::XPath->new( $webcontent );
my $digest = hmac_sha256_base64 ($salt, $self->{option_results}->{kayako_secret_key});
my $webcontent = $self->{http}->request(url_path => $url_original_path . "/Base/Department&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=";);
my $xp = XML::XPath->new($webcontent);
my $nodes = $xp->find('departments/department');
foreach my $actionNode ($nodes->get_nodelist) {
my ($id) = $xp->find('./id', $actionNode)->get_nodelist;
@ -176,8 +152,7 @@ sub reload_cache {
$datas->{"department_".$trim_id} = $self->{output}->to_utf8($trim_title);
}
$self->{option_results}->{'url_path'} = $url_original_path . "/Tickets/TicketPriority&apikey=" . $self->{option_results}->{'kayako_api_key'} . "&salt=" . $salt . "&signature=" . $digest . "=";
$webcontent = centreon::plugins::httplib::connect($self);
$webcontent = $self->{http}->request(url_path => $url_original_path . "/Tickets/TicketPriority&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=");
$xp = XML::XPath->new( $webcontent );
$nodes = $xp->find('ticketpriorities/ticketpriority');
foreach my $actionNode ($nodes->get_nodelist) {
@ -188,8 +163,7 @@ sub reload_cache {
$datas->{"priority_".$trim_id} = $self->{output}->to_utf8($trim_title);
}
$self->{option_results}->{'url_path'} = $url_original_path . "/Base/Staff&apikey=" . $self->{option_results}->{'kayako_api_key'} . "&salt=" . $salt . "&signature=" . $digest . "=";
$webcontent = centreon::plugins::httplib::connect($self);
$webcontent = $self->{http}->request(url_path => $url_original_path . "/Base/Staff&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=");
$xp = XML::XPath->new( $webcontent );
$nodes = $xp->find('staffusers/staff');
foreach my $actionNode ($nodes->get_nodelist) {
@ -200,8 +174,7 @@ sub reload_cache {
$datas->{"staff_".$trim_id} = $self->{output}->to_utf8($trim_title);
}
$self->{option_results}->{'url_path'} = $url_original_path . "/Tickets/TicketStatus&apikey=" . $self->{option_results}->{'kayako_api_key'} . "&salt=" . $salt . "&signature=" . $digest . "=";
$webcontent = centreon::plugins::httplib::connect($self);
$webcontent = $self->{http}->request(url_path => $url_original_path . "/Tickets/TicketStatus&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=");
$xp = XML::XPath->new( $webcontent );
$nodes = $xp->find('ticketstatuses/ticketstatus');
foreach my $actionNode ($nodes->get_nodelist) {
@ -217,10 +190,10 @@ sub reload_cache {
sub run {
my ($self, %options) = @_;
my $salt;
my $salt = '';
$salt .= int(rand(10)) for 1..10;
my $digest = hmac_sha256_base64 ($salt, $self->{option_results}->{'kayako_secret_key'});
$url_original_path = $self->{option_results}->{'url_path'};
my $digest = hmac_sha256_base64($salt, $self->{option_results}->{kayako_secret_key});
$url_original_path = $self->{option_results}->{url_path};
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_api_' . ($self->{option_results}->{hostname}) . '_kayako');
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp');
@ -230,8 +203,7 @@ sub run {
$self->{statefile_cache}->read();
}
$self->{option_results}->{'url_path'} = $url_original_path . "/Tickets/Ticket/ListAll/" . $self->{option_results}->{'department_id'} . "/" . $self->{option_results}->{'status_id'} . "/" . $self->{option_results}->{'staff_id'} . "/-1/-1/1420120620/-1/-1&apikey=" . $self->{option_results}->{'kayako_api_key'} . "&salt=" . $salt . "&signature=" . $digest . "=";
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request(url_path => $url_original_path . "/Tickets/Ticket/ListAll/" . $self->{option_results}->{department_id} . "/" . $self->{option_results}->{status_id} . "/" . $self->{option_results}->{staff_id} . "/-1/-1/1420120620/-1/-1&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=");
my $xp = XML::XPath->new( $webcontent );
my $nodes = $xp->find('tickets/ticket');
@ -243,9 +215,9 @@ sub run {
my $trim_priorityid = centreon::plugins::misc::trim($priorityid->string_value);
my ($date) = $xp->find('./lastactivity', $actionNode)->get_nodelist;
my $trim_date = centreon::plugins::misc::trim($date->string_value);
if (defined($self->{option_results}->{'start_date'}) and (defined($self->{option_results}->{'end_date'}))) {
if ($trim_date > $self->{option_results}->{'start_date'} and $trim_date < $self->{option_results}->{'end_date'}) {
if (defined($self->{option_results}->{'priority_id'})){
if (defined($self->{option_results}->{start_date}) and (defined($self->{option_results}->{end_date}))) {
if ($trim_date > $self->{option_results}->{start_date} and $trim_date < $self->{option_results}->{end_date}) {
if (defined($self->{option_results}->{priority_id})){
foreach $priority_filter (@priority_filters) {
if ($priority_filter == $trim_priorityid){
$tickets{$priority_filter}++;
@ -256,9 +228,9 @@ sub run {
$ticket_total++;
}
}
} elsif (defined($self->{option_results}->{'start_date'}) and (!defined($self->{option_results}->{'end_date'}))) {
if ($trim_date > $self->{option_results}->{'start_date'}) {
if (defined($self->{option_results}->{'priority_id'})){
} elsif (defined($self->{option_results}->{start_date}) and (!defined($self->{option_results}->{end_date}))) {
if ($trim_date > $self->{option_results}->{start_date}) {
if (defined($self->{option_results}->{priority_id})){
foreach $priority_filter (@priority_filters) {
if ($priority_filter == $trim_priorityid){
$tickets{$priority_filter}++;
@ -269,9 +241,9 @@ sub run {
$ticket_total++;
}
}
} elsif (!defined($self->{option_results}->{'start_date'}) and (defined($self->{option_results}->{'end_date'}))) {
if ($trim_date < $self->{option_results}->{'end_date'}) {
if (defined($self->{option_results}->{'priority_id'})){
} elsif (!defined($self->{option_results}->{start_date}) and (defined($self->{option_results}->{end_date}))) {
if ($trim_date < $self->{option_results}->{end_date}) {
if (defined($self->{option_results}->{priority_id})){
foreach $priority_filter (@priority_filters) {
if ($priority_filter == $trim_priorityid){
$tickets{$priority_filter}++;
@ -283,7 +255,7 @@ sub run {
}
}
} else {
if (defined($self->{option_results}->{'priority_id'})){
if (defined($self->{option_results}->{priority_id})){
foreach $priority_filter (@priority_filters) {
if ($priority_filter == $trim_priorityid){
$tickets{$priority_filter}++;
@ -299,32 +271,32 @@ sub run {
###########
# Manage Output
###########
my $exit = $self->{perfdata}->threshold_check(value => $ticket_total, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $exit = $self->{perfdata}->threshold_check(value => $ticket_total, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $staff = "";
my $ticket_status = "";
my $period = "";
if (defined($self->{option_results}->{'staff_id'}) && ($self->{option_results}->{'staff_id'} =~ m/^\d*$/)) {
$staff = " for staff '" . $self->{statefile_cache}->get(name => 'staff_'.$self->{option_results}->{'staff_id'}) ."'";
if (defined($self->{option_results}->{staff_id}) && ($self->{option_results}->{staff_id} =~ m/^\d*$/)) {
$staff = " for staff '" . $self->{statefile_cache}->get(name => 'staff_'.$self->{option_results}->{staff_id}) ."'";
}
if (defined($self->{option_results}->{'status_id'}) && ($self->{option_results}->{'status_id'} =~ m/^\d*$/)) {
$ticket_status = " in status '" . $self->{statefile_cache}->get(name => 'status_'.$self->{option_results}->{'status_id'}) ."'";
if (defined($self->{option_results}->{status_id}) && ($self->{option_results}->{status_id} =~ m/^\d*$/)) {
$ticket_status = " in status '" . $self->{statefile_cache}->get(name => 'status_'.$self->{option_results}->{status_id}) ."'";
}
if (defined($self->{option_results}->{'start_date'}) || defined($self->{option_results}->{'end_date'})){
if (defined($self->{option_results}->{start_date}) || defined($self->{option_results}->{end_date})){
$period = " -";
}
if (defined($self->{option_results}->{'start_date'})){
if (defined($self->{option_results}->{start_date})){
$start = " Start: " . $start;
}
if (defined($self->{option_results}->{'end_date'})){
if (defined($self->{option_results}->{end_date})){
$end = " End: " . $end;
}
if (defined($self->{option_results}->{'priority_id'})){
if (defined($self->{option_results}->{priority_id})){
foreach $priority_filter (@priority_filters) {
$label = $self->{statefile_cache}->get(name => 'priority_'.$priority_filter);
$self->{output}->perfdata_add(label => $label, value => $tickets{$priority_filter},

View File

@ -45,16 +45,11 @@ sub run {
$self->{sql}->connect();
if (!($self->{sql}->is_version_minimum(version => '5'))) {
$self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x').");
$self->{output}->option_exit();
}
$self->{sql}->query(query => "SELECT departmentid, title FROM swdepartments");
while ((my $row = $self->{sql}->fetchrow_hashref())) {
$self->{output}->output_add(long_msg => "'" . $row->{title} . "' [id = " . $row->{departmentid} . "]");
$self->{output}->output_add(long_msg => "'" . $row->{title} . "' [id = " . $row->{departmentid} . "]");
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List departments:');
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);

View File

@ -45,16 +45,11 @@ sub run {
$self->{sql}->connect();
if (!($self->{sql}->is_version_minimum(version => '5'))) {
$self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x').");
$self->{output}->option_exit();
}
$self->{sql}->query(query => "SELECT priorityid, title FROM swticketpriorities");
while ((my $row = $self->{sql}->fetchrow_hashref())) {
$self->{output}->output_add(long_msg => "'" . $row->{title} . "' [id = " . $row->{priorityid} . "]");
$self->{output}->output_add(long_msg => "'" . $row->{title} . "' [id = " . $row->{priorityid} . "]");
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List priorities:');
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);

View File

@ -45,16 +45,11 @@ sub run {
$self->{sql}->connect();
if (!($self->{sql}->is_version_minimum(version => '5'))) {
$self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x').");
$self->{output}->option_exit();
}
$self->{sql}->query(query => "SELECT staffid, username FROM swstaff");
while ((my $row = $self->{sql}->fetchrow_hashref())) {
$self->{output}->output_add(long_msg => "'" . $row->{username} . "' [id = " . $row->{staffid} . "]");
$self->{output}->output_add(long_msg => "'" . $row->{username} . "' [id = " . $row->{staffid} . "]");
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List staff:');
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);

View File

@ -45,16 +45,11 @@ sub run {
$self->{sql}->connect();
if (!($self->{sql}->is_version_minimum(version => '5'))) {
$self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x').");
$self->{output}->option_exit();
}
$self->{sql}->query(query => "SELECT ticketstatusid, title FROM swticketstatus");
while ((my $row = $self->{sql}->fetchrow_hashref())) {
$self->{output}->output_add(long_msg => "'" . $row->{title} . "' [id = " . $row->{ticketstatusid} . "]");
$self->{output}->output_add(long_msg => "'" . $row->{title} . "' [id = " . $row->{ticketstatusid} . "]");
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List status:');
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);

View File

@ -30,7 +30,6 @@ use Time::Local;
my $ticket_total = 0;
my %tickets;
my $label;
my %handlers = (ALRM => {} );
my $start = "";
my $end = "";
my $priority_filter;
@ -44,15 +43,15 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
"department-id:s" => { name => 'department_id' },
"staff-id:s" => { name => 'staff_id' },
"status-id:s" => { name => 'status_id' },
"priority-id:s" => { name => 'priority_id' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"start-date:s" => { name => 'start_date' },
"end-date:s" => { name => 'end_date' },
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
"department-id:s" => { name => 'department_id' },
"staff-id:s" => { name => 'staff_id' },
"status-id:s" => { name => 'status_id' },
"priority-id:s" => { name => 'priority_id' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"start-date:s" => { name => 'start_date' },
"end-date:s" => { name => 'end_date' },
});
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
@ -63,36 +62,36 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{'start_date'})) {
if ($self->{option_results}->{'start_date'} !~ m/^\d{1,2}-\d{1,2}-\d{4}$/){
$self->{output}->add_option_msg(short_msg => "Please specify a valid date (DD-MM-YYYY).");
$self->{output}->option_exit();
} else {
my ($mday,$mon,$year) = split(/-/, $self->{option_results}->{'start_date'});
$start = $self->{option_results}->{'start_date'};
$self->{option_results}->{'start_date'} = timelocal(0,0,0,$mday,$mon-1,$year);
}
}
if (defined($self->{option_results}->{'end_date'})) {
if ($self->{option_results}->{'end_date'} !~ m/^\d{1,2}-\d{1,2}-\d{4}$/){
if (defined($self->{option_results}->{start_date})) {
if ($self->{option_results}->{start_date} !~ m/^\d{1,2}-\d{1,2}-\d{4}$/){
$self->{output}->add_option_msg(short_msg => "Please specify a valid date (DD-MM-YYYY).");
$self->{output}->option_exit();
} else {
my ($mday,$mon,$year) = split(/-/, $self->{option_results}->{'start_date'});
$start = $self->{option_results}->{start_date};
$self->{option_results}->{start_date} = timelocal(0,0,0,$mday,$mon-1,$year);
}
}
if (defined($self->{option_results}->{end_date})) {
if ($self->{option_results}->{end_date} !~ m/^\d{1,2}-\d{1,2}-\d{4}$/){
$self->{output}->add_option_msg(short_msg => "Please specify a valid date (DD-MM-YYYY).");
$self->{output}->option_exit();
} else {
my ($mday,$mon,$year) = split(/-/, $self->{option_results}->{'end_date'});
$end = $self->{option_results}->{'end_date'};
$self->{option_results}->{'end_date'} = timelocal(59,59,23,$mday,$mon-1,$year);
my ($mday,$mon,$year) = split(/-/, $self->{option_results}->{end_date});
$end = $self->{option_results}->{end_date};
$self->{option_results}->{end_date} = timelocal(59,59,23,$mday,$mon-1,$year);
}
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
if (defined($self->{option_results}->{'priority_id'})) {
@priority_filters = split(/,/, $self->{option_results}->{'priority_id'});
if (defined($self->{option_results}->{priority_id})) {
@priority_filters = split(/,/, $self->{option_results}->{priority_id});
}
$self->{statefile_cache}->check_options(%options);
@ -132,22 +131,16 @@ sub run {
$self->{sql} = $options{sql};
$self->{sql}->connect();
if (!($self->{sql}->is_version_minimum(version => '5'))) {
$self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x').");
$self->{output}->option_exit();
}
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_sql_' . $self->{sql}->get_unique_id4save() . '_kayako');
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp');
if ($has_cache_file == 0 ||
!defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60))) {
$self->reload_cache();
$self->{statefile_cache}->read();
$self->reload_cache();
$self->{statefile_cache}->read();
}
my $query = "SELECT priorityid FROM swtickets WHERE ticketid IS NOT NULL";
if (defined($self->{option_results}->{'department_id'})) {
$query .= " AND departmentid IN (" . $self->{option_results}->{'department_id'} . ")";
}
@ -170,59 +163,60 @@ sub run {
$self->{sql}->query(query => $query);
while ((my $row = $self->{sql}->fetchrow_hashref())) {
if (defined($self->{option_results}->{'priority_id'})){
if (defined($self->{option_results}->{priority_id})) {
foreach $priority_filter (@priority_filters) {
if ($priority_filter == $row->{priorityid}){
if ($priority_filter == $row->{priorityid}) {
$tickets{$priority_filter}++;
$ticket_total++;
}
}
} else {
$ticket_total++;
}
}
}
###########
# Manage Output
###########
my $exit = $self->{perfdata}->threshold_check(value => $ticket_total, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $staff = "";
my $ticket_status = "";
my $period = "";
if (defined($self->{option_results}->{'staff_id'}) && ($self->{option_results}->{'staff_id'} =~ m/^\d*$/)) {
###########
# Manage Output
###########
my $exit = $self->{perfdata}->threshold_check(value => $ticket_total, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $staff = "";
my $ticket_status = "";
my $period = "";
if (defined($self->{option_results}->{staff_id}) && ($self->{option_results}->{staff_id} =~ m/^\d*$/)) {
$staff = " for staff '" . $self->{statefile_cache}->get(name => 'staff_'.$self->{option_results}->{'staff_id'}) ."'";
}
if (defined($self->{option_results}->{'status_id'}) && ($self->{option_results}->{'status_id'} =~ m/^\d*$/)) {
if (defined($self->{option_results}->{status_id}) && ($self->{option_results}->{status_id} =~ m/^\d*$/)) {
$ticket_status = " in status '" . $self->{statefile_cache}->get(name => 'status_'.$self->{option_results}->{'status_id'}) ."'";
}
if (defined($self->{option_results}->{'start_date'}) || defined($self->{option_results}->{'end_date'})){
if (defined($self->{option_results}->{start_date}) || defined($self->{option_results}->{end_date})){
$period = " -";
}
if (defined($self->{option_results}->{'start_date'})){
$start = " Start: " . $start;
if (defined($self->{option_results}->{start_date})){
$start = " Start: " . $start;
}
if (defined($self->{option_results}->{'end_date'})){
$end = " End: " . $end;
}
if (defined($self->{option_results}->{end_date})){
$end = " End: " . $end;
}
if (defined($self->{option_results}->{'priority_id'})){
foreach $priority_filter (@priority_filters) {
$label = $self->{statefile_cache}->get(name => 'priority_'.$priority_filter);
$self->{output}->perfdata_add(label => $label, value => $tickets{$priority_filter},
min => 0, max => $ticket_total);
}
}
$self->{output}->perfdata_add(label => 'Total', value => $ticket_total,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
if (defined($self->{option_results}->{priority_id})) {
foreach $priority_filter (@priority_filters) {
$label = $self->{statefile_cache}->get(name => 'priority_' . $priority_filter);
$self->{output}->perfdata_add(label => $label, value => $tickets{$priority_filter},
min => 0, max => $ticket_total);
}
}
$self->{output}->perfdata_add(label => 'Total', value => $ticket_total,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("%s tickets%s%s%s%s%s", $ticket_total, $staff, $ticket_status, $period, $start, $end));
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("%s tickets%s%s%s%s%s", $ticket_total, $staff, $ticket_status, $period, $start, $end));
$self->{output}->display();
$self->{output}->exit();

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
my $maps = [
{ counter => 'active', output => 'Active connections %d', match => 'Active connections:\s*(\d+)' },
@ -43,13 +43,13 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/nginx_status" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
foreach (@{$maps}) {
$options{options}->add_options(arguments => {
@ -57,6 +57,8 @@ sub new {
'critical-' . $_->{counter} . ':s' => { name => 'critical_' . $_->{counter} },
});
}
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -74,25 +76,14 @@ sub check_options {
$self->{output}->option_exit();
}
}
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
foreach (@{$maps}) {
if ($webcontent !~ /$_->{match}/msi) {
$self->{output}->output_add(severity => 'UNKNOWN',

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use centreon::plugins::statefile;
my $maps = [
@ -43,13 +43,13 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/nginx_status" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
foreach (@{$maps}) {
$options{options}->add_options(arguments => {
@ -58,6 +58,7 @@ sub new {
});
}
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -75,27 +76,20 @@ sub check_options {
$self->{output}->option_exit();
}
}
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();
}
$self->{statefile_value}->check_options(%options);
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my ($buffer_creation, $exit) = (0, 0);
my $new_datas = {};
my $old_datas = {};
$self->{statefile_value}->read(statefile => 'nginx_' . $self->{option_results}->{hostname} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
$self->{statefile_value}->read(statefile => 'nginx_' . $self->{option_results}->{hostname} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
$old_datas->{timestamp} = $self->{statefile_value}->get(name => 'timestamp');
$new_datas->{timestamp} = time();
foreach (@{$maps}) {

View File

@ -25,7 +25,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Time::HiRes qw(gettimeofday tv_interval);
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -37,7 +37,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/nginx_status" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -45,8 +45,12 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"unknown-status:s" => { name => 'unknown_status', default => '' },
"warning-status:s" => { name => 'warning_status' },
"critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -63,19 +67,7 @@ sub check_options {
$self->{output}->option_exit();
}
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
@ -83,12 +75,12 @@ sub run {
my $timing0 = [gettimeofday];
my $webcontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
my $webcontent = $self->{http}->request();
my $timeelapsed = tv_interval ($timing0, [gettimeofday]);
my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Response time %fs ", $timeelapsed));
$self->{output}->perfdata_add(label => "time",
@ -146,6 +138,18 @@ Proxy URL if any
Threshold for HTTP timeout
=item B<--unknown-status>
Threshold warning for http response code
=item B<--warning-status>
Threshold warning for http response code
=item B<--critical-status>
Threshold critical for http response code (Default: '%{http_code} < 200 or %{http_code} >= 300')
=item B<--warning>
Threshold warning in seconds (nginx_status page response time)

View File

@ -18,15 +18,14 @@
# limitations under the License.
#
package apps::apc::web::mode::filecache;
package apps::php::apc::web::mode::filecache;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
use centreon::plugins::values;
my $maps_counters = {
@ -216,7 +215,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/apc.php" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -225,6 +224,7 @@ sub new {
"timeout:s" => { name => 'timeout', default => 30 },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
foreach (keys %{$maps_counters}) {
@ -246,30 +246,22 @@ sub check_options {
my ($self, %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();
}
foreach (keys %{$maps_counters}) {
$maps_counters->{$_}->{obj}->init(option_results => $self->{option_results});
}
$self->{http}->set_options(%{$self->{option_results}});
$self->{statefile_value}->check_options(%options);
}
sub run {
my ($self, %options) = @_;
$self->{webcontent} = centreon::plugins::httplib::connect($self);
$self->{webcontent} = $self->{http}->request();
$self->manage_selection();
$self->{new_datas} = {};
$self->{statefile_value}->read(statefile => "apc_" . $self->{option_results}->{hostname} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode});
$self->{statefile_value}->read(statefile => "apc_" . $self->{option_results}->{hostname} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
$self->{new_datas}->{last_timestamp} = time();
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');

View File

@ -18,13 +18,13 @@
# limitations under the License.
#
package apps::apc::web::mode::memory;
package apps::php::apc::web::mode::memory;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use centreon::plugins::values;
my $maps_counters = {
@ -92,7 +92,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/apc.php" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -100,7 +100,9 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => 30 },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
foreach (keys %{$maps_counters}) {
$options{options}->add_options(arguments => {
'warning-' . $_ . ':s' => { name => 'warning-' . $_ },
@ -118,24 +120,17 @@ sub new {
sub check_options {
my ($self, %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();
}
foreach (keys %{$maps_counters}) {
$maps_counters->{$_}->{obj}->init(option_results => $self->{option_results});
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
$self->{webcontent} = centreon::plugins::httplib::connect($self);
$self->{webcontent} = $self->{http}->request();
$self->manage_selection();

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package apps::apc::web::plugin;
package apps::php::apc::web::plugin;
use strict;
use warnings;
@ -32,8 +32,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'file-cache' => 'apps::apc::web::mode::filecache',
'memory' => 'apps::apc::web::mode::memory',
'file-cache' => 'apps::php::apc::web::mode::filecache',
'memory' => 'apps::php::apc::web::mode::memory',
);
return $self;

View File

@ -0,0 +1,308 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::php::fpm::web::mode::usage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::http;
use centreon::plugins::values;
use centreon::plugins::statefile;
my $maps_counters = {
fpm => {
'000_active-processes' => { set => {
key_values => [ { name => 'active' }, { name => 'total' } ],
closure_custom_calc => \&custom_active_calc,
closure_custom_output => \&custom_active_output,
threshold_use => 'active_prct',
closure_custom_perfdata => => \&custom_active_perfdata,
}
},
'001_idle-processes' => { set => {
key_values => [ { name => 'idle' }, { name => 'total' } ],
closure_custom_calc => \&custom_idle_calc,
closure_custom_output => \&custom_idle_output,
threshold_use => 'idle_prct',
closure_custom_perfdata => => \&custom_idle_perfdata,
}
},
'002_listen-queue' => { set => {
key_values => [ { name => 'listen_queue' }, { name => 'max_listen_queue' } ],
output_template => 'Listen queue : %s',
output_use => 'listen_queue_absolute', threshold_use => 'listen_queue_absolute',
perfdatas => [
{ label => 'listen_queue', template => '%s', value => 'listen_queue_absolute',
min => 0, max => 'max_listen_queue_absolute' },
],
}
},
'003_requests' => { set => {
key_values => [ { name => 'request', diff => 1 } ],
per_second => 1,
output_template => 'Requests : %.2f/s',
perfdatas => [
{ label => 'requests', template => '%.2f', value => 'request_per_second',
unit => '/s', min => 0 },
],
}
},
},
};
sub custom_active_calc {
my ($self, %options) = @_;
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{active} = $options{new_datas}->{$self->{instance} . '_active'};
$self->{result_values}->{active_prct} = $self->{result_values}->{active} * 100 / $self->{result_values}->{total};
return 0;
}
sub custom_active_output {
my ($self, %options) = @_;
return sprintf("Active processes: %s (%.2f%%)",
$self->{result_values}->{active},
$self->{result_values}->{active_prct});
}
sub custom_active_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(label => 'active',
value => $self->{result_values}->{active},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
min => 0, max => $self->{result_values}->{total});
}
sub custom_idle_calc {
my ($self, %options) = @_;
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{idle} = $options{new_datas}->{$self->{instance} . '_idle'};
$self->{result_values}->{idle_prct} = $self->{result_values}->{idle} * 100 / $self->{result_values}->{total};
return 0;
}
sub custom_idle_output {
my ($self, %options) = @_;
return sprintf("Idle processes: %s (%.2f%%)",
$self->{result_values}->{idle},
$self->{result_values}->{idle_prct});
}
sub custom_idle_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(label => 'idle',
value => $self->{result_values}->{idle},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
min => 0, max => $self->{result_values}->{total});
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/fpm-status" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => 5 },
});
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
$self->{http} = centreon::plugins::http->new(output => $self->{output});
foreach my $key (('fpm')) {
foreach (keys %{$maps_counters->{$key}}) {
my ($id, $name) = split /_/;
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
$options{options}->add_options(arguments => {
'warning-' . $name . ':s' => { name => 'warning-' . $name },
'critical-' . $name . ':s' => { name => 'critical-' . $name },
});
}
$maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(statefile => $self->{statefile_value},
output => $self->{output}, perfdata => $self->{perfdata},
label => $name);
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
}
}
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
foreach my $key (('fpm')) {
foreach (keys %{$maps_counters->{$key}}) {
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
}
}
$self->{statefile_value}->check_options(%options);
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
$self->{webcontent} = $self->{http}->request();
$self->manage_selection();
$self->{new_datas} = {};
$self->{statefile_value}->read(statefile => "php_fpm_" . $self->{option_results}->{hostname} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
$self->{new_datas}->{last_timestamp} = time();
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits;
foreach (sort keys %{$maps_counters->{fpm}}) {
my $obj = $maps_counters->{fpm}->{$_}->{obj};
$obj->set(instance => 'fpm');
my ($value_check) = $obj->execute(values => $self->{fpm},
new_datas => $self->{new_datas});
if ($value_check != 0) {
$long_msg .= $long_msg_append . $obj->output_error();
$long_msg_append = ', ';
next;
}
my $exit2 = $obj->threshold_check();
push @exits, $exit2;
my $output = $obj->output();
$long_msg .= $long_msg_append . $output;
$long_msg_append = ', ';
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
$short_msg .= $short_msg_append . $output;
$short_msg_append = ', ';
}
$obj->perfdata();
}
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
$self->{output}->output_add(severity => $exit,
short_msg => "php-fpm $short_msg"
);
} else {
$self->{output}->output_add(short_msg => "php-fpm $long_msg");
}
$self->{statefile_value}->write(data => $self->{new_datas});
$self->{output}->display();
$self->{output}->exit();
}
sub manage_selection {
my ($self, %options) = @_;
$self->{fpm} = { request => undef, listen_queue => undef, max_listen_queue => undef,
idle => undef, active => undef, total => undef };
$self->{fpm}->{request} = $1 if ($self->{webcontent} =~ /accepted\s+conn:\s+(\d+)/msi);
$self->{fpm}->{listen_queue} = $1 if ($self->{webcontent} =~ /listen\s+queue:\s+(\d+)/msi);
$self->{fpm}->{max_listen_queue} = $1 if ($self->{webcontent} =~ /max\s+listen\s+queue:\s+(\d+)/msi);
$self->{fpm}->{idle} = $1 if ($self->{webcontent} =~ /idle\s+processes:\s+(\d+)/msi);
$self->{fpm}->{active} = $1 if ($self->{webcontent} =~ /active\s+processes:\s+(\d+)/msi);
$self->{fpm}->{total} = $1 if ($self->{webcontent} =~ /total\s+processes:\s+(\d+)/msi);
}
1;
__END__
=head1 MODE
Check php-fpm usage.
=over 8
=item B<--hostname>
IP Addr/FQDN of the webserver host
=item B<--port>
Port used by web server
=item B<--proxyurl>
Proxy URL if any
=item B<--proto>
Specify https if needed
=item B<--urlpath>
Set path to get server-status page in auto mode (Default: '/fpm-status')
=item B<--credentials>
Specify this option if you access server-status page over basic authentification
=item B<--username>
Specify username for basic authentification (Mandatory if --credentials is specidied)
=item B<--password>
Specify password for basic authentification (Mandatory if --credentials is specidied)
=item B<--timeout>
Threshold for HTTP timeout (Default: 5)
=item B<--warning-*>
Threshold warning.
Can be: 'active-processes' (%), 'idle-processes' (%),
'listen-queue', 'requests'.
=item B<--critical-*>
Threshold critical.
Can be: 'active-processes' (%), 'idle-processes' (%),
'listen-queue', 'requests'.
=back
=cut

View File

@ -0,0 +1,49 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::php::fpm::web::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_simple);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
# $options->{options} = options object
$self->{version} = '0.1';
%{$self->{modes}} = (
'usage' => 'apps::php::fpm::web::mode::usage',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check php-fpm module through the webpage.
=cut

View File

@ -24,7 +24,8 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use Time::HiRes qw(gettimeofday tv_interval);
sub new {
my ($class, %options) = @_;
@ -35,23 +36,38 @@ sub new {
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"http-peer-addr:s" => { name => 'http_peer_addr' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"urlpath:s" => { name => 'url_path', default => "/" },
"method:s" => { name => 'method' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path' },
"credentials" => { name => 'credentials' },
"ntlm" => { name => 'ntlm' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"expected-string:s" => { name => 'expected_string' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"no-follow" => { name => 'no_follow', },
"ssl:s" => { name => 'ssl', },
"cert-file:s" => { name => 'cert_file' },
"key-file:s" => { name => 'key_file' },
"cacert-file:s" => { name => 'cacert_file' },
"cert-pwd:s" => { name => 'cert_pwd' },
"cert-pkcs12" => { name => 'cert_pkcs12' },
"header:s@" => { name => 'header' },
"get-param:s@" => { name => 'get_param' },
"post-param:s@" => { name => 'post_param' },
"cookies-file:s" => { name => 'cookies_file' },
"unknown-status:s" => { name => 'unknown_status' },
"warning-status:s" => { name => 'warning_status' },
"critical-status:s" => { name => 'critical_status' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"warning-size:s" => { name => 'warning_size' },
"critical-size:s" => { name => 'critical_size' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -59,36 +75,36 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{hostname})) {
$self->{output}->add_option_msg(short_msg => "You need to specify hostname.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{expected_string})) {
$self->{output}->add_option_msg(short_msg => "You need to specify --expected-string 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");
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if ((!defined($self->{option_results}->{credentials})) && (defined($self->{option_results}->{ntlm}))) {
$self->{output}->add_option_msg(short_msg => "--ntlm option must be used with --credentials option");
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
if ((defined($self->{option_results}->{pkcs12})) && (!defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pwd}))) {
$self->{output}->add_option_msg(short_msg => "You need to set --cert-file= and --cert-pwd= options when --pkcs12 is used");
if (($self->{perfdata}->threshold_validate(label => 'warning-size', value => $self->{option_results}->{warning_size})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning-size threshold '" . $self->{option_results}->{warning_size} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical-size', value => $self->{option_results}->{critical_size})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical-size threshold '" . $self->{option_results}->{critical_size} . "'.");
$self->{output}->option_exit();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{port})) {
$self->{option_results}->{port} = centreon::plugins::httplib::get_port($self);
}
my $webcontent = centreon::plugins::httplib::connect($self);
my $timing0 = [gettimeofday];
my $webcontent = $self->{http}->request();
my $timeelapsed = tv_interval($timing0, [gettimeofday]);
$self->{output}->output_add(long_msg => $webcontent);
if ($webcontent =~ /$self->{option_results}->{expected_string}/mi) {
@ -98,6 +114,37 @@ sub run {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("'%s' is not present in content.", $self->{option_results}->{expected_string}));
}
# Time check
my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed,
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Response time : %.3fs", $timeelapsed));
}
$self->{output}->perfdata_add(label => "time", unit => 's',
value => sprintf('%.3f', $timeelapsed),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
# Size check
{
require bytes;
my $content_size = bytes::length($webcontent);
$exit = $self->{perfdata}->threshold_check(value => $content_size,
threshold => [ { label => 'critical-size', exit_litteral => 'critical' }, { label => 'warning-size', exit_litteral => 'warning' } ]);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Content size : %s", $content_size));
}
$self->{output}->perfdata_add(label => "size", unit => 'B',
value => $content_size,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-size'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-size'),
min => 0);
}
$self->{output}->display();
$self->{output}->exit();
}
@ -116,6 +163,10 @@ Check Webpage content
IP Addr/FQDN of the Webserver host
=item B<--http-peer-addr>
Set the address you want to connect (Useful if hostname is only a vhost. no ip resolve)
=item B<--port>
Port used by Webserver
@ -124,9 +175,13 @@ Port used by Webserver
Proxy URL if any
=item B<--method>
Specify http method used (Default: 'GET')
=item B<--proto>
Specify https if needed
Specify https if needed (Default: 'http')
=item B<--urlpath>
@ -150,7 +205,11 @@ Specify password for basic authentification (Mandatory if --credentials is speci
=item B<--timeout>
Threshold for HTTP timeout
Threshold for HTTP timeout (Default: 5)
=item B<--no-follow>
Do not follow http redirect
=item B<--ssl>
@ -176,6 +235,50 @@ Specify certificate's password
Specify type of certificate (PKCS12)
=item B<--header>
Set HTTP headers (Multiple option)
=item B<--get-param>
Set GET params (Multiple option. Example: --get-param='key=value')
=item B<--post-param>
Set POST params (Multiple option. Example: --post-param='key=value')
=item B<--cookies-file>
Save cookies in a file (Example: '/tmp/lwp_cookies.dat')
=item B<--unknown-status>
Threshold warning for http response code (Default: '%{http_code} < 200 or %{http_code} >= 300')
=item B<--warning-status>
Threshold warning for http response code
=item B<--critical-status>
Threshold critical for http response code
=item B<--warning>
Threshold warning in seconds (Webpage response time)
=item B<--critical>
Threshold critical in seconds (Webpage response time)
=item B<--warning-size>
Threshold warning for content size
=item B<--critical-size>
Threshold critical for content size
=item B<--expected-string>
Specify String to check on the Webpage

View File

@ -25,7 +25,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Time::HiRes qw(gettimeofday tv_interval);
use centreon::plugins::httplib;
use centreon::plugins::http;
use JSON::Path;
use JSON;
@ -40,9 +40,11 @@ sub new {
"data:s" => { name => 'data' },
"lookup:s@" => { name => 'lookup' },
"hostname:s" => { name => 'hostname' },
"http-peer-addr:s" => { name => 'http_peer_addr' },
"vhost:s" => { name => 'vhost' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"urlpath:s" => { name => 'url_path', default => "/" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path' },
"credentials" => { name => 'credentials' },
"ntlm" => { name => 'ntlm' },
"username:s" => { name => 'username' },
@ -57,6 +59,9 @@ sub new {
"cacert-file:s" => { name => 'cacert_file' },
"cert-pwd:s" => { name => 'cert_pwd' },
"cert-pkcs12" => { name => 'cert_pkcs12' },
"unknown-status:s" => { name => 'unknown_status' },
"warning-status:s" => { name => 'warning_status' },
"critical-status:s" => { name => 'critical_status' },
"warning-numeric:s" => { name => 'warning_numeric' },
"critical-numeric:s" => { name => 'critical_numeric' },
@ -80,6 +85,7 @@ sub new {
$self->{values_string_ok} = [];
$self->{values_string_warning} = [];
$self->{values_string_critical} = [];
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -106,47 +112,8 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical-time threshold '" . $self->{option_results}->{critical_time} . "'.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{hostname})) {
$self->{output}->add_option_msg(short_msg => "You need to specify hostname.");
$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}->{credentials})) && (defined($self->{option_results}->{ntlm}))) {
$self->{output}->add_option_msg(short_msg => "--ntlm option must be used with --credentials option");
$self->{output}->option_exit();
}
if ((defined($self->{option_results}->{pkcs12})) && (!defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pwd}))) {
$self->{output}->add_option_msg(short_msg => "You need to set --cert-file= and --cert-pwd= options when --pkcs12 is used");
$self->{output}->option_exit();
}
$self->{headers} = {};
if (defined($self->{option_results}->{header})) {
foreach (@{$self->{option_results}->{header}}) {
if (/^(.*?):(.*)/) {
$self->{headers}->{$1} = $2;
}
}
}
$self->{get_params} = {};
if (defined($self->{option_results}->{get_param})) {
foreach (@{$self->{option_results}->{get_param}}) {
if (/^([^=]+)={0,1}(.*)$/) {
my $key = $1;
my $value = defined($2) ? $2 : 1;
if (defined($self->{get_params}->{$key})) {
if (ref($self->{get_params}->{$key}) ne 'ARRAY') {
$self->{get_params}->{$key} = [ $self->{get_params}->{$key} ];
}
push @{$self->{get_params}->{$key}}, $value;
} else {
$self->{get_params}->{$key} = $value;
}
}
}
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub load_request {
@ -265,14 +232,10 @@ sub lookup {
sub run {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{port})) {
$self->{option_results}->{port} = centreon::plugins::httplib::get_port($self);
}
$self->load_request();
my $timing0 = [gettimeofday];
$self->{json_response} = centreon::plugins::httplib::connect($self, headers => $self->{headers}, method => $self->{method},
query_form_get => $self->{get_params}, query_form_post => $self->{json_request});
$self->{json_response} = $self->{http}->request(method => $self->{method}, query_form_post => $self->{json_request});
my $timeelapsed = tv_interval ($timing0, [gettimeofday]);
$self->{output}->output_add(long_msg => $self->{json_response});
@ -395,6 +358,10 @@ HTTP OPTIONS:
IP Addr/FQDN of the Webserver host
=item B<--http-peer-addr>
Set the address you want to connect (Useful if hostname is only a vhost. no ip resolve)
=item B<--port>
Port used by Webserver
@ -463,6 +430,18 @@ Set GET params (Multiple option. Example: --get-param='key=value')
Set HTTP headers (Multiple option. Example: --header='Content-Type: xxxxx')
=item B<--unknown-status>
Threshold warning for http response code (Default: '%{http_code} < 200 or %{http_code} >= 300')
=item B<--warning-status>
Threshold warning for http response code
=item B<--critical-status>
Threshold critical for http response code
=back
=cut

View File

@ -18,14 +18,14 @@
# limitations under the License.
#
package apps::protocols::http::mode::responsetime;
package apps::protocols::http::mode::response;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Time::HiRes qw(gettimeofday tv_interval);
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,24 +36,38 @@ sub new {
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"http-peer-addr:s" => { name => 'http_peer_addr' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"urlpath:s" => { name => 'url_path', default => "/" },
"method:s" => { name => 'method' },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path' },
"credentials" => { name => 'credentials' },
"ntlm" => { name => 'ntlm' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"no-follow" => { name => 'no_follow', },
"ssl:s" => { name => 'ssl' },
"cert-file:s" => { name => 'cert_file' },
"key-file:s" => { name => 'key_file' },
"cacert-file:s" => { name => 'cacert_file' },
"cert-pwd:s" => { name => 'cert_pwd' },
"cert-pkcs12" => { name => 'cert_pkcs12' },
"header:s@" => { name => 'header' },
"get-param:s@" => { name => 'get_param' },
"post-param:s@" => { name => 'post_param' },
"cookies-file:s" => { name => 'cookies_file' },
"unknown-status:s" => { name => 'unknown_status', default => '' },
"warning-status:s" => { name => 'warning_status' },
"critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"warning-size:s" => { name => 'warning_size' },
"critical-size:s" => { name => 'critical_size' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -69,38 +83,24 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
if (($self->{perfdata}->threshold_validate(label => 'warning-size', value => $self->{option_results}->{warning_size})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning-size threshold '" . $self->{option_results}->{warning_size} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical-size', value => $self->{option_results}->{critical_size})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical-size threshold '" . $self->{option_results}->{critical_size} . "'.");
$self->{output}->option_exit();
}
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}->{pkcs12})) && (!defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pwd}))) {
$self->{output}->add_option_msg(short_msg => "You need to set --cert-file= and --cert-pwd= options when --pkcs12 is used");
$self->{output}->option_exit();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{port})) {
$self->{option_results}->{port} = centreon::plugins::httplib::get_port($self);
}
my $timing0 = [gettimeofday];
my $webcontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
my $timeelapsed = tv_interval ($timing0, [gettimeofday]);
my $webcontent = $self->{http}->request();
my $timeelapsed = tv_interval($timing0, [gettimeofday]);
$self->{output}->output_add(long_msg => $webcontent);
@ -108,11 +108,29 @@ sub run {
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Response time %.3fs", $timeelapsed));
$self->{output}->perfdata_add(label => "time",
$self->{output}->perfdata_add(label => "time", unit => 's',
value => sprintf('%.3f', $timeelapsed),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
# Size check
{
require bytes;
my $content_size = bytes::length($webcontent);
$exit = $self->{perfdata}->threshold_check(value => $content_size,
threshold => [ { label => 'critical-size', exit_litteral => 'critical' }, { label => 'warning-size', exit_litteral => 'warning' } ]);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Content size : %s", $content_size));
}
$self->{output}->perfdata_add(label => "size", unit => 'B',
value => $content_size,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-size'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-size'),
min => 0);
}
$self->{output}->display();
$self->{output}->exit();
}
@ -123,7 +141,7 @@ __END__
=head1 MODE
Check Webpage Time Response
Check Webpage response and size.
=over 8
@ -131,13 +149,21 @@ Check Webpage Time Response
IP Addr/FQDN of the webserver host
=item B<--http-peer-addr>
Set the address you want to connect (Useful if hostname is only a vhost. no ip resolve)
=item B<--port>
Port used by Webserver
=item B<--method>
Specify http method used (Default: 'GET')
=item B<--proto>
Specify https if needed
Specify https if needed (Default: 'http')
=item B<--urlpath>
@ -165,20 +191,16 @@ Proxy URL if any
=item B<--timeout>
Threshold for HTTP timeout
Threshold for HTTP timeout (Default: 5)
=item B<--no-follow>
Do not follow http redirect
=item B<--ssl>
Specify SSL version (example : 'sslv3', 'tlsv1'...)
=item B<--warning>
Threshold warning in seconds (Webpage response time)
=item B<--critical>
Threshold critical in seconds (Webpage response time)
=item B<--cert-file>
Specify certificate to send to the webserver
@ -199,6 +221,42 @@ Specify certificate's password
Specify type of certificate (PKCS12)
=item B<--header>
Set HTTP headers (Multiple option)
=item B<--get-param>
Set GET params (Multiple option. Example: --get-param='key=value')
=item B<--post-param>
Set POST params (Multiple option. Example: --post-param='key=value')
=item B<--cookies-file>
Save cookies in a file (Example: '/tmp/lwp_cookies.dat')
=item B<--unknown-status>
Threshold warning for http response code
=item B<--warning-status>
Threshold warning for http response code
=item B<--critical-status>
Threshold critical for http response code (Default: '%{http_code} < 200 or %{http_code} >= 300')
=item B<--warning>
Threshold warning in seconds (Webpage response time)
=item B<--critical>
Threshold critical in seconds (Webpage response time)
=back
=cut

View File

@ -25,7 +25,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Time::HiRes qw(gettimeofday tv_interval);
use centreon::plugins::httplib;
use centreon::plugins::http;
use XML::XPath;
sub new {
@ -40,9 +40,11 @@ sub new {
"data:s" => { name => 'data' },
"lookup:s@" => { name => 'lookup' },
"hostname:s" => { name => 'hostname' },
"http-peer-addr:s" => { name => 'http_peer_addr' },
"vhost:s" => { name => 'vhost' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"urlpath:s" => { name => 'url_path', default => "/" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path' },
"credentials" => { name => 'credentials' },
"ntlm" => { name => 'ntlm' },
"username:s" => { name => 'username' },
@ -56,6 +58,9 @@ sub new {
"cacert-file:s" => { name => 'cacert_file' },
"cert-pwd:s" => { name => 'cert_pwd' },
"cert-pkcs12" => { name => 'cert_pkcs12' },
"unknown-status:s" => { name => 'unknown_status' },
"warning-status:s" => { name => 'warning_status' },
"critical-status:s" => { name => 'critical_status' },
"warning-numeric:s" => { name => 'warning_numeric' },
"critical-numeric:s" => { name => 'critical_numeric' },
@ -79,6 +84,7 @@ sub new {
$self->{values_string_ok} = [];
$self->{values_string_warning} = [];
$self->{values_string_critical} = [];
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -113,31 +119,9 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "You need to specify data.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{hostname})) {
$self->{output}->add_option_msg(short_msg => "You need to specify hostname.");
$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}->{credentials})) && (defined($self->{option_results}->{ntlm}))) {
$self->{output}->add_option_msg(short_msg => "--ntlm option must be used with --credentials option");
$self->{output}->option_exit();
}
if ((defined($self->{option_results}->{pkcs12})) && (!defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pwd}))) {
$self->{output}->add_option_msg(short_msg => "You need to set --cert-file= and --cert-pwd= options when --pkcs12 is used");
$self->{output}->option_exit();
}
$self->{headers} = {};
if (defined($self->{option_results}->{header})) {
foreach (@{$self->{option_results}->{header}}) {
if (/^(.*?):(.*)/) {
$self->{headers}->{$1} = $2;
}
}
}
$self->{headers}->{SOAPAction} = $self->{option_results}->{service_soap};
$self->{http}->set_options(%{$self->{option_results}});
$self->{http}->add_header(key => 'SOAPAction', value => $self->{option_results}->{service_soap});
}
sub load_request {
@ -257,13 +241,10 @@ sub lookup {
sub run {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{port})) {
$self->{option_results}->{port} = centreon::plugins::httplib::get_port($self);
}
$self->load_request();
my $timing0 = [gettimeofday];
$self->{soap_response} = centreon::plugins::httplib::connect($self, headers => $self->{headers}, method => 'POST', query_form_post => $self->{soap_request});
$self->{soap_response} = $self->{http}->request(method => 'POST', query_form_post => $self->{soap_request});
my $timeelapsed = tv_interval ($timing0, [gettimeofday]);
$self->{output}->output_add(long_msg => $self->{soap_response});
@ -390,6 +371,10 @@ HTTP OPTIONS:
IP Addr/FQDN of the Webserver host
=item B<--http-peer-addr>
Set the address you want to connect (Useful if hostname is only a vhost. no ip resolve)
=item B<--port>
Port used by Webserver
@ -454,6 +439,18 @@ Specify type of certificate (PKCS1
Set HTTP headers (Multiple option)
=item B<--unknown-status>
Threshold warning for http response code (Default: '%{http_code} < 200 or %{http_code} >= 300')
=item B<--warning-status>
Threshold warning for http response code
=item B<--critical-status>
Threshold critical for http response code
=back
=cut

View File

@ -34,7 +34,7 @@ sub new {
%{$self->{modes}} = (
'expected-content' => 'apps::protocols::http::mode::expectedcontent',
'json-content' => 'apps::protocols::http::mode::jsoncontent',
'response-time' => 'apps::protocols::http::mode::responsetime',
'response' => 'apps::protocols::http::mode::response',
'soap-content' => 'apps::protocols::http::mode::soapcontent',
);

View File

@ -69,10 +69,6 @@ sub check_options {
sub run {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{port})) {
$self->{option_results}->{port} = centreon::plugins::httplib::get_port($self);
}
my ($connection, $timing0, $timeelapsed);
if (defined($self->{option_results}->{ssl})) {

View File

@ -67,10 +67,6 @@ sub check_options {
sub run {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{port})) {
$self->{option_results}->{port} = centreon::plugins::httplib::get_port($self);
}
my $icmp_sock = new IO::Socket::INET(Proto=>"icmp");
my $read_set = new IO::Select();
$read_set->add($icmp_sock);

View File

@ -41,9 +41,9 @@ sub new {
"validity-mode:s" => { name => 'validity_mode' },
"warning-date:s" => { name => 'warning' },
"critical-date:s" => { name => 'critical' },
"subjectname:s" => { name => 'subjectname' },
"issuername:s" => { name => 'issuername' },
"timeout:s" => { name => 'timeout', default => '3' },
"subjectname:s" => { name => 'subjectname', default => '' },
"issuername:s" => { name => 'issuername', default => '' },
"timeout:s" => { name => 'timeout', default => 5 },
});
return $self;
}
@ -68,11 +68,10 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Please set the port option");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{validity_mode})) {
$self->{output}->add_option_msg(short_msg => "Please set the validity-mode option");
if (!defined($self->{option_results}->{validity_mode}) || $self->{option_results}->{validity_mode} !~ /^expiration|subject|issuer$/) {
$self->{output}->add_option_msg(short_msg => "Please set the validity-mode option (issuer, subject or expiration)");
$self->{output}->option_exit();
}
}
sub run {
@ -100,19 +99,19 @@ sub run {
$self->{output}->display();
$self->{output}->exit()
};
}
#Create SSL connection
Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL);
eval { $ssl = Net::SSLeay::new($ctx) };
if ($@) {
if ($@) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("%s", $!));
$self->{output}->display();
$self->{output}->exit()
};
}
eval { Net::SSLeay::set_fd($ssl, fileno($connection)) };
if ($@) {
@ -121,7 +120,7 @@ sub run {
$self->{output}->display();
$self->{output}->exit()
};
}
eval { Net::SSLeay::connect($ssl) };
if ($@) {
@ -130,7 +129,7 @@ sub run {
$self->{output}->display();
$self->{output}->exit()
};
}
#Retrieve Certificat
$cert = Net::SSLeay::get_peer_certificate($ssl);
@ -150,12 +149,12 @@ sub run {
#Subject Name
} elsif ($self->{option_results}->{validity_mode} eq 'subject') {
my $subject_name = Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_subject_name($cert));
if ( $subject_name =~ /$self->{option_results}->{subjectname}/mi ) {
if ($subject_name =~ /$self->{option_results}->{subjectname}/mi) {
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("Subject Name %s is present in Certificate :%s", $self->{option_results}->{subjectname}, $subject_name));
short_msg => sprintf("Subject Name '%s' is present in Certificate: %s", $self->{option_results}->{subjectname}, $subject_name));
} else {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Subject Name %s is not present in Certificate : %s", $self->{option_results}->{subjectname}, $subject_name));
short_msg => sprintf("Subject Name '%s' is not present in Certificate: %s", $self->{option_results}->{subjectname}, $subject_name));
}
$self->{output}->display();
@ -164,19 +163,16 @@ sub run {
#Issuer Name
} elsif ($self->{option_results}->{validity_mode} eq 'issuer') {
my $issuer_name = Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_issuer_name($cert));
if ( $issuer_name =~ /$self->{option_results}->{issuername}/mi ) {
if ($issuer_name =~ /$self->{option_results}->{issuername}/mi) {
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("Issuer Name %s is present in Certificate :%s", $self->{option_results}->{issuername}, $issuer_name));
short_msg => sprintf("Issuer Name '%s' is present in Certificate: %s", $self->{option_results}->{issuername}, $issuer_name));
} else {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Issuer Name %s is not present in Certificate : %s", $self->{option_results}->{issuername}, $issuer_name));
short_msg => sprintf("Issuer Name '%s' is not present in Certificate: %s", $self->{option_results}->{issuername}, $issuer_name));
}
$self->{output}->display();
$self->{output}->exit()
} else {
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find validity-mode '" . $self->{option_results}->{validity_mode} . "'.");
$self->{output}->option_exit();
}
}
}

View File

@ -23,7 +23,7 @@ package apps::tomcat::web::mode::applications;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -35,12 +35,12 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '8080' },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"urlpath:s" => { name => 'url_path', default => '/manager/text/list' },
"name:s" => { name => 'name' },
"regexp" => { name => 'use_regexp' },
@ -49,7 +49,7 @@ sub new {
});
$self->{result} = {};
$self->{hostname} = undef;
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -57,27 +57,15 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub manage_selection {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
while ($webcontent =~ m/(.*):(.*):(.*):(.*)/g) {
while ($webcontent =~ m/(.*):(.*):(.*):(.*)/g) {
my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4);
next if (defined($self->{option_results}->{filter_path}) && $self->{option_results}->{filter_path} ne '' &&

View File

@ -23,7 +23,7 @@ package apps::tomcat::web::mode::listapplication;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -35,12 +35,12 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '8080' },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"urlpath:s" => { name => 'url_path', default => '/manager/text/list' },
"filter-name:s" => { name => 'filter_name', },
"filter-state:s" => { name => 'filter_state', },
@ -48,7 +48,7 @@ sub new {
});
$self->{result} = {};
$self->{hostname} = undef;
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -56,25 +56,13 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub manage_selection {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
while ($webcontent =~ m/(.*):(.*):(.*):(.*)/g) {
my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4);

View File

@ -23,7 +23,7 @@ package apps::tomcat::web::mode::memory;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use XML::XPath;
sub new {
@ -36,38 +36,26 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '8080' },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
});
$self->{result} = {};
$self->{hostname} = undef;
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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 (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
@ -77,6 +65,7 @@ sub check_options {
$self->{output}->option_exit();
}
$self->{http}->set_options(%{$self->{option_results}});
}
my %xpath_to_check = (
@ -88,7 +77,7 @@ my %xpath_to_check = (
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my $port = $self->{option_results}->{port};
#EXAMPLE 1:

View File

@ -23,7 +23,7 @@ package apps::tomcat::web::mode::requestinfo;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
use XML::XPath;
@ -39,12 +39,12 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '8080' },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' },
"name:s" => { name => 'name' },
"regexp" => { name => 'use_regexp' },
@ -62,6 +62,7 @@ sub new {
$self->{result} = {};
$self->{hostname} = undef;
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -69,18 +70,6 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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();
}
#MaxTime
if (($self->{perfdata}->threshold_validate(label => 'warning-maxtime', value => $self->{option_results}->{warning_maxtime})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning 'warning-maxtime' threshold '" . $self->{option_results}->{warning_maxtime} . "'.");
@ -123,6 +112,8 @@ sub check_options {
if (!defined($self->{hostname})) {
$self->{hostname} = 'me';
}
$self->{http}->set_options(%{$self->{option_results}});
}
my %xpath_to_check = (
@ -135,7 +126,7 @@ my %xpath_to_check = (
sub manage_selection {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my $port = $self->{option_results}->{port};
#EXAMPLE 1:
@ -207,12 +198,12 @@ sub manage_selection {
};
if (scalar(keys %{$self->{result}}) <= 0) {
if (defined($self->{option_results}->{name})) {
$self->{output}->add_option_msg(short_msg => "No information found for name '" . $self->{option_results}->{name} . "'.");
} else {
$self->{output}->add_option_msg(short_msg => "No information found.");
}
$self->{output}->option_exit();
if (defined($self->{option_results}->{name})) {
$self->{output}->add_option_msg(short_msg => "No information found for name '" . $self->{option_results}->{name} . "'.");
} else {
$self->{output}->add_option_msg(short_msg => "No information found.");
}
$self->{output}->option_exit();
};
};
};
@ -223,7 +214,7 @@ sub run {
$self->manage_selection();
my $new_datas = {};
$self->{statefile_value}->read(statefile => 'cache_apps_tomcat_web_' . $self->{option_results}->{hostname} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
$self->{statefile_value}->read(statefile => 'cache_apps_tomcat_web_' . $self->{option_results}->{hostname} . '_' . $self->{http}->get_port() . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
$new_datas->{last_timestamp} = time();
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');

View File

@ -23,7 +23,7 @@ package apps::tomcat::web::mode::sessions;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -35,12 +35,12 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '8080' },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"urlpath:s" => { name => 'url_path', default => '/manager/text/list' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
@ -52,7 +52,7 @@ sub new {
});
$self->{result} = {};
$self->{hostname} = undef;
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -60,18 +60,6 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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 (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
@ -80,15 +68,15 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub manage_selection {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
while ($webcontent =~ m/(.*):(.*):(.*):(.*)/g) {
while ($webcontent =~ m/(.*):(.*):(.*):(.*)/g) {
my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4);
next if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' &&

View File

@ -23,7 +23,7 @@ package apps::tomcat::web::mode::threads;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use XML::XPath;
use URI::Escape;
@ -37,12 +37,12 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '8080' },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
@ -53,6 +53,7 @@ sub new {
$self->{result} = {};
$self->{hostname} = undef;
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -60,18 +61,6 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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 (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
@ -81,6 +70,7 @@ sub check_options {
$self->{output}->option_exit();
}
$self->{http}->set_options(%{$self->{option_results}});
}
my %xpath_to_check = (
@ -92,7 +82,7 @@ my %xpath_to_check = (
sub manage_selection {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my $port = $self->{option_results}->{port};
#EXAMPLE 1:

View File

@ -23,7 +23,7 @@ package apps::tomcat::web::mode::traffic;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
use XML::XPath;
@ -39,12 +39,12 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', default => '8080' },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
"urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' },
"name:s" => { name => 'name' },
"regexp" => { name => 'use_regexp' },
@ -59,6 +59,7 @@ sub new {
$self->{result} = {};
$self->{hostname} = undef;
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -66,18 +67,6 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{option_results}->{proto} ne 'http') && ($self->{option_results}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
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 (($self->{perfdata}->threshold_validate(label => 'warning-in', value => $self->{option_results}->{warning_in})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning 'in' threshold '" . $self->{option_results}->{warning_in} . "'.");
$self->{output}->option_exit();
@ -109,6 +98,8 @@ sub check_options {
if (!defined($self->{hostname})) {
$self->{hostname} = 'me';
}
$self->{http}->set_options(%{$self->{option_results}});
}
my %xpath_to_check = (
@ -119,7 +110,7 @@ my %xpath_to_check = (
sub manage_selection {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my $port = $self->{option_results}->{port};
#EXAMPLE 1:
@ -207,7 +198,7 @@ sub run {
$self->manage_selection();
my $new_datas = {};
$self->{statefile_value}->read(statefile => 'cache_apps_tomcat_web_' . $self->{option_results}->{hostname} . '_' . centreon::plugins::httplib::get_port($self) . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
$self->{statefile_value}->read(statefile => 'cache_apps_tomcat_web_' . $self->{option_results}->{hostname} . '_' . $self->{http}->get_port() . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all')));
$new_datas->{last_timestamp} = time();
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');

View File

@ -32,16 +32,15 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'snmp_standard::mode::cpu',
'memory' => 'os::windows::snmp::mode::memory',
'storage' => 'snmp_standard::mode::storage',
'audio-ports' => 'apps::voip::cisco::meetingplace::mode::audioports',
'video-ports' => 'apps::voip::cisco::meetingplace::mode::videoports',
'audio-licenses' => 'apps::voip::cisco::meetingplace::mode::audiolicenses',
'video-licenses' => 'apps::voip::cisco::meetingplace::mode::videolicenses',
'packet-errors' => 'snmp_standard::mode::packeterrors',
'traffic' => 'snmp_standard::mode::traffic',
);
'cpu' => 'snmp_standard::mode::cpu',
'memory' => 'os::windows::snmp::mode::memory',
'storage' => 'snmp_standard::mode::storage',
'audio-ports' => 'apps::voip::cisco::meetingplace::mode::audioports',
'video-ports' => 'apps::voip::cisco::meetingplace::mode::videoports',
'audio-licenses' => 'apps::voip::cisco::meetingplace::mode::audiolicenses',
'video-licenses' => 'apps::voip::cisco::meetingplace::mode::videolicenses',
'interfaces' => 'snmp_standard::mode::interfaces',
);
return $self;
}

View File

@ -86,7 +86,10 @@ sub check_table_cpu {
my $cpu5sec = defined($self->{results}->{$options{entry}}->{$options{sec5} . '.' . $instance}) ? sprintf("%.2f", $self->{results}->{$options{entry}}->{$options{sec5} . '.' . $instance}) : undef;
my $cpu1min = defined($self->{results}->{$options{entry}}->{$options{min1} . '.' . $instance}) ? sprintf("%.2f", $self->{results}->{$options{entry}}->{$options{min1} . '.' . $instance}) : undef;
my $cpu5min = defined($self->{results}->{$options{entry}}->{$options{min5} . '.' . $instance}) ? sprintf("%.2f", $self->{results}->{$options{entry}}->{$options{min5} . '.' . $instance}) : undef;
# Case that it's maybe other CPU oid in table for datas.
next if (!defined($cpu5sec) && !defined($cpu1min) && !defined($cpu5min));
$checked = 1;
my @exits;
push @exits, $self->{perfdata}->threshold_check(value => $cpu5sec,

View File

@ -203,7 +203,7 @@ sub get_attributes {
$j < scalar(@{$options{request}->[$i]->{attributes}}); $j++, $pos++) {
if ($responses[$pos]->is_error()) {
# 500-599 an error. 400 is an attribute not present
if ($responses[$pos]->status() >= 500) {
if ($responses[$pos]->status() >= 500 || $responses[$pos]->status() == 401) {
$self->{output}->add_option_msg(short_msg => "protocol issue: " . $responses[$pos]->error_text());
$self->{output}->option_exit();
}

282
centreon/plugins/http.pm Normal file
View File

@ -0,0 +1,282 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::plugins::http;
use strict;
use warnings;
use centreon::plugins::misc;
use LWP::UserAgent;
use HTTP::Cookies;
use URI;
use IO::Socket::SSL;
sub new {
my ($class, %options) = @_;
my $self = {};
bless $self, $class;
$self->{output} = $options{output};
$self->{ua} = undef;
$self->{options} = {
proto => 'http',
url_path => '/',
timeout => 5,
method => 'GET',
unknown_status => '%{http_code} < 200 or %{http_code} >= 300',
warning_status => undef,
critical_status => undef,
};
$self->{add_headers} = {};
return $self;
}
sub set_options {
my ($self, %options) = @_;
$self->{options} = { %{$self->{options}} };
foreach (keys %options) {
$self->{options}->{$_} = $options{$_} if (defined($options{$_}));
}
}
sub add_header {
my ($self, %options) = @_;
$self->{add_headers}->{$options{key}} = $options{value};
}
sub check_options {
my ($self, %options) = @_;
if (($options{request}->{proto} ne 'http') && ($options{request}->{proto} ne 'https')) {
$self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'.");
$self->{output}->option_exit();
}
if (!defined($options{request}->{hostname})) {
$self->{output}->add_option_msg(short_msg => "Please set the hostname option");
$self->{output}->option_exit();
}
if ((defined($options{request}->{credentials})) && (!defined($options{request}->{username}) || !defined($options{request}->{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($options{request}->{pkcs12})) && (!defined($options{request}->{cert_file}) && !defined($options{request}->{cert_pwd}))) {
$self->{output}->add_option_msg(short_msg => "You need to set --cert-file= and --cert-pwd= options when --pkcs12 is used");
$self->{output}->option_exit();
}
$options{request}->{port} = $self->get_port_request();
$options{request}->{headers} = {};
if (defined($options{request}->{header})) {
foreach (@{$options{request}->{header}}) {
if (/^(.*?):(.*)/) {
$options{request}->{headers}->{$1} = $2;
}
}
}
foreach (keys %{$self->{add_headers}}) {
$options{request}->{headers}->{$_} = $self->{add_headers}->{$_};
}
foreach my $method (('get', 'post')) {
if (defined($options{request}->{$method . '_param'})) {
$self->{$method . '_params'} = {};
foreach (@{$options{request}->{$method . '_param'}}) {
if (/^([^=]+)={0,1}(.*)$/) {
my $key = $1;
my $value = defined($2) ? $2 : 1;
if (defined($self->{$method . '_params'}->{$key})) {
if (ref($self->{$method . '_params'}->{$key}) ne 'ARRAY') {
$self->{$method . '_params'}->{$key} = [ $self->{$method . '_params'}->{$key} ];
}
push @{$self->{$method . '_params'}->{$key}}, $value;
} else {
$self->{$method . '_params'}->{$key} = $value;
}
}
}
}
}
foreach (('unknown_status', 'warning_status', 'critical_status')) {
if (defined($options{request}->{$_})) {
$options{request}->{$_} =~ s/%\{http_code\}/\$response->code/g;
}
}
}
sub get_port {
my ($self, %options) = @_;
my $port = '';
if (defined($self->{options}->{port}) && $self->{options}->{port} ne '') {
$port = $self->{options}->{port};
} else {
$port = 80 if ($self->{options}->{proto} eq 'http');
$port = 443 if ($self->{options}->{proto} eq 'https');
}
return $port;
}
sub get_port_request {
my ($self, %options) = @_;
my $port = '';
if (defined($self->{options}->{port}) && $self->{options}->{port} ne '') {
$port = $self->{options}->{port};
}
return $port;
}
sub request {
my ($self, %options) = @_;
my $request_options = { %{$self->{options}} };
foreach (keys %options) {
$request_options->{$_} = $options{$_} if (defined($options{$_}));
}
$self->check_options(request => $request_options);
if (!defined($self->{ua})) {
$self->{ua} = LWP::UserAgent->new(keep_alive => 1, protocols_allowed => ['http', 'https'], timeout => $request_options->{timeout});
if (defined($request_options->{cookies_file})) {
$self->{ua}->cookie_jar(HTTP::Cookies->new(file => $request_options->{cookies_file},
autosave => 1));
}
}
if (defined($request_options->{no_follow})) {
$self->{ua}->requests_redirectable(undef);
} else {
$self->{ua}->requests_redirectable([ 'GET', 'HEAD', 'POST' ]);
}
if (defined($request_options->{http_peer_addr})) {
push @LWP::Protocol::http::EXTRA_SOCK_OPTS, PeerAddr => $request_options->{http_peer_addr};
}
my ($response, $content);
my ($req, $url);
if (defined($request_options->{port}) && $request_options->{port} =~ /^[0-9]+$/) {
$url = $request_options->{proto}. "://" . $request_options->{hostname} . ':' . $request_options->{port} . $request_options->{url_path};
} else {
$url = $request_options->{proto}. "://" . $request_options->{hostname} . $request_options->{url_path};
}
my $uri = URI->new($url);
if (defined($self->{get_params})) {
$uri->query_form($self->{get_params});
}
$req = HTTP::Request->new($request_options->{method}, $uri);
my $content_type_forced;
foreach my $key (keys %{$request_options->{headers}}) {
if ($key !~ /content-type/i) {
$req->header($key => $request_options->{headers}->{$key});
} else {
$content_type_forced = $request_options->{headers}->{$key};
}
}
if ($request_options->{method} eq 'POST') {
if (defined($content_type_forced)) {
$req->content_type($content_type_forced);
$req->content($request_options->{query_form_post});
} else {
my $uri_post = URI->new();
if (defined($self->{post_params})) {
$uri_post->query_form($self->{post_params});
}
$req->content_type('application/x-www-form-urlencoded');
$req->content($uri_post->query);
}
}
if (defined($request_options->{credentials}) && defined($request_options->{ntlm})) {
$self->{ua}->credentials($request_options->{hostname} . ':' . $request_options->{port}, '', $request_options->{username}, $request_options->{password});
} elsif (defined($request_options->{credentials})) {
$req->authorization_basic($request_options->{username}, $request_options->{password});
}
if (defined($request_options->{proxyurl})) {
$self->{ua}->proxy(['http', 'https'], $request_options->{proxyurl});
}
if (defined($request_options->{cert_pkcs12}) && $request_options->{cert_file} ne '' && $request_options->{cert_pwd} ne '') {
eval "use Net::SSL"; die $@ if $@;
$ENV{HTTPS_PKCS12_FILE} = $request_options->{cert_file};
$ENV{HTTPS_PKCS12_PASSWORD} = $request_options->{cert_pwd};
}
my $ssl_context;
if (defined($request_options->{ssl}) && $request_options->{ssl} ne '') {
$ssl_context = { SSL_version => $request_options->{ssl} };
}
if (defined($request_options->{cert_file}) && !defined($request_options->{cert_pkcs12})) {
$ssl_context = {} if (!defined($ssl_context));
$ssl_context->{SSL_use_cert} = 1;
$ssl_context->{SSL_cert_file} = $request_options->{cert_file};
$ssl_context->{SSL_key_file} = $request_options->{key_file} if (defined($request_options->{key_file}));
$ssl_context->{SSL_ca_file} = $request_options->{cacert_file} if (defined($request_options->{cacert_file}));
}
if (defined($ssl_context)) {
my $context = new IO::Socket::SSL::SSL_Context(%{$ssl_context});
IO::Socket::SSL::set_default_context($context);
}
$response = $self->{ua}->request($req);
# Check response
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($request_options->{critical_status}) && $request_options->{critical_status} ne '' &&
eval "$request_options->{critical_status}") {
$status = 'critical';
} elsif (defined($request_options->{warning_status}) && $request_options->{warning_status} ne '' &&
eval "$request_options->{warning_status}") {
$status = 'warning';
} elsif (defined($request_options->{unknown_status}) && $request_options->{unknown_status} ne '' &&
eval "$request_options->{unknown_status}") {
$status = 'unknown';
}
};
if (defined($message)) {
$self->{output}->add_option_msg(short_msg => 'filter status issue: ' . $message);
$self->{output}->option_exit();
}
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $status,
short_msg => $response->status_line);
$self->{output}->display();
$self->{output}->exit();
}
return $response->content;
}
1;

View File

@ -1,141 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package centreon::plugins::httplib;
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Cookies;
use URI;
use IO::Socket::SSL;
sub get_port {
my ($self, %options) = @_;
my $cache_port = '';
if (defined($self->{option_results}->{port}) && $self->{option_results}->{port} ne '') {
$cache_port = $self->{option_results}->{port};
} else {
$cache_port = 80 if ($self->{option_results}->{proto} eq 'http');
$cache_port = 443 if ($self->{option_results}->{proto} eq 'https');
}
return $cache_port;
}
sub connect {
my ($self, %options) = @_;
my $method = defined($options{method}) ? $options{method} : 'GET';
my $connection_exit = defined($options{connection_exit}) ? $options{connection_exit} : 'unknown';
my $ua = LWP::UserAgent->new(keep_alive => 1, protocols_allowed => ['http', 'https'], timeout => $self->{option_results}->{timeout},
requests_redirectable => [ 'GET', 'HEAD', 'POST' ]);
if (defined($options{cookies_file})) {
$ua->cookie_jar(HTTP::Cookies->new(file => $options{cookies_file},
autosave => 1));
}
my ($response, $content);
my ($req, $url);
if (defined($self->{option_results}->{port}) && $self->{option_results}->{port} =~ /^[0-9]+$/) {
$url = $self->{option_results}->{proto}. "://" . $self->{option_results}->{hostname}.':'. $self->{option_results}->{port} . $self->{option_results}->{url_path};
} else {
$url = $self->{option_results}->{proto}. "://" . $self->{option_results}->{hostname} . $self->{option_results}->{url_path};
}
my $uri = URI->new($url);
if (defined($options{query_form_get})) {
$uri->query_form($options{query_form_get});
}
$req = HTTP::Request->new($method => $uri);
my $content_type_forced;
if (defined($options{headers})) {
foreach my $key (keys %{$options{headers}}) {
if ($key !~ /content-type/i) {
$req->header($key => $options{headers}->{$key});
} else {
$content_type_forced = $options{headers}->{$key};
}
}
}
if ($method eq 'POST') {
if (defined($content_type_forced)) {
$req->content_type($content_type_forced);
$req->content($options{query_form_post});
} else {
my $uri_post = URI->new();
if (defined($options{query_form_post})) {
$uri_post->query_form($options{query_form_post});
}
$req->content_type('application/x-www-form-urlencoded');
$req->content($uri_post->query);
}
}
if (defined($self->{option_results}->{credentials}) && defined($self->{option_results}->{ntlm})) {
$ua->credentials($self->{option_results}->{hostname} . ':' . $self->{option_results}->{port}, '', $self->{option_results}->{username}, $self->{option_results}->{password});
} elsif (defined($self->{option_results}->{credentials})) {
$req->authorization_basic($self->{option_results}->{username}, $self->{option_results}->{password});
}
if (defined($self->{option_results}->{proxyurl})) {
$ua->proxy(['http', 'https'], $self->{option_results}->{proxyurl});
}
if (defined($self->{option_results}->{cert_pkcs12}) && $self->{option_results}->{cert_file} ne '' && $self->{option_results}->{cert_pwd} ne '') {
eval "use Net::SSL"; die $@ if $@;
$ENV{HTTPS_PKCS12_FILE} = $self->{option_results}->{cert_file};
$ENV{HTTPS_PKCS12_PASSWORD} = $self->{option_results}->{cert_pwd};
}
my $ssl_context;
if (defined($self->{option_results}->{ssl}) && $self->{option_results}->{ssl} ne '') {
$ssl_context = { SSL_version => $self->{option_results}->{ssl} };
}
if (defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pkcs12})) {
$ssl_context = {} if (!defined($ssl_context));
$ssl_context->{SSL_use_cert} = 1;
$ssl_context->{SSL_cert_file} = $self->{option_results}->{cert_file};
$ssl_context->{SSL_key_file} = $self->{option_results}->{key_file} if (defined($self->{option_results}->{key_file}));
$ssl_context->{SSL_ca_file} = $self->{option_results}->{cacert_file} if (defined($self->{option_results}->{cacert_file}));
}
if (defined($ssl_context)) {
my $context = new IO::Socket::SSL::SSL_Context(%{$ssl_context});
IO::Socket::SSL::set_default_context($context);
}
$response = $ua->request($req);
if ($response->is_success) {
$content = $response->content;
return $content;
}
$self->{output}->output_add(severity => $connection_exit,
short_msg => $response->status_line);
$self->{output}->display();
$self->{output}->exit();
}
1;

View File

@ -318,13 +318,13 @@ sub powershell_escape {
sub minimal_version {
my ($version_src, $version_dst) = @_;
# No Version. We skip
if (!defined($version_src) || !defined($version_dst) ||
$version_src !~ /^[0-9]+(?:\.[0-9\.])*$/ || $version_dst !~ /^[0-9x]+(?:\.[0-9x\.])*$/) {
$version_src !~ /^[0-9]+(?:\.[0-9\.]+)*$/ || $version_dst !~ /^[0-9x]+(?:\.[0-9x]+)*$/) {
return 1;
}
my @version_src = split /\./, $version_src;
my @versions = split /\./, $version_dst;
for (my $i = 0; $i < scalar(@versions); $i++) {

View File

@ -0,0 +1,338 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package database::firebird::firebirdcmd;
use strict;
use warnings;
use centreon::plugins::misc;
use Digest::MD5 qw(md5_hex);
sub new {
my ($class, %options) = @_;
my $self = {};
bless $self, $class;
# $options{options} = options object
# $options{output} = output object
# $options{exit_value} = integer
# $options{noptions} = integer
if (!defined($options{output})) {
print "Class mysqlcmd: Need to specify 'output' argument.\n";
exit 3;
}
if (!defined($options{options})) {
$options{output}->add_option_msg(short_msg => "Class Firebirdcmd: Need to specify 'options' argument.");
$options{output}->option_exit();
}
if (!defined($options{noptions})) {
$options{options}->add_options(arguments =>
{ "firebird-cmd:s" => { name => 'firebird_cmd', default => '/opt/firebird/bin/isql' }
"host:s@" => { name => 'host' },
"port:s@" => { name => 'port' },
"username:s@" => { name => 'username' },
"password:s@" => { name => 'password' },
"dbname:s@" => { name => 'dbname' },
"sql-errors-exit:s" => { name => 'sql_errors_exit', default => 'unknown' },
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'MYSQLCMD OPTIONS', once => 1);
$self->{output} = $options{output};
$self->{mode} = $options{mode};
$self->{args} = undef;
$self->{stdout} = undef;
$self->{columns} = undef;
$self->{version} = undef;
$self->{host} = undef;
$self->{port} = undef;
$self->{dbname} = undef;
$self->{username} = undef;
$self->{password} = undef;
return $self;
}
# Method to manage multiples
sub set_options {
my ($self, %options) = @_;
# options{options_result}
$self->{option_results} = $options{option_results};
}
# Method to manage multiples
sub set_defaults {
my ($self, %options) = @_;
# options{default}
# Manage default value
foreach (keys %{$options{default}}) {
if ($_ eq $self->{mode}) {
for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) {
foreach my $opt (keys %{$options{default}->{$_}[$i]}) {
if (!defined($self->{option_results}->{$opt}[$i])) {
$self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt};
}
}
}
}
}
}
sub check_options {
my ($self, %options) = @_;
# return 1 = ok still data_source
# return 0 = no data_source left
$self->{host} = (defined($self->{option_results}->{host})) ? shift(@{$self->{option_results}->{host}}) : undef;
$self->{port} = (defined($self->{option_results}->{port})) ? shift(@{$self->{option_results}->{port}}) : undef;
$self->{dbname} = (defined($self->{option_results}->{dbname})) ? shift(@{$self->{option_results}->{dbname}}) : undef;
$self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : undef;
$self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : undef;
$self->{sql_errors_exit} = $self->{option_results}->{sql_errors_exit};
$self->{firebird_cmd} = $self->{option_results}->{firebird_cmd};
if (!defined($self->{host}) || $self->{host} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify host argument.");
$self->{output}->option_exit(exit_litteral => $self->{sql_errors_exit});
}
$self->{args} = ['--batch', '--raw', '--host', $self->{host}];
if (defined($self->{port})) {
push @{$self->{args}}, "--port", $self->{port};
}
if (defined($self->{username})) {
push @{$self->{args}}, "--user", $self->{username};
}
if (defined($self->{password}) && $self->{password} ne '') {
push @{$self->{args}}, "-p" . $self->{password};
}
if (defined($self->{dbname}) && $self->{dbnam} ne '') {
push @{$self->{args}}, "--dbname", $self->{dbname};
}
if (scalar(@{$self->{option_results}->{host}}) == 0) {
return 0;
}
return 1;
}
sub is_version_minimum {
my ($self, %options) = @_;
# $options{version} = string version to check
my @version_src = split /\./, $self->{version};
my @versions = split /\./, $options{version};
for (my $i = 0; $i < scalar(@versions); $i++) {
return 1 if ($versions[$i] eq 'x');
return 1 if (!defined($version_src[$i]));
$version_src[$i] =~ /^([0-9]*)/;
next if ($versions[$i] == int($1));
return 0 if ($versions[$i] > int($1));
return 1 if ($versions[$i] < int($1));
}
return 1;
}
sub get_id {
my ($self, %options) = @_;
my $msg = $self->{host};
if (defined($self->{port})) {
$msg .= ":" . $self->{port};
}
return $msg;
}
sub get_unique_id4save {
my ($self, %options) = @_;
my $msg = $self->{host};
if (defined($self->{port})) {
$msg .= ":" . $self->{port};
}
return md5_hex($msg);
}
sub quote {
my $self = shift;
return undef;
}
sub command_execution {
my ($self, %options) = @_;
my ($lerror, $stdout, $exit_code) = centreon::plugins::misc::backtick(
command => $self->{firebird_cmd},
arguments => [@{$self->{args}}, '-e', $options{request}],
timeout => 30,
wait_exit => 1,
redirect_stderr => 1
);
if ($exit_code <= -1000) {
if ($exit_code == -1000) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => $stdout);
}
$self->{output}->display();
$self->{output}->exit();
}
return ($exit_code, $stdout);
}
# Connection initializer
sub connect {
my ($self, %options) = @_;
my $dontquit = (defined($options{dontquit}) && $options{dontquit} == 1) ? 1 : 0;
(my $exit_code, $self->{stdout}) = $self->command_execution(request => "SHOW VERSION");
if ($exit_code != 0) {
if ($dontquit == 0) {
$self->{output}->add_option_msg(short_msg => "Cannot connect: " . $self->{stdout});
$self->{output}->option_exit(exit_litteral => $self->{sql_errors_exit});
}
return (-1, "Cannot connect: " . $self->{stdout});
}
my $row = $self->fetchrow_hashref();
$self->{version} = $row->{Value};
return 0;
}
sub fetchall_arrayref {
my ($self, %options) = @_;
my $array_ref = [];
if (!defined($self->{columns})) {
$self->{stdout} =~ s/^(.*?)(\n|$)//;
@{$self->{columns}} = split(/\t/, $1);
}
foreach (split /\n/, $self->{stdout}) {
push @$array_ref, [map({ s/\\n/\x{0a}/g; s/\\t/\x{09}/g; s/\\/\x{5c}/g; $_; } split(/\t/, $_))];
}
return $array_ref;
}
sub fetchrow_array {
my ($self, %options) = @_;
my @array_result = ();
if (!defined($self->{columns})) {
$self->{stdout} =~ s/^(.*?)(\n|$)//;
@{$self->{columns}} = split(/\t/, $1);
}
if (($self->{stdout} =~ s/^(.*?)(\n|$)//)) {
push @array_result, map({ s/\\n/\x{0a}/g; s/\\t/\x{09}/g; s/\\/\x{5c}/g; $_; } split(/\t/, $1));
}
return @array_result;
}
sub fetchrow_hashref {
my ($self, %options) = @_;
my $array_result = undef;
if (!defined($self->{columns})) {
$self->{stdout} =~ s/^(.*?)(\n|$)//;
@{$self->{columns}} = split(/\t/, $1);
}
if ($self->{stdout} ne '' && $self->{stdout} =~ s/^(.*?)(\n|$)//) {
$array_result = {};
my @values = split(/\t/, $1);
for (my $i = 0; $i < scalar(@values); $i++) {
my $value = $values[$i];
$value =~ s/\\n/\x{0a}/g;
$value =~ s/\\t/\x{09}/g;
$value =~ s/\\/\x{5c}/g;
$array_result->{$self->{columns}[$i]} = $value;
}
}
return $array_result;
}
sub query {
my ($self, %options) = @_;
$self->{columns} = undef;
(my $exit_code, $self->{stdout}) = $self->command_execution(request => $options{query});
if ($exit_code != 0) {
$self->{output}->add_option_msg(short_msg => "Cannot execute query: " . $self->{stdout});
$self->{output}->option_exit(exit_litteral => $self->{sql_errors_exit});
}
}
1;
__END__
=head1 NAME
mysqlcmd global
=head1 SYNOPSIS
mysqlcmd class
=head1 MYSQLCMD OPTIONS
=over 8
=item B<--mysql-cmd>
mysql command (Default: '/usr/bin/mysql').
=item B<--host>
Database hostname.
=item B<--port>
Database port.
=item B<--username>
Database username.
=item B<--password>
Database password.
=item B<--sql-errors-exit>
Exit code for DB Errors (default: unknown)
=back
=head1 DESCRIPTION
B<snmp>.
=cut

View File

@ -0,0 +1,117 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package database::firebird::mode::iostats;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use POSIX;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
# $options{sql} = sqlmode object
$self->{sql} = $options{sql};
$self->{sql}->connect();
if (!($self->{sql}->is_version_minimum(version => '1'))) {
$self->{output}->add_option_msg(short_msg => "Firebird version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x').");
$self->{output}->option_exit();
}
$self->{sql}->query(query => q{SELECT MON$PAGE_READS,MON$PAGE_WRITES FROM MON$IO_STATS WHERE MON$STAT_GROUP=0;});
my $result = $self->{sql}->fetchall_arrayref();
if (!defined($result)) {
$self->{output}->add_option_msg(short_msg => "Cannot get IO Stats.");
$self->{output}->option_exit();
}
my $page_reads = $$result[0][0];
my $page_writes = $$result[0][1];
my $exit1 = $self->{perfdata}->threshold_check(value => $page_reads, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $page_writes, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("I/O stats : %d/%d",$page_writes, $page_reads ));
$self->{output}->perfdata_add(label => 'input', value => $page_writes);
$self->{output}->perfdata_add(label => 'output', value => $page_reads);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check MySQL uptime.
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--seconds>
Display uptime in seconds.
=back
=cut

View File

@ -0,0 +1,188 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package database::firebird::mode::memory;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use DBD::Firebird;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
"seconds" => { name => 'seconds', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
# $options{sql} = sqlmode object
$self->{sql} = $options{sql};
$self->{sql}->connect();
if (!($self->{sql}->is_version_minimum(version => '1'))) {
$self->{output}->add_option_msg(short_msg => "Firebird version '" . $self->{sql}->{version} . "' is not supported (need version >= '1.x').");
$self->{output}->option_exit();
}
$self->{sql}->query(query => q{SELECT MON$STAT_GROUP,MON$MEMORY_ALLOCATED,MON$MEMORY_USED FROM MON$MEMORY_USAGE});
my $result = $self->{sql}->fetchall_arrayref();
if(!defined($result)) {
$self->{output}->add_option_msg(short_msg => "Cannot get memory.");
$self->{output}->opion_exit();
}
my $mem_allocated;
my $attach_used=0;
my $prct_attach=0;
my $trans_used=0;
my $prct_trans;
my $stat_used=0;
my $prct_stat=0;
my $call_used=0;
my $prct_call=0;
my ($total_value, $total_unit)=(0,0);
my ($attach_value, $attach_unit)=(0,0);
my ($trans_value, $trans_unit)=(0,0);
my ($stat_value, $stat_unit)=(0,0);
my ($call_value, $call_unit)= (0,'B');
foreach my $row (@$result) {
next if (defined($self->{option_results}->{filter}) &&
$$row[0] !~ /$self->{option_results}->{filter}/);
if ($$row[0] == 0) {
$mem_allocated = $$row[1];
($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $mem_allocated);
} elsif ($$row[0] ==1) {
$attach_used = $attach_used + $$row[2];
$prct_attach = $attach_used * 100 / $mem_allocated;
($attach_value, $attach_unit) = $self->{perfdata}->change_bytes(value => $attach_used);
} elsif ($$row[0] == 2) {
$trans_used = $trans_used + $$row[2];
$prct_trans = $trans_used * 100 / $mem_allocated;
($trans_value, $trans_unit) = $self->{perfdata}->change_bytes(value => $trans_used);
} elsif ($$row[0] == 3) {
$stat_used = $stat_used + $$row[2];
$prct_stat = $stat_used * 100 / $mem_allocated;
($stat_value, $stat_unit) = $self->{perfdata}->change_bytes(value => $stat_used);
} elsif ($$row[0] ==4) {
$call_used = $call_used + $$row[2];
$prct_call = $call_used * 100 / $mem_allocated;
($call_value, $call_unit) = $self->{perfdata}->change_bytes(value => $call_used);
}
}
my $mem_used = $attach_used + $trans_used + $stat_used + $call_used;
my $prct_used = $mem_used * 100 / $mem_allocated;
my ($used_value, $used_unit)=$self->{perfdata}->change_bytes(value => $mem_used);
my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->perfdata_add(label => "used", unit => 'B',
value => $mem_used,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $mem_allocated, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $mem_allocated, cast_int => 1),
min => 0, max => $mem_allocated);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Memory Allocated %s, Total Used %s (%.2f%%)",
$total_value . " " . $total_unit,
$used_value . " " . $used_unit, $prct_used));
$self->{output}->output_add(long_msg => sprintf("Attachement Used %s (%.2f%%)",
$attach_value . " " . $attach_unit, $prct_attach));
$self->{output}->perfdata_add(label => "attachement", unit => 'B',
value => $attach_used);
$self->{output}->output_add(long_msg => sprintf("Transaction Used %s (%.2f%%)",
$trans_value . " " . $trans_unit, $prct_trans));
$self->{output}->perfdata_add(label => "transaction", unit => 'B',
value => $trans_used);
$self->{output}->output_add(long_msg => sprintf("Statement Used %s (%.2f%%)",
$stat_value . " " . $stat_unit, $prct_stat));
$self->{output}->perfdata_add(label => "statement", unit => 'B',
value => $stat_used);
$self->{output}->output_add(long_msg => sprintf("Call Used %s (%.2f%%)",
$call_value . " " . $call_unit, $prct_call));
$self->{output}->perfdata_add(label => "call", unit => 'B',
value => $call_used);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check MySQL uptime.
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--seconds>
Display uptime in seconds.
=back
=cut

View File

@ -0,0 +1,145 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package database::firebird::mode::queries;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::statefile;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
$self->{statefile_cache}->check_options(%options);
}
sub run {
my ($self, %options) = @_;
# $options{sql} = sqlmode object
$self->{sql} = $options{sql};
$self->{sql}->connect();
$self->{sql}->query(query => q{
SELECT MON$RECORD_SEQ_READS,MON$RECORD_INSERTS,MON$RECORD_UPDATES,MON$RECORD_DELETES,MON$RECORD_BACKOUTS,MON$RECORD_PURGES,MON$RECORD_EXPUNGES from MON$RECORD_STATS WHERE MON$STAT_GROUP=0
});
my $result = $self->{sql}->fetchall_arrayref();
if (!($self->{sql}->is_version_minimum(version => '1'))) {
$self->{output}->add_option_msg(short_msg => "Firebird version '" . $self->{sql}->{version} . "' is not supported (need version >= '1').");
$self->{output}->option_exit();
}
my $new_datas = {};
$self->{statefile_cache}->read(statefile => 'firebird_' . $self->{mode} . '_' . $self->{sql}->get_unique_id4save());
my $old_timestamp = $self->{statefile_cache}->get(name => 'last_timestamp');
$new_datas->{last_timestamp} = time();
if (defined($old_timestamp) && $new_datas->{last_timestamp} - $old_timestamp == 0) {
$self->{output}->add_option_msg(short_msg => "Need at least one second between two checks.");
$self->{output}->option_exit();
}
my @field = ("seq_reads","inserts","updates","deletes","backouts","purges","expunges");
my $i=0;
foreach my $name (@field) {
$new_datas->{$name} = $$result[0][$i];
my $old_val = $self->{statefile_cache}->get(name => $name);
next if (!defined($old_val) || $$result[0][$i] < $old_val);
my $value = int(($$result[0][$i] - $old_val) / ($new_datas->{last_timestamp} - $old_timestamp));
if ($name ne 'seq_reads') {
$self->{output}->perfdata_add(label => $name . '_requests',
value => $value,
min => 0);
$i++;
next;
}
my $exit_code = $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("Total requests = %s", $value));
$self->{output}->perfdata_add(label => 'total_requests',
value => $value,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
$i++
}
$self->{statefile_cache}->write(data => $new_datas);
if (!defined($old_timestamp)) {
$self->{output}->output_add(severity => 'OK',
short_msg => "Buffer creation...");
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check average number of queries executed.
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=back
=cut

View File

@ -0,0 +1,139 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package database::firebird::mode::slowqueries;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::statefile;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
$self->{statefile_cache}->check_options(%options);
}
sub run {
my ($self, %options) = @_;
# $options{sql} = sqlmode object
$self->{sql} = $options{sql};
$self->{sql}->connect();
if (!($self->{sql}->is_version_minimum(version => '1'))) {
$self->{output}->add_option_msg(short_msg => "Firebird version '" . $self->{sql}->{version} . "' is not supported (need version >= '1.x').");
$self->{output}->option_exit();
}
$self->{sql}->query(query => q{SELECT COUNT(*) FROM MON$STATEMENTS INNER JOIN MON$TRANSACTIONS ON (MON$STATEMENTS.MON$ATTACHMENT_ID = MON$TRANSACTIONS.MON$ATTACHMENT_ID)});
my $result = $self->{sql}->fetchrow_array();
my $name='slow_query';
if (!defined($result)) {
$self->{output}->add_option_msg(short_msg => "Cannot get slow queries.");
$self->{output}->option_exit();
}
my $new_datas = {};
$self->{statefile_cache}->read(statefile => 'firebird_' . $self->{mode} . '_' . $self->{sql}->get_unique_id4save());
my $old_timestamp = $self->{statefile_cache}->get(name => 'last_timestamp');
$new_datas->{last_timestamp} = time();
if (defined($old_timestamp) && $new_datas->{last_timestamp} - $old_timestamp == 0) {
$self->{output}->add_option_msg(short_msg => "Need at least one second between two checks.");
$self->{output}->option_exit();
}
$new_datas->{$name} = $result;
my $old_val = $self->{statefile_cache}->get(name => $name);
if (defined($old_val) && $result >= $old_val) {
my $value = sprintf("%.2f", ($result - $old_val) / ($new_datas->{last_timestamp} - $old_timestamp));
my $exit_code = $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("%d slow queries in %d seconds (%.2f/sec)",
($result - $old_val), ($new_datas->{last_timestamp} - $old_timestamp), $value)
);
$self->{output}->perfdata_add(label => 'slow_queries_rate',
value => $value,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
}
$self->{statefile_cache}->write(data => $new_datas);
if (!defined($old_timestamp)) {
$self->{output}->output_add(severity => 'OK',
short_msg => "Buffer creation...");
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check average number of queries detected as "slow" (per seconds).
=over 8
=item B<--warning>
Threshold warning in queries per seconds.
=item B<--critical>
Threshold critical in queries per seconds.
=back
=cut

View File

@ -0,0 +1,116 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package database::firebird::mode::users;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use DBD::Firebird;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
# $options{sql} = sqlmode object
$self->{sql} = $options{sql};
$self->{sql}->connect();
if (!($self->{sql}->is_version_minimum(version => '1'))) {
$self->{output}->add_option_msg(short_msg => "firebird version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x').");
$self->{output}->option_exit();
}
$self->{sql}->query(query => q{SELECT COUNT(MON$USER) FROM MON$ATTACHMENTS});
my $result = $self->{sql}->fetchrow_array();
if (!defined($result)) {
$self->{output}->add_option_msg(short_msg => "Cannot get users.");
$self->{output}->option_exit();
}
my $exit_code = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $msg = sprintf("%d user(s) connect to database", $result);
$self->{output}->output_add(severity => $exit_code,
short_msg => $msg);
$self->{output}->perfdata_add(label => 'User', value => $result,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check MySQL uptime.
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--seconds>
Display uptime in seconds.
=back
=cut

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package apps::kayako::sql::plugin;
package database::firebird::plugin;
use strict;
use warnings;
@ -26,20 +26,22 @@ use base qw(centreon::plugins::script_sql);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
# $options->{options} = options object
$self->{version} = '0.1';
%{$self->{modes}} = (
'list-department' => 'apps::kayako::sql::mode::listdepartment',
'list-priority' => 'apps::kayako::sql::mode::listpriority',
'list-staff' => 'apps::kayako::sql::mode::liststaff',
'list-status' => 'apps::kayako::sql::mode::liststatus',
'ticket-count' => 'apps::kayako::sql::mode::ticketcount',
);
$self->{sql_modes}{psqlcmd} = 'database::postgres::psqlcmd';
'connection-time' => 'centreon::common::protocols::sql::mode::connectiontime',
'memory' => 'database::firebird::mode::memory',
'users' => 'database::firebird::mode::users',
'io-stats' => 'database::firebird::mode::iostats',
'queries' => 'database::firebird::mode::queries',
'slow-queries' => 'database::firebird::mode::slowqueries',
);
$self->{sql_modes}{firebirdcmd} = 'database::firebird::firebirdcmd';
return $self;
}
@ -48,9 +50,9 @@ sub init {
$self->{options}->add_options(
arguments => {
'host:s@' => { name => 'db_host' },
'port:s@' => { name => 'db_port' },
'database:s@' => { name => 'db_name' },
'host:s@' => { name => 'db_host' },
'port:s@' => { name => 'db_port' },
'database:s@' => { name => 'db_name' },
}
);
$self->{options}->parse_options();
@ -59,25 +61,21 @@ sub init {
if (defined($options_result->{db_host})) {
@{$self->{sqldefault}->{dbi}} = ();
@{$self->{sqldefault}->{mysqlcmd}} = ();
@{$self->{sqldefault}->{firebirdcmd}} = ();
for (my $i = 0; $i < scalar(@{$options_result->{db_host}}); $i++) {
$self->{sqldefault}->{dbi}[$i] = { data_source => 'mysql:host=' . $options_result->{db_host}[$i] };
$self->{sqldefault}->{mysqlcmd}[$i] = { host => $options_result->{db_host}[$i] };
$self->{sqldefault}->{dbi}[$i] = { data_source => 'Firebird:host=' . $options_result->{db_host}[$i] };
$self->{sqldefault}->{firebirdcmd}[$i] = { host => $options_result->{db_host}[$i] };
if (defined($options_result->{db_port}[$i])) {
$self->{sqldefault}->{dbi}[$i]->{data_source} .= ';port=' . $options_result->{db_port}[$i];
$self->{sqldefault}->{mysqlcmd}[$i]->{port} = $options_result->{db_port}[$i];
$self->{sqldefault}->{firebirdcmd}[$i]->{port} = $options_result->{db_port}[$i];
}
if (!defined($options_result->{db_name}[$i]) || $options_result->{db_name}[$i] eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify '--database' option.");
$self->{output}->option_exit();
}else{
$self->{sqldefault}->{dbi}[$i]->{data_source} .= ';database=' . $options_result->{db_name}[$i];
$self->{sqldefault}->{psqlcmd}[$i]->{dbname} = $options_result->{db_name}[$i];
}
$options_result->{db_name}[$i] = (defined($options_result->{db_name}[$i]) && $options_result->{db_name}[$i] ne '') ? $options_result->{db_name}[$i] : 'firebird';
$self->{sqldefault}->{dbi}[$i]->{data_source} .= ';database=' . $options_result->{db_name}[$i];
$self->{sqldefault}->{firebirdcmd}[$i]->{dbname} = $options_result->{db_name}[$i];
}
}
$self->SUPER::init(%options);
$self->SUPER::init(%options);
}
1;
@ -86,7 +84,11 @@ __END__
=head1 PLUGIN DESCRIPTION
Check Kayako with MySQL Server.
Check Firebird Server.
=over 8
You can use following options or options from 'sqlmode' directly.
=item B<--host>
@ -98,7 +100,7 @@ Database Server Port.
=item B<--database>
Database Name.
Path to Database. (eg:/opt/firebird/examples/empbuild/employee.fdb)
=back

View File

@ -1192,7 +1192,7 @@ To use it, add the following line at the beginning of your **mode**:
.. code-block:: perl
use centreon::plugins::httplib;
use centreon::plugins::http;
Some options must be set in **plugin.pm**:
@ -1244,7 +1244,9 @@ We suppose these options are defined :
.. code-block:: perl
my $webcontent = centreon::plugins::httplib::connect($self);
$self->{http} = centreon::plugins::http->new(output => $self->{output});
$self->{http}->set_options(%{$self->{option_results}});
my $webcontent = $self->{http}->request();
print $webcontent;
Output displays content of the webpage '\http://google.com/'.

View File

@ -635,10 +635,10 @@ Linux
Check all interface traffics in SNMP
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning if traffic in/out used > 80% and critical if traffic in/out used > 90%. It also skips errors from down interface (option ``--skip``):
Warning if traffic in/out used > 80% and critical if traffic in/out used > 90% :
::
$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=traffic --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --verbose --interface='.*' --name --regexp --skip --warning-in=80 --critical-in=90 --warning-out=80 --critical-out=90
$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=interfaces --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --verbose --interface='.*' --name --add-traffic --warning-in-traffic=80 --critical-in-traffic=90 --warning-out-traffic=80 --critical-out-traffic=90
OK: All traffic are ok | 'traffic_in_lo'=126.58b/s;0.00:8000000.00;0.00:9000000.00;0;10000000 'traffic_out_lo'=126.58b/s;0.00:8000000.00;0.00:9000000.00;0;10000000 'traffic_in_eth0'=1872.00b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000 'traffic_out_eth0'=266.32b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000 'traffic_in_eth1'=976.65b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000 'traffic_out_eth1'=1021.68b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000
Interface 'lo' Traffic In : 126.58b/s (0.00 %), Out : 126.58b/s (0.00 %)
Interface 'eth0' Traffic In : 1.87Kb/s (0.00 %), Out : 266.32b/s (0.00 %)

View File

@ -1191,7 +1191,7 @@ Pour l'utiliser, ajouter la ligne suivante au début de votre **mode** :
.. code-block:: perl
use centreon::plugins::httplib;
use centreon::plugins::http;
Certaines options doivent être spécifiées dans **plugin.pm** :
@ -1243,7 +1243,9 @@ Nous supposons que ces options sont définies :
.. code-block:: perl
my $webcontent = centreon::plugins::httplib::connect($self);
$self->{http} = centreon::plugins::http->new(output => $self->{output});
$self->{http}->set_options(%{$self->{option_results}});
my $webcontent = $self->{http}->request();
print $webcontent;
La sortie affichera le contenu de la page web '\http://google.com/'.

View File

@ -637,10 +637,10 @@ Linux
Contrôler le trafic de toutes les interfaces en SNMP
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dégradé si le trafic entrant/sortant utilisé > 80% et critique si le trafic entrant/sortant utilisé > 90%. L'exemple évite également les erreurs sur les interfaces déconnectées (option ``--skip``) :
Dégradé si le trafic entrant/sortant utilisé > 80% et critique si le trafic entrant/sortant utilisé > 90% :
::
$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=traffic --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --verbose --interface='.*' --name --regexp --skip --warning-in=80 --critical-in=90 --warning-out=80 --critical-out=90
$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=interfaces --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --verbose --interface='.*' --name --add-traffic --warning-in-traffic=80 --critical-in-traffic=90 --warning-out-traffic=80 --critical-out-traffic=90
OK: All traffic are ok | 'traffic_in_lo'=126.58b/s;0.00:8000000.00;0.00:9000000.00;0;10000000 'traffic_out_lo'=126.58b/s;0.00:8000000.00;0.00:9000000.00;0;10000000 'traffic_in_eth0'=1872.00b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000 'traffic_out_eth0'=266.32b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000 'traffic_in_eth1'=976.65b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000 'traffic_out_eth1'=1021.68b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000
Interface 'lo' Traffic In : 126.58b/s (0.00 %), Out : 126.58b/s (0.00 %)
Interface 'eth0' Traffic In : 1.87Kb/s (0.00 %), Out : 266.32b/s (0.00 %)

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,7 +36,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/index.htm?eL" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -45,9 +45,10 @@ sub new {
"warning" => { name => 'warning' },
"critical" => { name => 'critical' },
"closed" => { name => 'closed' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{status} = { closed => 'ok', opened => 'ok' };
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -63,20 +64,13 @@ sub check_options {
$self->{status}->{$label} = 'warning';
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my $contact;
if ($webcontent !~ /<body>(.*)<\/body>/msi || $1 !~ /([NW]).*?:/) {

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,8 +36,8 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"urlpath:s" => { name => 'url_path', default => "/" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path' },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
@ -45,9 +45,10 @@ sub new {
"warning" => { name => 'warning' },
"critical" => { name => 'critical' },
"dry" => { name => 'dry' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{status} = { dry => 'ok', wet => 'ok' };
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -63,20 +64,13 @@ sub check_options {
$self->{status}->{$label} = 'warning';
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my $flood;
if ($webcontent !~ /<body>(.*)<\/body>/msi || $1 !~ /(dry|wet)/i) {

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,7 +36,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/index.htm?em" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -44,8 +44,9 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -61,20 +62,13 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my $humidity;
if ($webcontent !~ /<body>(.*)<\/body>/msi || $1 !~ /HU:\s*([0-9\.]+)/i) {

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,7 +36,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/index.htm?em" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -44,8 +44,9 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -61,20 +62,13 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my $illumination;
if ($webcontent !~ /<body>(.*)<\/body>/msi || $1 !~ /IL(?:\s*:\s*|\s*)([0-9\.]+)/i) {

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,7 +36,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/index.htm?em" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -44,8 +44,9 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -61,20 +62,13 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
if ($webcontent !~ /<body>(.*)<\/body>/msi || $1 !~ /T([CF]):\s*([0-9\.]+)/i) {
$self->{output}->add_option_msg(short_msg => "Could not find temperature information.");

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,7 +36,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/index.htm?eR" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -44,8 +44,9 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -61,20 +62,13 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
if ($webcontent !~ /<body>(.*)<\/body>/msi || $1 !~ /R([CF])\s*([0-9\.]+)/i) {
$self->{output}->add_option_msg(short_msg => "Could not find thermistor temperature information.");

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::httplib;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
@ -36,7 +36,7 @@ sub new {
{
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto', default => "http" },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/index.htm?ev" },
"credentials" => { name => 'credentials' },
"username:s" => { name => 'username' },
@ -44,8 +44,9 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(output => $self->{output});
return $self;
}
@ -61,20 +62,13 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
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();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = centreon::plugins::httplib::connect($self);
my $webcontent = $self->{http}->request();
my $voltage;
if ($webcontent !~ /<body>(.*)<\/body>/msi || $1 !~ /CV\s*([0-9\.]+)/i) {

View File

@ -1,86 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::battery;
use strict;
use warnings;
my %status = (
1 => ['other', 'CRITICAL'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
my %reading = (
1 => 'Predictive Failure',
2 => 'Failed',
4 => 'Presence Detected',
);
sub check {
my ($self) = @_;
# In MIB '10892.mib'
$self->{output}->output_add(long_msg => "Checking batteries");
$self->{components}->{battery} = {name => 'batteries', total => 0};
return if ($self->check_exclude('battery'));
my $oid_batteryStatus = '.1.3.6.1.4.1.674.10892.1.600.50.1.5';
my $oid_batteryReading = '.1.3.6.1.4.1.674.10892.1.600.50.1.6';
my $oid_batteryLocationName = '.1.3.6.1.4.1.674.10892.1.600.50.1.7';
my $result = $self->{snmp}->get_table(oid => $oid_batteryStatus);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_batteryReading, $oid_batteryLocationName],
instances => [keys %$result],
instance_regexp => '(\d+\.\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)\.(\d+)$/;
my ($chassis_Index, $battery_Index) = ($1, $2);
my $instance = $chassis_Index . '.' . $battery_Index;
my $battery_status = $result->{$key};
my $battery_reading = $result2->{$oid_batteryReading . '.' . $instance};
my $battery_locationName = $result2->{$oid_batteryLocationName . '.' . $instance};
$self->{components}->{battery}->{total}++;
$self->{output}->output_add(long_msg => sprintf("battery %d status is %s, reading is %s [location: %s].",
$battery_Index, ${$status{$battery_status}}[0], $reading{$battery_reading},
$battery_locationName
));
if ($battery_status != 3) {
$self->{output}->output_add(severity => ${$status{$battery_status}}[1],
short_msg => sprintf("battery %d status is %s",
$battery_Index, ${$status{$battery_status}}[0]));
}
}
}
1;

View File

@ -1,108 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::cachebattery;
use strict;
use warnings;
my %state = (
0 => 'unknown',
1 => 'ready',
2 => 'failed',
6 => 'degraded',
7 => 'reconditioning',
9 => 'high',
10 => 'powerLow',
12 => 'charging',
21 => 'missing',
36 => 'learning',
);
my %componentStatus = (
1 => ['other', 'UNKNOWN'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
my %learnState = (
1 => 'failed',
2 => 'active',
4 => 'timedOut',
8 => 'requested',
16 => 'idle',
32 => 'due',
);
my %predictedCapacity = (
1 => 'failed',
2 => 'ready',
4 => 'unknown',
);
sub check {
my ($self) = @_;
# In MIB '10893.mib'
$self->{output}->output_add(long_msg => "Checking cache batteries");
$self->{components}->{cachebattery} = {name => 'cache batteries', total => 0};
return if ($self->check_exclude('cachebattery'));
my $oid_batteryState = '.1.3.6.1.4.1.674.10893.1.20.130.15.1.4';
my $oid_batteryComponentStatus = '.1.3.6.1.4.1.674.10893.1.20.130.15.1.6';
my $oid_batteryPredictedCapicity = '.1.3.6.1.4.1.674.10893.1.20.130.15.1.10';
my $oid_batteryLearnState = '.1.3.6.1.4.1.674.10893.1.20.130.15.1.12';
my $result = $self->{snmp}->get_table(oid => $oid_batteryState);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_batteryComponentStatus, $oid_batteryPredictedCapicity, $oid_batteryLearnState],
instances => [keys %$result],
instance_regexp => '(\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)$/;
my $battery_Index = $1;
my $battery_State = $result->{$key};
my $battery_ComponentStatus = $result2->{$oid_batteryComponentStatus . '.' . $battery_Index};
my $battery_PredictedCapacity = $result2->{$oid_batteryPredictedCapicity . '.' . $battery_Index};
my $battery_LearnState = $result2->{$oid_batteryLearnState . '.' . $battery_Index};
$self->{components}->{cachebattery}->{total}++;
$self->{output}->output_add(long_msg => sprintf("cache battery %d status is %s, state is %s, learn state is %s, predicted capacity is %s.",
$battery_Index, ${$componentStatus{$battery_ComponentStatus}}[0], $state{$battery_State},
$learnState{$battery_LearnState}, $predictedCapacity{$battery_PredictedCapacity}
));
if ($battery_ComponentStatus != 3) {
$self->{output}->output_add(severity => ${$componentStatus{$battery_ComponentStatus}}[1],
short_msg => sprintf("cache battery %d status is %s",
$battery_Index, ${$componentStatus{$battery_ComponentStatus}}[0]));
}
}
}
1;

View File

@ -1,100 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::connector;
use strict;
use warnings;
my %state = (
0 => 'unknown',
1 => 'ready',
2 => 'failed',
3 => 'online',
4 => 'offline',
6 => 'degraded',
);
my %status = (
1 => ['other', 'UNKNOWN'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
my %busType = (
1 => 'SCSI',
2 => 'IDE',
3 => 'Fibre Channel',
4 => 'SSA',
6 => 'USB',
7 => 'SATA',
8 => 'SAS',
);
sub check {
my ($self) = @_;
# In MIB '10893.mib'
$self->{output}->output_add(long_msg => "Checking Connectors (Channels)");
$self->{components}->{connector} = {name => 'connectors', total => 0};
return if ($self->check_exclude('connector'));
my $oid_channelName = '.1.3.6.1.4.1.674.10893.1.20.130.2.1.2';
my $oid_channelState = '.1.3.6.1.4.1.674.10893.1.20.130.2.1.3';
my $oid_channelComponentStatus = '.1.3.6.1.4.1.674.10893.1.20.130.2.1.8';
my $oid_channelBusType = '.1.3.6.1.4.1.674.10893.1.20.130.2.1.11';
my $result = $self->{snmp}->get_table(oid => $oid_channelName);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_channelState, $oid_channelComponentStatus, $oid_channelBusType],
instances => [keys %$result],
instance_regexp => '(\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)$/;
my $channel_Index = $1;
my $channel_name = $result->{$key};
my $channel_state = $result2->{$oid_channelState . '.' . $channel_Index};
my $channel_componentStatus = $result2->{$oid_channelComponentStatus . '.' . $channel_Index};
my $channel_busType = $result2->{$oid_channelBusType . '.' . $channel_Index};
$self->{components}->{connector}->{total}++;
$self->{output}->output_add(long_msg => sprintf("connector '%s' status is '%s', state is '%s' [index: %d, bus: %s].",
$channel_name, ${$status{$channel_componentStatus}}[0], $state{$channel_state},
$channel_Index, $busType{$channel_busType}
));
if ($channel_componentStatus != 3) {
$self->{output}->output_add(severity => ${$status{$channel_componentStatus}}[1],
short_msg => sprintf("connector '%s' status is '%s' [index: %d, bus: %s]",
$channel_name, ${$status{$channel_componentStatus}}[0], $channel_Index, $busType{$channel_busType}));
}
}
}
1;

View File

@ -1,90 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::controller;
use strict;
use warnings;
my %state = (
0 => 'unknown',
1 => 'ready',
2 => 'failed',
3 => 'online',
4 => 'offline',
6 => 'degraded',
);
my %status = (
1 => ['other', 'UNKNOWN'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
sub check {
my ($self) = @_;
# In MIB '10893.mib'
$self->{output}->output_add(long_msg => "Checking Controllers");
$self->{components}->{controller} = {name => 'controllers', total => 0};
return if ($self->check_exclude('controller'));
my $oid_controllerName = '.1.3.6.1.4.1.674.10893.1.20.130.1.1.2';
my $oid_controllerState = '.1.3.6.1.4.1.674.10893.1.20.130.1.1.5';
my $oid_controllerComponentStatus = '.1.3.6.1.4.1.674.10893.1.20.130.1.1.38';
my $oid_controllerFWVersion = '.1.3.6.1.4.1.674.10893.1.20.130.1.1.8';
my $result = $self->{snmp}->get_table(oid => $oid_controllerName);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_controllerState, $oid_controllerComponentStatus, $oid_controllerFWVersion],
instances => [keys %$result],
instance_regexp => '(\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)$/;
my $controller_Index = $1;
my $controller_name = $result->{$key};
my $controller_state = $result2->{$oid_controllerState . '.' . $controller_Index};
my $controller_componentStatus = $result2->{$oid_controllerComponentStatus . '.' . $controller_Index};
my $controller_FWVersion = $result2->{$oid_controllerFWVersion . '.' . $controller_Index};
$self->{components}->{controller}->{total}++;
$self->{output}->output_add(long_msg => sprintf("controller '%s' status is '%s', state is '%s' [index: %d, firmware: %s].",
$controller_name, ${$status{$controller_componentStatus}}[0], $state{$controller_state},
$controller_Index, $controller_FWVersion
));
if ($controller_componentStatus != 3) {
$self->{output}->output_add(severity => ${$status{$controller_componentStatus}}[1],
short_msg => sprintf("controller '%s' status is '%s' [index: %d]",
$controller_name, ${$status{$controller_componentStatus}}[0], $controller_Index));
}
}
}
1;

View File

@ -1,107 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::cpu;
use strict;
use warnings;
my %status = (
1 => ['other', 'CRITICAL'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
my %statusState = (
1 => 'other',
2 => 'unknown',
3 => 'enabled',
4 => 'userDisabled',
5 => 'biosDisabled',
6 => 'idle',
);
my %statusReading = (
1 => 'internalError',
2 => 'thermalTrip',
32 => 'configurationError',
128 => 'Present',
256 => 'Disabled',
512 => 'terminatorPresent',
1024 => 'throttled',
);
sub check {
my ($self) = @_;
# In MIB '10892.mib'
$self->{output}->output_add(long_msg => "Checking Processor Units");
$self->{components}->{cpu} = {name => 'CPUs', total => 0};
return if ($self->check_exclude('cpu'));
my $oid_cpuStatus = '.1.3.6.1.4.1.674.10892.1.1100.30.1.5';
my $oid_cpuManufacturerName = '.1.3.6.1.4.1.674.10892.1.1100.30.1.8';
my $oid_cpuStatusState = '.1.3.6.1.4.1.674.10892.1.1100.30.1.9';
my $oid_cpuCurrentSpeed = '.1.3.6.1.4.1.674.10892.1.1100.30.1.12';
my $oid_cpuBrandName = '.1.3.6.1.4.1.674.10892.1.1100.30.1.23';
my $oid_cpuChassis = '.1.3.6.1.4.1.674.10892.1.1100.32.1.1';
my $oid_cpuStatusReading = '.1.3.6.1.4.1.674.10892.1.1100.32.1.6';
my $result = $self->{snmp}->get_table(oid => $oid_cpuStatus);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_cpuManufacturerName, $oid_cpuStatusState, $oid_cpuCurrentSpeed, $oid_cpuBrandName, $oid_cpuChassis, $oid_cpuStatusReading],
instances => [keys %$result],
instance_regexp => '(\d+\.\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)\.(\d+)$/;
my ($chassis_Index, $cpu_Index) = ($1, $2);
my $instance = $chassis_Index . '.' . $cpu_Index;
my $cpu_Status = $result->{$key};
my $cpu_ManufacturerName = $result2->{$oid_cpuManufacturerName . '.' . $instance};
my $cpu_StatusState = $result2->{$oid_cpuStatusState . '.' . $instance};
my $cpu_CurrentSpeed = $result2->{$oid_cpuCurrentSpeed . '.' . $instance};
my $cpu_BrandName = $result2->{$oid_cpuBrandName . '.' . $instance};
my $cpu_Chassis = $result2->{$oid_cpuChassis . '.' . $instance};
my $cpu_StatusReading = $result2->{$oid_cpuStatusReading . '.' . $instance};
$self->{components}->{cpu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("cpu %d status is %s, state is %s, current speed is %d MHz [model: %s].",
$cpu_Index, ${$status{$cpu_Status}}[0], $statusState{$cpu_StatusState},
$cpu_CurrentSpeed, $cpu_BrandName
));
if ($cpu_Status != 3) {
$self->{output}->output_add(severity => ${$status{$cpu_Status}}[1],
short_msg => sprintf("cpu %d status is %s",
$cpu_Index, ${$status{$cpu_Status}}[0]));
}
}
}
1;

View File

@ -1,58 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::esmlog;
use strict;
use warnings;
my %status = (
1 => ['other', 'CRITICAL'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
sub check {
my ($self) = @_;
# In MIB '10892.mib'
$self->{output}->output_add(long_msg => "Checking ESM log filling");
$self->{components}->{esmlog} = {name => 'ESM log', total => 0};
return if ($self->check_exclude('esmlog'));
my $oid_eventLogStatus = '.1.3.6.1.4.1.674.10892.1.200.10.1.41.1';
my $result = $self->{snmp}->get_leef(oids => [$oid_eventLogStatus], nothing_quit => 1);
$self->{components}->{esmlog}->{total}++;
$self->{output}->output_add(long_msg => sprintf("ESM log status is '%s'.",
${$status{$result->{$oid_eventLogStatus}}}[0]
));
if ($result->{$oid_eventLogStatus} != 3) {
$self->{output}->output_add(severity => ${$status{$result->{$oid_eventLogStatus}}}[1],
short_msg => sprintf("ESM log status is '%s'",
${$status{$result->{$oid_eventLogStatus}}}[0]));
}
}
1;

View File

@ -1,83 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::fan;
use strict;
use warnings;
my %status = (
1 => ['other', 'CRITICAL'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCriticalUpper', 'WARNING'],
5 => ['criticalUpper', 'CRITICAL'],
6 => ['nonRecoverableUpper', 'CRITICAL'],
7 => ['nonCriticalLower', 'WARNING'],
8 => ['criticalLower', 'CRITICAL'],
9 => ['nonRecoverableLower', 'CRITICAL'],
10 => ['failed', 'CRITICAL']
);
sub check {
my ($self) = @_;
# In MIB '10892.mib'
$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = {name => 'fans', total => 0};
return if ($self->check_exclude('fan'));
my $oid_coolingDeviceStatus = '.1.3.6.1.4.1.674.10892.1.700.12.1.5';
my $oid_coolingDeviceReading = '.1.3.6.1.4.1.674.10892.1.700.12.1.6';
my $oid_coolingDeviceLocationName = '.1.3.6.1.4.1.674.10892.1.700.12.1.8';
my $result = $self->{snmp}->get_table(oid => $oid_coolingDeviceStatus);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_coolingDeviceReading, $oid_coolingDeviceLocationName],
instances => [keys %$result],
instance_regexp => '(\d+\.\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)\.(\d+)$/;
my ($chassis_Index, $fan_Index) = ($1, $2);
my $instance = $chassis_Index . '.' . $fan_Index;
my $fan_Status = $result->{$key};
my $fan_Reading = $result2->{$oid_coolingDeviceReading . '.' . $instance};
my $fan_LocationName = $result2->{$oid_coolingDeviceLocationName . '.' . $instance};
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan %d status is %s, speed is %d RPM [location: %s].",
$fan_Index, ${$status{$fan_Status}}[0], $fan_Reading,
$fan_LocationName
));
if ($fan_Status != 3) {
$self->{output}->output_add(severity => ${$status{$fan_Status}}[1],
short_msg => sprintf("fan %d status is %s",
$fan_Index, ${$status{$fan_Status}}[0]));
}
}
}
1;

View File

@ -1,56 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::globalstatus;
use strict;
use warnings;
my %status = (
1 => ['other', 'CRITICAL'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
sub check {
my ($self) = @_;
# In MIB '10892.mib'
$self->{output}->output_add(long_msg => "Checking global system status");
return if ($self->check_exclude('globalstatus'));
my $oid_globalSystemStatus = '.1.3.6.1.4.1.674.10892.1.200.10.1.2.1';
my $result = $self->{snmp}->get_leef(oids => [$oid_globalSystemStatus], nothing_quit => 1);
$self->{output}->output_add(long_msg => sprintf("Overall global status is '%s'.",
${$status{$result->{$oid_globalSystemStatus}}}[0]
));
if ($result->{$oid_globalSystemStatus} != 3) {
$self->{output}->output_add(severity => ${$status{$result->{$oid_globalSystemStatus}}}[1],
short_msg => sprintf("Overall global status is '%s'",
${$status{$result->{$oid_globalSystemStatus}}}[0]));
}
}
1;

View File

@ -1,121 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::logicaldrive;
use strict;
use warnings;
my %state = (
0 => 'unknown',
1 => 'ready',
2 => 'failed',
3 => 'online',
4 => 'offline',
6 => 'degraded',
15 => 'resynching',
24 => 'rebuild',
26 => 'formatting',
35 => 'initializing',
);
my %layout = (
1 => 'Concatened',
2 => 'RAID-0',
3 => 'RAID-1',
4 => 'RAID-2',
5 => 'RAID-3',
6 => 'RAID-4',
7 => 'RAID-5',
8 => 'RAID-6',
9 => 'RAID-7',
10 => 'RAID-10',
11 => 'RAID-30',
12 => 'RAID-50',
13 => 'Add spares',
14 => 'Delete logical',
15 => 'Transform logical',
18 => 'RAID-0-plus-1 - Mylex only',
19 => 'Concatened RAID 1',
20 => 'Concatened RAID 5',
21 => 'no RAID',
22 => 'RAID Morph - Adapted only',
);
my %componentStatus = (
1 => ['other', 'UNKNOWN'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
sub check {
my ($self) = @_;
# In MIB '10893.mib'
$self->{output}->output_add(long_msg => "Checking Logical Drives");
$self->{components}->{logicaldrive} = {name => 'logical drives', total => 0};
return if ($self->check_exclude('logicaldrive'));
my $oid_diskName = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.2';
my $oid_diskDeviceName = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.3';
my $oid_diskState = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.4';
my $oid_diskLengthInMB = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.6';
my $oid_diskLayout = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.13';
my $oid_diskComponentStatus = '.1.3.6.1.4.1.674.10893.1.20.140.1.1.20';
my $result = $self->{snmp}->get_table(oid => $oid_diskName);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_diskDeviceName, $oid_diskState, $oid_diskLengthInMB, $oid_diskLayout, $oid_diskComponentStatus],
instances => [keys %$result],
instance_regexp => '(\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)$/;
my $disk_Index = $1;
my $disk_Name = $result->{$key};
my $disk_DeviceName = $result2->{$oid_diskDeviceName . '.' . $disk_Index};
my $disk_State = $result2->{$oid_diskState . '.' . $disk_Index};
my $disk_LengthInMB = $result2->{$oid_diskLengthInMB . '.' . $disk_Index};
my $disk_Layout = $result2->{$oid_diskLayout . '.' . $disk_Index};
my $disk_ComponentStatus = $result2->{$oid_diskComponentStatus . '.' . $disk_Index};
$self->{components}->{logicaldrive}->{total}++;
$self->{output}->output_add(long_msg => sprintf("logical drive %s status is %s, state is %s, layout is %s, size is %d MB [device: %s, index: %d].",
$disk_Name, ${$componentStatus{$disk_ComponentStatus}}[0], $state{$disk_State},
$layout{$disk_Layout}, $disk_LengthInMB, $disk_DeviceName, $disk_Index
));
if ($disk_ComponentStatus != 3) {
$self->{output}->output_add(severity => ${$componentStatus{$disk_ComponentStatus}}[1],
short_msg => sprintf("logical drive %s status is %s [device: %s, index: %d]",
$disk_Name, ${$componentStatus{$disk_ComponentStatus}}[0], $disk_DeviceName, $disk_Index));
}
}
}
1;

View File

@ -1,91 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::memory;
use strict;
use warnings;
my %status = (
1 => ['other', 'CRITICAL'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
my %failureModes = (
0 => 'Not failure',
1 => 'ECC single bit correction warning rate exceeded',
2 => 'ECC single bit correction failure rate exceeded',
4 => 'ECC multibit fault encountered',
8 => 'ECC single bit correction logging disabled',
16 => 'device disabled because of spare activation',
);
sub check {
my ($self) = @_;
# In MIB '10892.mib'
$self->{output}->output_add(long_msg => "Checking Memory Modules");
$self->{components}->{memory} = {name => 'memory modules', total => 0};
return if ($self->check_exclude('memory'));
my $oid_memoryDeviceStatus = '.1.3.6.1.4.1.674.10892.1.1100.50.1.5';
my $oid_memoryDeviceLocationName = '.1.3.6.1.4.1.674.10892.1.1100.50.1.8';
my $oid_memoryDeviceSize = '.1.3.6.1.4.1.674.10892.1.1100.50.1.14';
my $oid_memoryDeviceFailureModes = '.1.3.6.1.4.1.674.10892.1.1100.50.1.20';
my $result = $self->{snmp}->get_table(oid => $oid_memoryDeviceStatus);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_memoryDeviceLocationName, $oid_memoryDeviceSize, $oid_memoryDeviceFailureModes],
instances => [keys %$result],
instance_regexp => '(\d+\.\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)\.(\d+)$/;
my ($chassis_Index, $memory_Index) = ($1, $2);
my $instance = $chassis_Index . '.' . $memory_Index;
my $memory_deviceStatus = $result->{$key};
my $memory_deviceLocationName = $result2->{$oid_memoryDeviceLocationName . '.' . $instance};
my $memory_deviceSize = $result2->{$oid_memoryDeviceSize . '.' . $instance};
my $memory_deviceFailureModes = $result2->{$oid_memoryDeviceFailureModes . '.' . $instance};
$self->{components}->{memory}->{total}++;
$self->{output}->output_add(long_msg => sprintf("memory module %d status is %s, failure mode is %s, size is %d KB [location: %s].",
$memory_Index, ${$status{$memory_deviceStatus}}[0], $failureModes{$memory_deviceFailureModes},
$memory_deviceSize, $memory_deviceLocationName
));
if ($memory_deviceStatus != 3) {
$self->{output}->output_add(severity => ${$status{$memory_deviceStatus}}[1],
short_msg => sprintf("memory module %d status is %s",
$memory_Index, ${$status{$memory_deviceStatus}}[0]));
}
}
}
1;

View File

@ -1,122 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::physicaldisk;
use strict;
use warnings;
my %state = (
0 => 'unknown',
1 => 'ready',
2 => 'failed',
3 => 'online',
4 => 'offline',
6 => 'degraded',
7 => 'recovering',
11 => 'removed',
15 => 'resynching',
24 => 'rebuild',
25 => 'noMedia',
26 => 'formatting',
28 => 'diagnostics',
35 => 'initializing',
);
my %spareState = (
1 => 'memberVD',
2 => 'memberDG',
3 => 'globalHostSpare',
4 => 'dedicatedHostSpare',
5 => 'notASpare',
);
my %componentStatus = (
1 => ['other', 'UNKNOWN'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
my %smartAlertIndication = (
1 => ['no', 'OK'],
2 => ['yes', 'WARNING'],
);
sub check {
my ($self) = @_;
# In MIB '10893.mib'
$self->{output}->output_add(long_msg => "Checking Physical Disks");
$self->{components}->{physicaldisk} = {name => 'physical disks', total => 0};
return if ($self->check_exclude('physicaldisk'));
my $oid_diskName = '.1.3.6.1.4.1.674.10893.1.20.130.4.1.2';
my $oid_diskState = '.1.3.6.1.4.1.674.10893.1.20.130.4.1.4';
my $oid_diskLengthInMB = '.1.3.6.1.4.1.674.10893.1.20.130.4.1.11';
my $oid_diskSpareState = '.1.3.6.1.4.1.674.10893.1.20.130.4.1.22';
my $oid_diskComponentStatus = '.1.3.6.1.4.1.674.10893.1.20.130.4.1.24';
my $oid_diskSmartAlertIndication = '.1.3.6.1.4.1.674.10893.1.20.130.4.1.31';
my $result = $self->{snmp}->get_table(oid => $oid_diskName);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_diskState, $oid_diskLengthInMB, $oid_diskSpareState, $oid_diskComponentStatus, $oid_diskSmartAlertIndication],
instances => [keys %$result],
instance_regexp => '(\d+\.\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)\.(\d+)$/;
my ($chassis_Index, $disk_Index) = ($1, $2);
my $instance = $chassis_Index . '.' . $disk_Index;
my $disk_Name = $result->{$key};
my $disk_State = $result2->{$oid_diskState . '.' . $instance};
my $disk_LengthInMB = $result2->{$oid_diskLengthInMB . '.' . $instance};
my $disk_SpareState = $result2->{$oid_diskSpareState . '.' . $instance};
my $disk_ComponentStatus = $result2->{$oid_diskComponentStatus . '.' . $instance};
my $disk_SmartAlertIndication = $result2->{$oid_diskSmartAlertIndication . '.' . $instance};
$self->{components}->{physicaldisk}->{total}++;
$self->{output}->output_add(long_msg => sprintf("physical disk '%s' status is %s, state is %s, predictive failure alert %s, spare state is %s, size is %d MB [index: %d].",
$disk_Name, ${$componentStatus{$disk_ComponentStatus}}[0], $state{$disk_State}, ${$smartAlertIndication{$disk_SmartAlertIndication}}[0],
$spareState{$disk_SpareState}, $disk_LengthInMB, $disk_Index
));
if ($disk_SmartAlertIndication !=1) {
$self->{output}->output_add(severity => ${$smartAlertIndication{$disk_SmartAlertIndication}}[1],
short_msg => sprintf("physical disk '%s' has received a predictive failure alert [index: %d]",
$disk_Name, $disk_Index));
}
if ($disk_ComponentStatus != 3) {
$self->{output}->output_add(severity => ${$componentStatus{$disk_ComponentStatus}}[1],
short_msg => sprintf("physical disk '%s' status is %s [index: %d]",
$disk_Name, ${$componentStatus{$disk_ComponentStatus}}[0], $disk_Index));
}
}
}
1;

View File

@ -1,111 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::psu;
use strict;
use warnings;
my %status = (
1 => ['other', 'CRITICAL'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
my %type = (
1 => 'other',
2 => 'unknown',
3 => 'Linear',
4 => 'switching',
5 => 'Battery',
6 => 'UPS',
7 => 'Converter',
8 => 'Regulator',
9 => 'AC',
10 => 'DC',
11 => 'VRM',
);
my %state = (
1 => 'present',
2 => 'failure',
4 => 'predictiveFailure',
8 => 'ACLost',
16 => 'ACLostOrOutOfRange',
32 => 'ACPresentButOutOfRange',
64 => 'configurationError',
);
my %ConfigurationErrorType = (
1 => 'vendorMismatch',
2 => 'revisionMismatch',
3 => 'processorMissing',
);
sub check {
my ($self) = @_;
# In MIB '10892.mib'
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'power supplies', total => 0};
return if ($self->check_exclude('psu'));
my $oid_powerSupplyStatus = '.1.3.6.1.4.1.674.10892.1.600.12.1.5';
my $oid_powerSupplyType = '.1.3.6.1.4.1.674.10892.1.600.12.1.7';
my $oid_powerSupplySensorState = '.1.3.6.1.4.1.674.10892.1.600.12.1.11';
my $oid_powerSupplyConfigurationErrorType = '.1.3.6.1.4.1.674.10892.1.600.12.1.12';
my $result = $self->{snmp}->get_table(oid => $oid_powerSupplyStatus);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_powerSupplyType, $oid_powerSupplySensorState, $oid_powerSupplyConfigurationErrorType],
instances => [keys %$result],
instance_regexp => '(\d+\.\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)\.(\d+)$/;
my ($chassis_Index, $psu_Index) = ($1, $2);
my $instance = $chassis_Index . '.' . $psu_Index;
my $psu_Status = $result->{$key};
my $psu_Type = $result2->{$oid_powerSupplyType . '.' . $instance};
my $psu_SensorState = $result2->{$oid_powerSupplySensorState . '.' . $instance};
my $psu_ConfigurationErrorType = $result2->{$oid_powerSupplyConfigurationErrorType . '.' . $instance};
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("psu %d status is %s, state is %s [type: %s].",
$psu_Index, ${$status{$psu_Status}}[0], $state{$psu_SensorState},
$type{$psu_Type}
));
if ($psu_Status != 3) {
$self->{output}->output_add(severity => ${$status{$psu_Status}}[1],
short_msg => sprintf("psu %d status is %s",
$psu_Index, ${$status{$psu_Status}}[0]));
}
}
}
1;

View File

@ -1,100 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::components::temperature;
use strict;
use warnings;
my %status = (
1 => ['other', 'CRITICAL'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCriticalUpper', 'WARNING'],
5 => ['criticalUpper', 'CRITICAL'],
6 => ['nonRecoverableUpper', 'CRITICAL'],
7 => ['nonCriticalLower', 'WARNING'],
8 => ['criticalLower', 'CRITICAL'],
9 => ['nonRecoverableLower', 'CRITICAL'],
10 => ['failed', 'CRITICAL'],
);
my %type = (
1 => 'other',
2 => 'unknown',
3 => 'Ambient ESM',
4 => 'Discrete',
);
my %discreteReading = (
1 => 'good',
2 => 'bad',
);
sub check {
my ($self) = @_;
# In MIB '10892.mib'
$self->{output}->output_add(long_msg => "Checking temperature probes");
$self->{components}->{temperature} = {name => 'temperature probes', total => 0};
return if ($self->check_exclude('temperature'));
my $oid_temperatureProbeStatus = '.1.3.6.1.4.1.674.10892.1.700.20.1.5';
my $oid_temperatureProbeReading = '.1.3.6.1.4.1.674.10892.1.700.20.1.6';
my $oid_temperatureProbeType = '.1.3.6.1.4.1.674.10892.1.700.20.1.7';
my $oid_temperatureProbeLocationName = '.1.3.6.1.4.1.674.10892.1.700.20.1.8';
my $result = $self->{snmp}->get_table(oid => $oid_temperatureProbeStatus);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_temperatureProbeReading, $oid_temperatureProbeType, $oid_temperatureProbeLocationName],
instances => [keys %$result],
instance_regexp => '(\d+\.\d+)$');
my $result2 = $self->{snmp}->get_leef();
return if (scalar(keys %$result2) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)\.(\d+)$/;
my ($chassis_Index, $temperature_Index) = ($1, $2);
my $instance = $chassis_Index . '.' . $temperature_Index;
my $temperature_Status = $result->{$key};
my $temperature_Reading = $result2->{$oid_temperatureProbeReading . '.' . $instance};
my $temperature_Type = $result2->{$oid_temperatureProbeType . '.' . $instance};
my $temperature_LocationName = $result2->{$oid_temperatureProbeLocationName . '.' . $instance};
my $temperature_Reading2 = $temperature_Reading/10;
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("temperature probe %d status is %s, temperature is %.1f °C [location: %s].",
$temperature_Index, ${$status{$temperature_Status}}[0], $temperature_Reading2,
$temperature_LocationName
));
if ($temperature_Status != 3) {
$self->{output}->output_add(severity => ${$status{$temperature_Status}}[1],
short_msg => sprintf("temperature probe %d status is %s",
$temperature_Index, ${$status{$temperature_Status}}[0]));
}
}
}
1;

View File

@ -1,247 +0,0 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::mode::hardware;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
use hardware::server::dell::openmanage::mode::components::globalstatus;
use hardware::server::dell::openmanage::mode::components::fan;
use hardware::server::dell::openmanage::mode::components::psu;
use hardware::server::dell::openmanage::mode::components::temperature;
use hardware::server::dell::openmanage::mode::components::cpu;
use hardware::server::dell::openmanage::mode::components::cachebattery;
use hardware::server::dell::openmanage::mode::components::memory;
use hardware::server::dell::openmanage::mode::components::physicaldisk;
use hardware::server::dell::openmanage::mode::components::logicaldrive;
use hardware::server::dell::openmanage::mode::components::esmlog;
use hardware::server::dell::openmanage::mode::components::battery;
use hardware::server::dell::openmanage::mode::components::controller;
use hardware::server::dell::openmanage::mode::components::connector;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"exclude:s" => { name => 'exclude' },
"component:s" => { name => 'component', default => 'all' },
});
$self->{product_name} = undef;
$self->{components} = {};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub global {
my ($self, %options) = @_;
$self->get_system_information();
hardware::server::dell::openmanage::mode::components::globalstatus::check($self);
hardware::server::dell::openmanage::mode::components::fan::check($self);
hardware::server::dell::openmanage::mode::components::psu::check($self);
hardware::server::dell::openmanage::mode::components::temperature::check($self);
hardware::server::dell::openmanage::mode::components::cpu::check($self);
hardware::server::dell::openmanage::mode::components::cachebattery::check($self);
hardware::server::dell::openmanage::mode::components::memory::check($self);
hardware::server::dell::openmanage::mode::components::physicaldisk::check($self);
hardware::server::dell::openmanage::mode::components::logicaldrive::check($self);
hardware::server::dell::openmanage::mode::components::esmlog::check($self);
hardware::server::dell::openmanage::mode::components::battery::check($self);
hardware::server::dell::openmanage::mode::components::controller::check($self);
hardware::server::dell::openmanage::mode::components::connector::check($self);
my $total_components = 0;
my $display_by_component = '';
my $display_by_component_append = '';
foreach my $comp (keys %{$self->{components}}) {
# Skipping short msg when no components
next if ($self->{components}->{$comp}->{total} == 0);
$total_components += $self->{components}->{$comp}->{total};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $self->{components}->{$comp}->{name};
$display_by_component_append = ', ';
}
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("All %s components [%s] are ok - Product Name: %s",
$total_components,
$display_by_component,
$self->{product_name})
);
}
sub globalstatus {
my %status = (
1 => ['other', 'CRITICAL'],
2 => ['unknown', 'UNKNOWN'],
3 => ['ok', 'OK'],
4 => ['nonCritical', 'WARNING'],
5 => ['critical', 'CRITICAL'],
6 => ['nonRecoverable', 'CRITICAL'],
);
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking global system status");
return if ($self->check_exclude('globalstatus'));
my $oid_globalSystemStatus = '.1.3.6.1.4.1.674.10892.1.200.10.1.2.1';
my $result = $self->{snmp}->get_leef(oids => [$oid_globalSystemStatus], nothing_quit => 1);
$self->{output}->output_add(long_msg => sprintf("Overall global status is '%s'.",
${$status{$result->{$oid_globalSystemStatus}}}[0]
));
$self->{output}->output_add(severity => ${$status{$result->{$oid_globalSystemStatus}}}[1],
short_msg => sprintf("Overall global status is '%s'",
${$status{$result->{$oid_globalSystemStatus}}}[0]));
}
sub component {
my ($self, %options) = @_;
if ($self->{option_results}->{component} eq 'globalstatus') {
hardware::server::dell::openmanage::mode::components::globalstatus::check($self);
} elsif ($self->{option_results}->{component} eq 'fan') {
hardware::server::dell::openmanage::mode::components::fan::check($self);
} elsif ($self->{option_results}->{component} eq 'psu') {
hardware::server::dell::openmanage::mode::components::psu::check($self);
} elsif ($self->{option_results}->{component} eq 'temperature') {
hardware::server::dell::openmanage::mode::components::temperature::check($self);
} elsif ($self->{option_results}->{component} eq 'cpu') {
hardware::server::dell::openmanage::mode::components::cpu::check($self);
} elsif ($self->{option_results}->{component} eq 'cachebattery') {
hardware::server::dell::openmanage::mode::components::cachebattery::check($self);
} elsif ($self->{option_results}->{component} eq 'memory') {
hardware::server::dell::openmanage::mode::components::memory::check($self);
} elsif ($self->{option_results}->{component} eq 'physicaldisk') {
hardware::server::dell::openmanage::mode::components::physicaldisk::check($self);
} elsif ($self->{option_results}->{component} eq 'logicaldrive') {
hardware::server::dell::openmanage::mode::components::logicaldrive::check($self);
} elsif ($self->{option_results}->{component} eq 'esmlog') {
hardware::server::dell::openmanage::mode::components::esmlog::check($self);
} elsif ($self->{option_results}->{component} eq 'battery') {
hardware::server::dell::openmanage::mode::components::battery::check($self);
} elsif ($self->{option_results}->{component} eq 'controller') {
hardware::server::dell::openmanage::mode::components::controller::check($self);
} elsif ($self->{option_results}->{component} eq 'connector') {
hardware::server::dell::openmanage::mode::components::connector::check($self);
} elsif ($self->{option_results}->{component} eq 'storage') {
hardware::server::dell::openmanage::mode::components::physicaldisk::check($self);
hardware::server::dell::openmanage::mode::components::logicaldrive::check($self);
hardware::server::dell::openmanage::mode::components::cachebattery::check($self);
hardware::server::dell::openmanage::mode::components::controller::check($self);
hardware::server::dell::openmanage::mode::components::connector::check($self);
hardware::server::dell::openmanage::mode::components::cachebattery::check($self);
}else {
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
$self->{output}->option_exit();
}
my $total_components = 0;
my $display_by_component = '';
my $display_by_component_append = '';
foreach my $comp (sort(keys %{$self->{components}})) {
# Skipping short msg when no components
next if ($self->{components}->{$comp}->{total} == 0);
$total_components += $self->{components}->{$comp}->{total};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $self->{components}->{$comp}->{name};
$display_by_component_append = ', ';
}
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("All %s components [%s] are ok.",
$total_components,
$display_by_component)
);
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
if ($self->{option_results}->{component} eq 'all') {
$self->global();
} elsif ($self->{option_results}->{component} eq 'globalstatus') {
$self->globalstatus();
} else {
$self->component();
}
$self->{output}->display();
$self->{output}->exit();
}
sub get_system_information {
my ($self) = @_;
# In '10892-MIB'
my $oid_chassisModelName = ".1.3.6.1.4.1.674.10892.1.300.10.1.9.1";
my $result = $self->{snmp}->get_leef(oids => [$oid_chassisModelName]);
$self->{product_name} = defined($result->{$oid_chassisModelName}) ? centreon::plugins::misc::trim($result->{$oid_chassisModelName}) : 'unknown';
}
sub check_exclude {
my ($self, $section) = @_;
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$section(\s|,|$)/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $section section."));
return 1;
}
return 0;
}
1;
__END__
=head1 MODE
Check Hardware (Global status, Fans, CPUs, Power Supplies, Temperature, Storage).
=over 8
=item B<--component>
Which component to check (Default: 'all').
Can be: 'globalstatus', 'fan', 'cpu', 'psu', 'temperature', 'cachebattery', 'physicaldisk', 'logicaldrive', 'battery', 'controller', 'connector', 'storage'.
=item B<--exclude>
Exclude some parts (comma seperated list) (Example: --exclude=psu,fan).
=back
=cut

View File

@ -0,0 +1,83 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::battery;
use strict;
use warnings;
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
my %map_reading = (
1 => 'Predictive Failure',
2 => 'Failed',
4 => 'Presence Detected',
);
# In MIB '10892.mib'
my $mapping = {
batteryStatus => { oid => '.1.3.6.1.4.1.674.10892.1.600.50.1.5', map => \%map_status },
batteryReading => { oid => '.1.3.6.1.4.1.674.10892.1.600.50.1.6', map => \%map_reading },
batteryLocationName => { oid => '.1.3.6.1.4.1.674.10892.1.600.50.1.7' },
};
my $oid_batteryTableEntry = '.1.3.6.1.4.1.674.10892.1.600.50.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $oid_batteryTableEntry, start => $mapping->{batteryStatus}->{oid}, end => $mapping->{batteryLocationName}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking batteries");
$self->{components}->{battery} = {name => 'batteries', total => 0, skip => 0};
return if ($self->check_exclude(section => 'battery'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_batteryTableEntry}})) {
next if ($oid !~ /^$mapping->{batteryStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_batteryTableEntry}, instance => $instance);
next if ($self->check_exclude(section => 'battery', instance => $instance));
$self->{components}->{battery}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Battery '%s' status is '%s' [instance: %s, reading: %s, location: %s]",
$instance, $result->{batteryStatus}, $instance, $result->{batteryReading}, $result->{batteryLocationName}
));
my $exit = $self->get_severity(section => 'battery', value => $result->{batteryStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Battery '%s' status is '%s'",
$instance, $result->{batteryStatus}));
}
}
}
1;

View File

@ -0,0 +1,114 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::cachebattery;
use strict;
use warnings;
my %map_state = (
0 => 'unknown',
1 => 'ready',
2 => 'failed',
6 => 'degraded',
7 => 'reconditioning',
9 => 'high',
10 => 'powerLow',
12 => 'charging',
21 => 'missing',
36 => 'learning',
);
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
my %map_learnState = (
1 => 'failed',
2 => 'active',
4 => 'timedOut',
8 => 'requested',
16 => 'idle',
32 => 'due',
);
my %map_predictedCapacity = (
1 => 'failed',
2 => 'ready',
4 => 'unknown',
);
# In MIB 'dcstorag.mib'
my $mapping = {
batteryState => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.15.1.4', map => \%map_state },
};
my $mapping2 = {
batteryComponentStatus => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.15.1.6', map => \%map_status },
};
my $mapping3 = {
batteryPredictedCapicity => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.15.1.10', map => \%map_predictedCapacity },
};
my $mapping4 = {
batteryLearnState => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.15.1.12', map => \%map_learnState },
};
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{batteryState}->{oid} }, { oid => $mapping2->{batteryComponentStatus}->{oid} },
{ oid => $mapping3->{batteryPredictedCapicity}->{oid} }, { oid => $mapping4->{batteryLearnState}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking cache batteries");
$self->{components}->{cachebattery} = {name => 'cache batteries', total => 0, skip => 0};
return if ($self->check_exclude(section => 'cachebattery'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping2->{batteryComponentStatus}->{oid}}})) {
next if ($oid !~ /^$mapping2->{batteryComponentStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{batteryState}->{oid}}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{batteryComponentStatus}->{oid}}, instance => $instance);
my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{batteryPredictedCapicity}->{oid}}, instance => $instance);
my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{batteryLearnState}->{oid}}, instance => $instance);
$result4->{batteryLearnState} = defined($result4->{batteryLearnState}) ? $result4->{batteryLearnState} : '-';
next if ($self->check_exclude(section => 'cachebattery', instance => $instance));
$self->{components}->{cachebattery}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Cache battery '%s' status is '%s' [instance: %s, state: %s, learn state: %s, predicted capacity: %s]",
$instance, $result2->{batteryComponentStatus}, $instance,
$result->{batteryState}, $result4->{batteryLearnState}, $result3->{batteryPredictedCapicity}
));
my $exit = $self->get_severity(section => 'cachebattery', value => $result2->{batteryComponentStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Cache battery '%s' status is '%s'",
$instance, $result2->{batteryComponentStatus}));
}
}
}
1;

View File

@ -0,0 +1,104 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::connector;
use strict;
use warnings;
my %map_state = (
0 => 'unknown',
1 => 'ready',
2 => 'failed',
3 => 'online',
4 => 'offline',
6 => 'degraded',
);
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
my %map_busType = (
1 => 'SCSI',
2 => 'IDE',
3 => 'Fibre Channel',
4 => 'SSA',
6 => 'USB',
7 => 'SATA',
8 => 'SAS',
);
# In MIB 'dcstorag.mib'
my $mapping = {
channelName => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.2.1.2' },
channelState => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.2.1.3', map => \%map_state },
};
my $mapping2 = {
channelComponentStatus => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.2.1.8', map => \%map_status },
};
my $mapping3 = {
channelBusType => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.2.1.11', map => \%map_busType },
};
my $oid_channelEntry = '.1.3.6.1.4.1.674.10893.1.20.130.2.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $oid_channelEntry, start => $mapping->{channelName}->{oid}, end => $mapping->{channelState}->{oid} },
{ oid => $mapping2->{channelComponentStatus}->{oid} },
{ oid => $mapping3->{channelBusType}->{oid} } ;
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking connectors (channels)");
$self->{components}->{connector} = {name => 'connectors', total => 0, skip => 0};
return if ($self->check_exclude(section => 'connector'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping2->{channelComponentStatus}->{oid}}})) {
next if ($oid !~ /^$mapping2->{channelComponentStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_channelEntry}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{channelComponentStatus}->{oid}}, instance => $instance);
my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{channelBusType}->{oid}}, instance => $instance);
next if ($self->check_exclude(section => 'connector', instance => $instance));
$self->{components}->{connector}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Connector '%s' status is '%s' [instance: %s, state: %s, bus type: %s]",
$result->{channelName}, $result2->{channelComponentStatus}, $instance,
$result->{channelState}, $result3->{channelBusType}
));
my $exit = $self->get_severity(section => 'connector', value => $result2->{channelComponentStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Connector '%s' status is '%s'",
$result->{channelName}, $result2->{channelComponentStatus}));
}
}
}
1;

View File

@ -0,0 +1,96 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::controller;
use strict;
use warnings;
my %map_state = (
0 => 'unknown',
1 => 'ready',
2 => 'failed',
3 => 'online',
4 => 'offline',
6 => 'degraded',
);
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
# In MIB 'dcstorag.mib'
my $mapping = {
controllerName => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.1.1.2' },
};
my $mapping2 = {
controllerComponentStatus => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.1.1.38', map => \%map_status },
};
my $mapping3 = {
controllerState => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.1.1.5', map => \%map_state },
};
my $mapping4 = {
controllerFWVersion => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.1.1.8' },
};
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{controllerName}->{oid} }, { oid => $mapping2->{controllerComponentStatus}->{oid} },
{ oid => $mapping3->{controllerState}->{oid} }, { oid => $mapping4->{controllerFWVersion}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking controllers");
$self->{components}->{controller} = {name => 'controllers', total => 0, skip => 0};
return if ($self->check_exclude(section => 'controller'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping2->{controllerComponentStatus}->{oid}}})) {
next if ($oid !~ /^$mapping2->{controllerComponentStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{controllerName}->{oid}}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{controllerComponentStatus}->{oid}}, instance => $instance);
my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{controllerState}->{oid}}, instance => $instance);
my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{controllerFWVersion}->{oid}}, instance => $instance);
next if ($self->check_exclude(section => 'controller', instance => $instance));
$self->{components}->{controller}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Controller '%s' status is '%s' [instance: %s, state: %s, firmware: %s]",
$result->{controllerName}, $result2->{controllerComponentStatus}, $instance,
$result3->{controllerState}, $result4->{controllerFWVersion}
));
my $exit = $self->get_severity(section => 'controller', value => $result2->{controllerComponentStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Controller '%s' status is '%s'",
$result->{controllerName}, $result2->{controllerComponentStatus}));
}
}
}
1;

View File

@ -0,0 +1,100 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::cpu;
use strict;
use warnings;
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
my %map_statusState = (
1 => 'other',
2 => 'unknown',
3 => 'enabled',
4 => 'userDisabled',
5 => 'biosDisabled',
6 => 'idle',
);
# In MIB '10892.mib'
my $mapping = {
processorDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.1.1100.30.1.5', map => \%map_status },
};
my $mapping2 = {
processorDeviceManufacturerName => { oid => '.1.3.6.1.4.1.674.10892.1.1100.30.1.8' },
processorDeviceStatusState => { oid => '.1.3.6.1.4.1.674.10892.1.1100.30.1.9', map => \%map_statusState },
};
my $mapping3 = {
processorDeviceCurrentSpeed => { oid => '.1.3.6.1.4.1.674.10892.1.1100.30.1.12' }, # in mHz
};
my $mapping4 = {
processorDeviceBrandName => { oid => '.1.3.6.1.4.1.674.10892.1.1100.30.1.23' },
};
my $oid_processorDeviceTableEntry = '.1.3.6.1.4.1.674.10892.1.1100.30.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{processorDeviceStatus}->{oid} },
{ oid => $oid_processorDeviceTableEntry, start => $mapping2->{processorDeviceManufacturerName}->{oid}, end => $mapping2->{processorDeviceStatusState}->{oid} },
{ oid => $mapping3->{processorDeviceCurrentSpeed}->{oid} }, { oid => $mapping4->{processorDeviceBrandName}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking processor units");
$self->{components}->{cpu} = {name => 'CPUs', total => 0, skip => 0};
return if ($self->check_exclude(section => 'cpu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{processorDeviceStatus}->{oid}}})) {
next if ($oid !~ /^$mapping->{processorDeviceStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{processorDeviceStatus}->{oid}}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_processorDeviceTableEntry}, instance => $instance);
my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{processorDeviceCurrentSpeed}->{oid}}, instance => $instance);
my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{processorDeviceBrandName}->{oid}}, instance => $instance);
next if ($self->check_exclude(section => 'cpu', instance => $instance));
$self->{components}->{cpu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Cpu '%s' status is '%s' [instance: %s, manufacturer name: %s, brand name: %s, state: %s, speed: %s]",
$instance, $result->{processorDeviceStatus}, $instance,
$result2->{processorDeviceManufacturerName}, $result4->{processorDeviceBrandName},
$result2->{processorDeviceStatusState}, $result3->{processorDeviceCurrentSpeed}
));
my $exit = $self->get_severity(section => 'cpu', value => $result->{processorDeviceStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Cpu '%s' status is '%s'",
$instance, $result->{processorDeviceStatus}));
}
}
}
1;

View File

@ -0,0 +1,74 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::esmlog;
use strict;
use warnings;
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
# In MIB '10892.mib'
my $mapping = {
systemStateEventLogStatus => { oid => '.1.3.6.1.4.1.674.10892.1.200.10.1.41', map => \%map_status },
};
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{systemStateEventLogStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking ESM log filling");
$self->{components}->{esmlog} = {name => 'ESM log', total => 0, skip => 0};
return if ($self->check_exclude(section => 'esmlog'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{systemStateEventLogStatus}->{oid}}})) {
next if ($oid !~ /^$mapping->{systemStateEventLogStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{systemStateEventLogStatus}->{oid}}, instance => $instance);
next if ($self->check_exclude(section => 'globalstatus', instance => $instance));
$self->{components}->{esmlog}->{total}++;
$self->{output}->output_add(long_msg => sprintf("ESM '%s' log status is '%s' [instance: %s]",
$instance, $result->{systemStateEventLogStatus}, $instance
));
my $exit = $self->get_severity(section => 'esmlog', value => $result->{systemStateEventLogStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("ESM '%s' log status is '%s'",
$instance, $result->{systemStateEventLogStatus}));
}
}
}
1;

View File

@ -0,0 +1,101 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::fan;
use strict;
use warnings;
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCriticalUpper',
5 => 'criticalUpper',
6 => 'nonRecoverableUpper',
7 => 'nonCriticalLower',
8 => 'criticalLower',
9 => 'nonRecoverableLower',
10 => 'failed',
);
# In MIB '10892.mib'
my $mapping = {
coolingDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.1.700.12.1.5', map => \%map_status },
coolingDeviceReading => { oid => '.1.3.6.1.4.1.674.10892.1.700.12.1.6' },
};
my $mapping2 = {
coolingDeviceLocationName => { oid => '.1.3.6.1.4.1.674.10892.1.700.12.1.8' },
};
my $oid_coolingDeviceTableEntry = '.1.3.6.1.4.1.674.10892.1.700.12.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $oid_coolingDeviceTableEntry, start => $mapping->{coolingDeviceStatus}->{oid}, end => $mapping->{coolingDeviceReading}->{oid} },
{ oid => $mapping2->{coolingDeviceLocationName}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
return if ($self->check_exclude(section => 'fan'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_coolingDeviceTableEntry}})) {
next if ($oid !~ /^$mapping->{coolingDeviceStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingDeviceTableEntry}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{coolingDeviceLocationName}->{oid}}, instance => $instance);
next if ($self->check_exclude(section => 'fan', instance => $instance));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance: %s, Location: %s, reading: %s]",
$instance, $result->{coolingDeviceStatus}, $instance,
$result2->{coolingDeviceLocationName}, $result->{coolingDeviceReading}
));
my $exit = $self->get_severity(section => 'fan', value => $result->{coolingDeviceStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s' status is '%s'",
$instance, $result->{coolingDeviceStatus}));
}
if (defined($result->{coolingDeviceReading}) && $result->{coolingDeviceReading} =~ /[0-9]/) {
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{coolingDeviceReading});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s' speed is %s rpm", $instance, $result->{coolingDeviceReading}));
}
$self->{output}->perfdata_add(label => 'fan_' . $instance, unit => 'rpm',
value => $result->{coolingDeviceReading},
warning => $warn,
critical => $crit,
min => 0
);
}
}
}
1;

View File

@ -0,0 +1,74 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::globalstatus;
use strict;
use warnings;
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
# In MIB '10892.mib'
my $mapping = {
globalSystemStatus => { oid => '.1.3.6.1.4.1.674.10892.1.200.10.1.2', map => \%map_status },
};
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{globalSystemStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking global system status");
$self->{components}->{globalstatus} = {name => 'global system status', total => 0, skip => 0};
return if ($self->check_exclude(section => 'globalstatus'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{globalSystemStatus}->{oid}}})) {
next if ($oid !~ /^$mapping->{globalSystemStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{globalSystemStatus}->{oid}}, instance => $instance);
next if ($self->check_exclude(section => 'globalstatus', instance => $instance));
$self->{components}->{globalstatus}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Chassis '%s' global status is '%s' [instance: %s]",
$instance, $result->{globalSystemStatus}, $instance
));
my $exit = $self->get_severity(section => 'globalstatus', value => $result->{globalSystemStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Chassis '%s' global status is '%s'",
$instance, $result->{globalSystemStatus}));
}
}
}
1;

View File

@ -0,0 +1,126 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::logicaldrive;
use strict;
use warnings;
my %map_state = (
0 => 'unknown',
1 => 'ready',
2 => 'failed',
3 => 'online',
4 => 'offline',
6 => 'degraded',
15 => 'resynching',
24 => 'rebuild',
26 => 'formatting',
35 => 'initializing',
);
my %map_layout = (
1 => 'Concatened',
2 => 'RAID-0',
3 => 'RAID-1',
4 => 'RAID-2',
5 => 'RAID-3',
6 => 'RAID-4',
7 => 'RAID-5',
8 => 'RAID-6',
9 => 'RAID-7',
10 => 'RAID-10',
11 => 'RAID-30',
12 => 'RAID-50',
13 => 'Add spares',
14 => 'Delete logical',
15 => 'Transform logical',
18 => 'RAID-0-plus-1 - Mylex only',
19 => 'Concatened RAID 1',
20 => 'Concatened RAID 5',
21 => 'no RAID',
22 => 'RAID Morph - Adapted only',
);
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
# In MIB 'dcstorag.mib'
my $mapping = {
virtualDiskName => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.2' },
virtualDiskDeviceName => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.3' },
virtualDiskState => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.4', map => \%map_state },
};
my $mapping2 = {
virtualDiskLengthInMB => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.6' },
};
my $mapping3 = {
virtualDiskLayout => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.13', map => \%map_layout },
};
my $mapping4 = {
virtualDiskComponentStatus => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.20', map => \%map_status },
};
my $oid_virtualDiskEntry = '.1.3.6.1.4.1.674.10893.1.20.140.1.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $oid_virtualDiskEntry, start => $mapping->{virtualDiskName}->{oid}, end => $mapping->{virtualDiskState}->{oid} },
{ oid => $mapping2->{virtualDiskLengthInMB}->{oid} }, { oid => $mapping3->{virtualDiskLayout}->{oid} }, { oid => $mapping4->{virtualDiskComponentStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking logical drives");
$self->{components}->{logicaldrive} = {name => 'logical drives', total => 0, skip => 0};
return if ($self->check_exclude(section => 'logicaldrive'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping4->{virtualDiskComponentStatus}->{oid}}})) {
next if ($oid !~ /^$mapping4->{virtualDiskComponentStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_virtualDiskEntry}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{virtualDiskLengthInMB}->{oid}}, instance => $instance);
my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{virtualDiskLayout}->{oid}}, instance => $instance);
my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{virtualDiskComponentStatus}->{oid}}, instance => $instance);
next if ($self->check_exclude(section => 'logicaldrive', instance => $instance));
$self->{components}->{logicaldrive}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Logical drive '%s' status is '%s' [instance: %s, size: %s MB, layout: %s, state: %s, device name: %s]",
$result->{virtualDiskName}, $result4->{virtualDiskComponentStatus}, $instance,
$result2->{virtualDiskLengthInMB}, $result3->{virtualDiskLayout},
$result->{virtualDiskState}, $result->{virtualDiskDeviceName}
));
my $exit = $self->get_severity(section => 'logicaldrive', value => $result4->{virtualDiskComponentStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Logical drive '%s' status is '%s'",
$result->{virtualDiskName}, $result4->{virtualDiskComponentStatus}));
}
}
}
1;

View File

@ -0,0 +1,97 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::memory;
use strict;
use warnings;
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
my %map_failureModes = (
0 => 'Not failure',
1 => 'ECC single bit correction warning rate exceeded',
2 => 'ECC single bit correction failure rate exceeded',
4 => 'ECC multibit fault encountered',
8 => 'ECC single bit correction logging disabled',
16 => 'device disabled because of spare activation',
);
# In MIB '10892.mib'
my $mapping = {
memoryDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.1.1100.50.1.5', map => \%map_status },
};
my $mapping2 = {
memoryDeviceLocationName => { oid => '.1.3.6.1.4.1.674.10892.1.1100.50.1.8' },
};
my $mapping3 = {
memoryDeviceSize => { oid => '.1.3.6.1.4.1.674.10892.1.1100.50.1.14' },
};
my $mapping4 = {
memoryDeviceFailureModes => { oid => '.1.3.6.1.4.1.674.10892.1.1100.50.1.20', map => \%map_failureModes },
};
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{memoryDeviceStatus}->{oid} }, { oid => $mapping2->{memoryDeviceLocationName}->{oid} },
{ oid => $mapping3->{memoryDeviceSize}->{oid} }, { oid => $mapping4->{memoryDeviceFailureModes}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking memory modules");
$self->{components}->{memory} = {name => 'memory modules', total => 0, skip => 0};
return if ($self->check_exclude(section => 'memory'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{memoryDeviceStatus}->{oid}}})) {
next if ($oid !~ /^$mapping->{memoryDeviceStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{memoryDeviceStatus}->{oid}}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{memoryDeviceLocationName}->{oid}}, instance => $instance);
my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{memoryDeviceSize}->{oid}}, instance => $instance);
my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{memoryDeviceFailureModes}->{oid}}, instance => $instance);
next if ($self->check_exclude(section => 'memory', instance => $instance));
$self->{components}->{memory}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Memory module '%s' status is '%s' [instance: %s, Location: %s, Size: %s MB, Failure mode: %s]",
$instance, $result->{memoryDeviceStatus}, $instance,
$result2->{memoryDeviceLocationName}, $result3->{memoryDeviceSize}, $result4->{memoryDeviceFailureModes}
));
my $exit = $self->get_severity(section => 'memory', value => $result->{memoryDeviceStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Memory module '%s' status is '%s'",
$instance, $result->{memoryDeviceStatus}));
}
}
}
1;

View File

@ -0,0 +1,128 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::physicaldisk;
use strict;
use warnings;
my %map_state = (
0 => 'unknown',
1 => 'ready',
2 => 'failed',
3 => 'online',
4 => 'offline',
6 => 'degraded',
7 => 'recovering',
11 => 'removed',
15 => 'resynching',
24 => 'rebuild',
25 => 'noMedia',
26 => 'formatting',
28 => 'diagnostics',
35 => 'initializing',
);
my %map_spareState = (
1 => 'memberVD',
2 => 'memberDG',
3 => 'globalHostSpare',
4 => 'dedicatedHostSpare',
5 => 'notASpare',
);
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
my %map_smartAlertIndication = (
1 => 'no',
2 => 'yes',
);
# In MIB 'dcstorag.mib'
my $mapping = {
arrayDiskName => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.4.1.2' },
};
my $mapping2 = {
arrayDiskState => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.4.1.4', map => \%map_state },
};
my $mapping3 = {
arrayDiskSpareState => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.4.1.22', map => \%map_spareState },
};
my $mapping4 = {
arrayDiskComponentStatus => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.4.1.24', map => \%map_status },
};
my $mapping5 = {
arrayDiskSmartAlertIndication => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.4.1.31', map => \%map_smartAlertIndication },
};
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{arrayDiskName}->{oid} }, { oid => $mapping2->{arrayDiskState}->{oid} },
{ oid => $mapping3->{arrayDiskSpareState}->{oid} }, { oid => $mapping4->{arrayDiskComponentStatus}->{oid} },
{ oid => $mapping5->{arrayDiskSmartAlertIndication}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking physical disks");
$self->{components}->{physicaldisk} = {name => 'physical disks', total => 0, skip => 0};
return if ($self->check_exclude(section => 'physicaldisk'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping4->{arrayDiskComponentStatus}->{oid}}})) {
next if ($oid !~ /^$mapping4->{arrayDiskComponentStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{arrayDiskName}->{oid}}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{arrayDiskState}->{oid}}, instance => $instance);
my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{arrayDiskSpareState}->{oid}}, instance => $instance);
my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{arrayDiskComponentStatus}->{oid}}, instance => $instance);
my $result5 = $self->{snmp}->map_instance(mapping => $mapping5, results => $self->{results}->{$mapping5->{arrayDiskSmartAlertIndication}->{oid}}, instance => $instance);
next if ($self->check_exclude(section => 'physicaldisk', instance => $instance));
$self->{components}->{physicaldisk}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Physical Disk '%s' status is '%s' [instance: %s, state: %s, spare state: %s, smart alert: %s]",
$result->{arrayDiskName}, $result4->{arrayDiskComponentStatus}, $instance,
$result2->{arrayDiskState}, $result3->{arrayDiskSpareState}, $result5->{arrayDiskSmartAlertIndication}
));
my $exit = $self->get_severity(section => 'physicaldisk', value => $result4->{arrayDiskComponentStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Physical Disk '%s' status is '%s'",
$result->{arrayDiskName}, $result4->{arrayDiskComponentStatus}));
}
$exit = $self->get_severity(section => 'physicaldisk_smartalert', value => $result5->{arrayDiskSmartAlertIndication});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("physical disk '%s' has received a predictive failure alert",
$result->{arrayDiskName}));
}
}
}
1;

View File

@ -0,0 +1,131 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::psu;
use strict;
use warnings;
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
my %map_type = (
1 => 'other',
2 => 'unknown',
3 => 'Linear',
4 => 'switching',
5 => 'Battery',
6 => 'UPS',
7 => 'Converter',
8 => 'Regulator',
9 => 'AC',
10 => 'DC',
11 => 'VRM',
);
my %map_state = (
1 => 'present',
2 => 'failure',
4 => 'predictiveFailure',
8 => 'ACLost',
16 => 'ACLostOrOutOfRange',
32 => 'ACPresentButOutOfRange',
64 => 'configurationError',
);
my %map_ConfigurationErrorType = (
1 => 'vendorMismatch',
2 => 'revisionMismatch',
3 => 'processorMissing',
);
# In MIB '10892.mib'
my $mapping = {
powerSupplyStatus => { oid => '.1.3.6.1.4.1.674.10892.1.600.12.1.5', map => \%map_status },
powerSupplyOutputWatts => { oid => '.1.3.6.1.4.1.674.10892.1.600.12.1.6' },
powerSupplyType => { oid => '.1.3.6.1.4.1.674.10892.1.600.12.1.7', map => \%map_type },
powerSupplyLocationName => { oid => '.1.3.6.1.4.1.674.10892.1.600.12.1.8' },
};
my $mapping2 = {
powerSupplySensorState => { oid => '.1.3.6.1.4.1.674.10892.1.600.12.1.11', map => \%map_state },
powerSupplyConfigurationErrorType => { oid => '.1.3.6.1.4.1.674.10892.1.600.12.1.12', map => \%map_ConfigurationErrorType },
};
my $oid_powerSupplyTable = '.1.3.6.1.4.1.674.10892.1.600.12';
my $oid_powerSupplyTableEntry = '.1.3.6.1.4.1.674.10892.1.600.12.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $oid_powerSupplyTable, start => $mapping->{powerSupplyStatus}->{oid}, end => $mapping->{powerSupplyLocationName}->{oid} },
{ oid => $oid_powerSupplyTableEntry, start => $mapping2->{powerSupplySensorState}->{oid}, end => $mapping2->{powerSupplyConfigurationErrorType}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0};
return if ($self->check_exclude(section => 'psu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerSupplyTable}})) {
next if ($oid !~ /^$mapping->{powerSupplyStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerSupplyTable}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_powerSupplyTableEntry}, instance => $instance);
$result2->{powerSupplyConfigurationErrorType} = defined($result2->{powerSupplyConfigurationErrorType}) ? $result2->{powerSupplyConfigurationErrorType} : '-';
next if ($self->check_exclude(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance: %s, location: %s, type: %s, output watts: %s, state: %s, configuration error: %s]",
$instance, $result->{powerSupplyStatus}, $instance,
$result->{powerSupplyLocationName}, $result->{powerSupplyType}, $result->{powerSupplyOutputWatts},
$result2->{powerSupplySensorState}, $result2->{powerSupplyConfigurationErrorType}
));
my $exit = $self->get_severity(section => 'psu', value => $result->{powerSupplyStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is '%s'",
$instance, $result->{powerSupplyStatus}));
}
if (defined($result->{powerSupplyOutputWatts}) && $result->{powerSupplyOutputWatts} =~ /[0-9]/) {
$result->{powerSupplyOutputWatts} /= 10;
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'psu.power', instance => $instance, value => $result->{powerSupplyOutputWatts});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' power is %s W", $instance, $result->{powerSupplyOutputWatts}));
}
$self->{output}->perfdata_add(label => 'psu_power_' . $instance, unit => 'W',
value => $result->{powerSupplyOutputWatts},
warning => $warn,
critical => $crit,
min => 0
);
}
}
}
1;

View File

@ -0,0 +1,105 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::components::temperature;
use strict;
use warnings;
my %map_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCriticalUpper',
5 => 'criticalUpper',
6 => 'nonRecoverableUpper',
7 => 'nonCriticalLower',
8 => 'criticalLower',
9 => 'nonRecoverableLower',
10 => 'failed',
);
my %map_type = (
1 => 'other',
2 => 'unknown',
3 => 'Ambient ESM',
4 => 'Discrete',
);
# In MIB '10892.mib'
my $mapping = {
temperatureProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.1.700.20.1.5', map => \%map_status },
temperatureProbeReading => { oid => '.1.3.6.1.4.1.674.10892.1.700.20.1.6' },
temperatureProbeType => { oid => '.1.3.6.1.4.1.674.10892.1.700.20.1.7', map => \%map_type },
temperatureProbeLocationName => { oid => '.1.3.6.1.4.1.674.10892.1.700.20.1.8' },
};
my $oid_temperatureProbeTable = '.1.3.6.1.4.1.674.10892.1.700.20';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $oid_temperatureProbeTable, start => $mapping->{temperatureProbeStatus}->{oid}, end => $mapping->{temperatureProbeLocationName}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
return if ($self->check_exclude(section => 'temperature'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureProbeTable}})) {
next if ($oid !~ /^$mapping->{temperatureProbeStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureProbeTable}, instance => $instance);
next if ($self->check_exclude(section => 'temperature', instance => $instance));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is '%s' [instance: %s, location: %s, reading: %s]",
$instance, $result->{temperatureProbeStatus}, $instance,
$result->{temperatureProbeLocationName}, $result->{temperatureProbeReading}
));
my $exit = $self->get_severity(section => 'temperature', value => $result->{temperatureProbeStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' status is '%s'",
$instance, $result->{temperatureProbeStatus}));
}
if (defined($result->{temperatureProbeReading}) && $result->{temperatureProbeReading} =~ /[0-9]/) {
$result->{temperatureProbeReading} /= 10;
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureProbeReading});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' is %s degree centigrade", $instance, $result->{temperatureProbeReading}));
}
$self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C',
value => $result->{temperatureProbeReading},
warning => $warn,
critical => $crit,
min => 0
);
}
}
}
1;

View File

@ -0,0 +1,400 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::server::dell::openmanage::snmp::mode::hardware;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
my $thresholds = {
globalstatus => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
battery => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
cachebattery => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
connector => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
controller => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
controller => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
cpu => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
esmlog => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
fan => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCriticalUpper', 'WARNING'],
['criticalUpper', 'CRITICAL'],
['nonRecoverableUpper', 'CRITICAL'],
['nonCriticalLower', 'WARNING'],
['criticalLower', 'CRITICAL'],
['nonRecoverableLower', 'CRITICAL'],
['failed', 'CRITICAL']
],
logicaldrive => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
memory => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
physicaldisk => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
physicaldisk_smartalert => [
['yes', 'WARNING'],
['no', 'OK'],
],
psu => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL'],
],
temperature => [
['other', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCriticalUpper', 'WARNING'],
['criticalUpper', 'CRITICAL'],
['nonRecoverableUpper', 'CRITICAL'],
['nonCriticalLower', 'WARNING'],
['criticalLower', 'CRITICAL'],
['nonRecoverableLower', 'CRITICAL'],
['failed', 'CRITICAL'],
],
};
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"exclude:s" => { name => 'exclude' },
"component:s" => { name => 'component', default => '.*' },
"no-component:s" => { name => 'no_component' },
"threshold-overload:s@" => { name => 'threshold_overload' },
"warning:s@" => { name => 'warning' },
"critical:s@" => { name => 'critical' },
});
$self->{components} = {};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{no_component})) {
if ($self->{option_results}->{no_component} ne '') {
$self->{no_components} = $self->{option_results}->{no_component};
} else {
$self->{no_components} = 'critical';
}
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
if ($val !~ /^(.*?),(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $status, $filter) = ($1, $2, $3);
if ($self->{output}->is_litteral_status(status => $status) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
$self->{output}->option_exit();
}
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
}
$self->{numeric_threshold} = {};
foreach my $option (('warning', 'critical')) {
foreach my $val (@{$self->{option_results}->{$option}}) {
if ($val !~ /^(.*?),(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $regexp, $value) = ($1, $2, $3);
if ($section !~ /^(temperature|fan|psu\.power)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature, fan, psu.power).");
$self->{output}->option_exit();
}
my $position = 0;
if (defined($self->{numeric_threshold}->{$section})) {
$position = scalar(@{$self->{numeric_threshold}->{$section}});
}
if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'.");
$self->{output}->option_exit();
}
$self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section}));
push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp };
}
}
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
# In '10892-MIB'
my $oid_chassisModelName = ".1.3.6.1.4.1.674.10892.1.300.10.1.9";
my $snmp_request = [ { oid => $oid_chassisModelName } ];
my @components = ('globalstatus', 'fan', 'psu', 'temperature', 'cpu', 'cachebattery', 'memory',
'physicaldisk', 'logicaldrive', 'esmlog', 'battery', 'controller', 'connector');
foreach (@components) {
if (/$self->{option_results}->{component}/) {
my $mod_name = "hardware::server::dell::openmanage::snmp::mode::components::$_";
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
error_msg => "Cannot load module '$mod_name'.");
my $func = $mod_name->can('load');
$func->(request => $snmp_request);
}
}
if (scalar(@{$snmp_request}) == 1) {
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
$self->{output}->option_exit();
}
$self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_chassisModelName}})) {
my $name = defined($self->{results}->{$oid_chassisModelName}->{$oid}) ?
centreon::plugins::misc::trim($self->{results}->{$oid_chassisModelName}->{$oid}) : 'unknown';
$self->{output}->output_add(long_msg => sprintf("Product Name: %s", $name));
}
foreach (@components) {
if (/$self->{option_results}->{component}/) {
my $mod_name = "hardware::server::dell::openmanage::snmp::mode::components::$_";
my $func = $mod_name->can('check');
$func->($self);
}
}
my $total_components = 0;
my $display_by_component = '';
my $display_by_component_append = '';
foreach my $comp (sort(keys %{$self->{components}})) {
# Skipping short msg when no components
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
$display_by_component_append = ', ';
}
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("All %s components are ok [%s].",
$total_components,
$display_by_component)
);
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
$self->{output}->output_add(severity => $self->{no_components},
short_msg => 'No components are checked.');
}
$self->{output}->display();
$self->{output}->exit();
}
sub check_exclude {
my ($self, %options) = @_;
if (defined($options{instance})) {
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
$self->{components}->{$options{section}}->{skip}++;
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
return 1;
}
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
return 1;
}
return 0;
}
sub get_severity_numeric {
my ($self, %options) = @_;
my $status = 'OK'; # default
my $thresholds = { warning => undef, critical => undef };
my $checked = 0;
if (defined($self->{numeric_threshold}->{$options{section}})) {
my $exits = [];
foreach (@{$self->{numeric_threshold}->{$options{section}}}) {
if ($options{instance} =~ /$_->{regexp}/) {
push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]);
$thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label});
$checked = 1;
}
}
$status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0);
}
return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked);
}
sub get_severity {
my ($self, %options) = @_;
my $status = 'UNKNOWN'; # default
if (defined($self->{overload_th}->{$options{section}})) {
foreach (@{$self->{overload_th}->{$options{section}}}) {
if ($options{value} =~ /$_->{filter}/i) {
$status = $_->{status};
return $status;
}
}
}
foreach (@{$thresholds->{$options{section}}}) {
if ($options{value} =~ /$$_[0]/i) {
$status = $$_[1];
return $status;
}
}
return $status;
}
1;
__END__
=head1 MODE
Check Hardware (Global status, Fans, CPUs, Power Supplies, Temperature, Storage).
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'globalstatus', 'fan', 'cpu', 'psu', 'temperature', 'cachebattery',
'physicaldisk', 'logicaldrive', 'battery', 'controller', 'connector'.
=item B<--exclude>
Exclude some parts (comma seperated list) (Example: --exclude=fan,cpu)
Can also exclude specific instance: --exclude=fan#1#,cpu
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='temperature,CRITICAL,^(?!(ok)$)'
=item B<--warning>
Set warning threshold for temperature, psu.power or fan (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,30'
=item B<--critical>
Set critical threshold for temperature, psu.power or fan (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,40'
=back
=cut

Some files were not shown because too many files have changed in this diff Show More