Merge pull request #1 from centreon/master

Keep up to date with master repo
This commit is contained in:
Bertrand Cournaud 2015-12-04 09:00:35 +01:00
commit f2021f4d0c
102 changed files with 5613 additions and 330 deletions

View File

@ -1,4 +1,5 @@
# centreon-plugins # centreon-plugins
“centreon-plugins” is a free and open source project to monitor systems. The project can be used with Centreon and all monitoring softwares compatible with Nagios plugins. “centreon-plugins” is a free and open source project to monitor systems. The project can be used with Centreon and all monitoring softwares compatible with Nagios plugins.
You can monitor many systems: You can monitor many systems:
@ -8,7 +9,7 @@ You can monitor many systems:
* hardware: printers (rfc3805), UPS (Powerware, Mge, Standard), Sun Hardware, Cisco UCS, SensorIP, HP Proliant, HP Bladechassis, Dell Openmanage, Dell CMC, Raritan,... * hardware: printers (rfc3805), UPS (Powerware, Mge, Standard), Sun Hardware, Cisco UCS, SensorIP, HP Proliant, HP Bladechassis, Dell Openmanage, Dell CMC, Raritan,...
* network: Aruba, Brocade, Bluecoat, Brocade, Checkpoint, Cisco AP/IronPort/ASA/Standard, Extreme, Fortigate, H3C, Hirschmann, HP Procurve, F5 BIG-IP, Juniper, PaloAlto, Redback, Riverbed, Ruggedcom, Stonesoft,... * network: Aruba, Brocade, Bluecoat, Brocade, Checkpoint, Cisco AP/IronPort/ASA/Standard, Extreme, Fortigate, H3C, Hirschmann, HP Procurve, F5 BIG-IP, Juniper, PaloAlto, Redback, Riverbed, Ruggedcom, Stonesoft,...
* os: Linux (SNMP, NRPE), Freebsd (SNMP), AIX (SNMP), Solaris (SNMP)... * os: Linux (SNMP, NRPE), Freebsd (SNMP), AIX (SNMP), Solaris (SNMP)...
* storage: EMC Clariion, Netapp, HP MSA p2000, Dell EqualLogic, Qnap, Panzura, Synology... * storage: EMC Clariion, Netapp, Nimble, HP MSA p2000, Dell EqualLogic, Qnap, Panzura, Synology...
## Basic Usage ## Basic Usage

View File

@ -0,0 +1,132 @@
#
# 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::biztalk::sql::mode::rlocationdisabled;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
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' },
"filter-location:s" => { name => 'filter_location' },
"filter-application:s" => { name => 'filter_application' },
});
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};
my $query = q{
SELECT RL.Name, RL.Disabled, APP.nvcName
FROM BizTalkMgmtDb.dbo.adm_ReceiveLocation AS RL WITH(NOLOCK)
INNER JOIN BizTalkMgmtDb.dbo.bts_receiveport AS RP WITH(NOLOCK)
ON RL.ReceivePortId = RP.nID
INNER JOIN BizTalkMgmtDb.dbo.bts_application AS APP WITH(NOLOCK)
ON RP.nApplicationID = APP.nID WHERE RL.[Disabled] = -1
};
$self->{sql}->connect();
$self->{sql}->query(query => $query);
my $count = 0;
while ((my $row = $self->{sql}->fetchrow_hashref())) {
if (defined($self->{option_results}->{filter_location}) && $self->{option_results}->{filter_location} ne '' &&
$row->{Name} !~ /$self->{option_results}->{filter_location}/) {
$self->{output}->output_add(long_msg => "Skipping '" . $row->{Name} . "': no matching filter location.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_application}) && $self->{option_results}->{filter_application} ne '' &&
$row->{nvcName} !~ /$self->{option_results}->{filter_application}/) {
$self->{output}->output_add(long_msg => "Skipping '" . $row->{nvcName} . "': no matching filter application.", debug => 1);
next;
}
$self->{output}->output_add(long_msg => "'" . $row->{Name} . "' of application '" . $row->{nvcName} . "'");
$count++;
}
my $exit = $self->{perfdata}->threshold_check(value => $count, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("%d receive locations are disabled", $count));
$self->{output}->perfdata_add(label => 'count',
value => $count,
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 the number of biztalk received locations disabled.
The mode should be used with mssql plugin and dyn-mode option.
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--filter-location>
Filter by location (regexp can be used).
=item B<--filter-application>
Filter by application (regexp can be used).
=back
=cut

View File

@ -98,8 +98,12 @@ sub run {
$self->{output}->perfdata_add(label => "time", unit => 's', $self->{output}->perfdata_add(label => "time", unit => 's',
value => sprintf('%.3f', $timeelapsed), value => sprintf('%.3f', $timeelapsed),
min => 0);
$self->{output}->perfdata_add(label => "entries",
value => $num_entries,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), 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}->display();
$self->{output}->exit(); $self->{output}->exit();

View File

@ -0,0 +1,129 @@
#
# 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::protocols::ntp::mode::offset;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Net::NTP;
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 =>
{
"ntp-host:s" => { name => 'ntp_host' },
"port:s" => { name => 'port', default => 123 },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => 30 },
});
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();
}
if (!defined($self->{option_results}->{ntp_host})) {
$self->{output}->add_option_msg(short_msg => "Please set the ntp-host option");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my %ntp;
eval {
$Net::NTP::TIMEOUT = $self->{option_results}->{timeout};
%ntp = get_ntp_response($self->{option_results}->{ntp_host}, $self->{option_results}->{port});
};
if ($@) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Couldn't connect to ntp server: " . $@);
$self->{output}->display();
$self->{output}->exit();
}
my $localtime = time();
my $offset = ($ntp{'Receive Timestamp'} - $ntp{'Originate Timestamp'}) + ($ntp{'Transmit Timestamp'} - $localtime) / 2);
my $exit = $self->{perfdata}->threshold_check(value => $offset,
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Offset: %.3fs", $offset));
$self->{output}->output_add(long_msg => sprintf("Host has an offset of %.5fs with its time server reference %s", $offset, $self->{option_results}->{ntp_host}));
$self->{output}->perfdata_add(label => "time", unit => 's',
value => sprintf('%.3f', $offset),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Ntp server response.
=over 8
=item B<--ntp-host>
Ntp server address or FQDN
=item B<--port>
Port used (Default: 123)
=item B<--timeout>
Threshold for NTP timeout
=item B<--warning>
Threshold warning in seconds
=item B<--critical>
Threshold critical in seconds (e.g @10:10 means CRITICAL if offset is not between -10 and +10 seconds)
=back
=cut

View File

@ -32,7 +32,8 @@ sub new {
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'response-time' => 'apps::protocols::ntp::mode::responsetime', 'response-time' => 'apps::protocols::ntp::mode::responsetime',
'offset' => 'apps::protocols::ntp::mode::offset',
); );
return $self; return $self;

View File

@ -208,11 +208,11 @@ Threshold warning in days (Days before expiration, eg: '60:' for 60 days before)
Threshold critical in days (Days before expiration, eg: '30:' for 30 days before) Threshold critical in days (Days before expiration, eg: '30:' for 30 days before)
=item B<--subject> =item B<--subjectname>
Subject Name pattern Subject Name pattern
=item B<--issuer> =item B<--issuername>
Issuer Name pattern Issuer Name pattern

View File

@ -94,7 +94,6 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Please specify a scenario name" . $self->{option_results}->{scenario} . "."); $self->{output}->add_option_msg(short_msg => "Please specify a scenario name" . $self->{option_results}->{scenario} . ".");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
} }
sub run { sub run {

View File

@ -55,6 +55,8 @@ sub new {
"vsphere-password:s@" => { name => 'vsphere_password' }, "vsphere-password:s@" => { name => 'vsphere_password' },
"container:s@" => { name => 'container' }, "container:s@" => { name => 'container' },
"timeout:s@" => { name => 'timeout' }, "timeout:s@" => { name => 'timeout' },
"sampling-period:s@" => { name => 'sampling_period' },
"time-shift:s@" => { name => 'time_shift' },
}); });
} }
$options{options}->add_help(package => __PACKAGE__, sections => 'CONNECTOR OPTIONS', once => 1); $options{options}->add_help(package => __PACKAGE__, sections => 'CONNECTOR OPTIONS', once => 1);
@ -105,6 +107,8 @@ sub check_options {
$self->{vsphere_address} = (defined($self->{option_results}->{vsphere_address})) ? shift(@{$self->{option_results}->{vsphere_address}}) : undef; $self->{vsphere_address} = (defined($self->{option_results}->{vsphere_address})) ? shift(@{$self->{option_results}->{vsphere_address}}) : undef;
$self->{vsphere_username} = (defined($self->{option_results}->{vsphere_username})) ? shift(@{$self->{option_results}->{vsphere_username}}) : undef; $self->{vsphere_username} = (defined($self->{option_results}->{vsphere_username})) ? shift(@{$self->{option_results}->{vsphere_username}}) : undef;
$self->{vsphere_password} = (defined($self->{option_results}->{vsphere_password})) ? shift(@{$self->{option_results}->{vsphere_password}}) : undef; $self->{vsphere_password} = (defined($self->{option_results}->{vsphere_password})) ? shift(@{$self->{option_results}->{vsphere_password}}) : undef;
$self->{sampling_period} = (defined($self->{option_results}->{sampling_period})) ? shift(@{$self->{option_results}->{sampling_period}}) : undef;
$self->{time_shift} = (defined($self->{option_results}->{sampling_period})) ? shift(@{$self->{option_results}->{time_shift}}) : 0;
$self->{connector_port} = 5700 if ($self->{connector_port} eq ''); $self->{connector_port} = 5700 if ($self->{connector_port} eq '');
$self->{container} = 'default' if ($self->{container} eq ''); $self->{container} = 'default' if ($self->{container} eq '');
@ -198,6 +202,8 @@ sub run {
$self->{json_send}->{vsphere_address} = $self->{vsphere_address}; $self->{json_send}->{vsphere_address} = $self->{vsphere_address};
$self->{json_send}->{vsphere_username} = $self->{vsphere_username}; $self->{json_send}->{vsphere_username} = $self->{vsphere_username};
$self->{json_send}->{vsphere_password} = $self->{vsphere_password}; $self->{json_send}->{vsphere_password} = $self->{vsphere_password};
$self->{json_send}->{sampling_period} = $self->{sampling_period};
$self->{json_send}->{time_shift} = $self->{time_shift};
# Init # Init
my $context = zmq_init(); my $context = zmq_init();
@ -288,6 +294,15 @@ Password of vpshere/ESX connection (with --vsphere-address).
Set global execution timeout (Default: 50) Set global execution timeout (Default: 50)
=item B<--sampling-period>
Choose the sampling period (can change the default sampling for counters).
Should be not different than 300 or 20.
=item B<--time-shift>
Can shift the time. We the following option you can average X counters values (default: 0).
=back =back
=head1 DESCRIPTION =head1 DESCRIPTION

View File

@ -0,0 +1,102 @@
#
# 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::vmware::connector::mode::servicehost;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
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 =>
{
"esx-hostname:s" => { name => 'esx_hostname' },
"filter" => { name => 'filter' },
"scope-datacenter:s" => { name => 'scope_datacenter' },
"scope-cluster:s" => { name => 'scope_cluster' },
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
"filter-services:s" => { name => 'filter_services' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status status option '" . $self->{option_results}->{disconnect_status} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
$self->{connector} = $options{custom};
$self->{connector}->add_params(params => $self->{option_results},
command => 'servicehost');
$self->{connector}->run();
}
1;
__END__
=head1 MODE
Check ESX services.
=over 8
=item B<--esx-hostname>
ESX hostname to check.
If not set, we check all ESX.
=item B<--filter>
ESX hostname is a regexp.
=item B<--scope-datacenter>
Search in following datacenter(s) (can be a regexp).
=item B<--scope-cluster>
Search in following cluster(s) (can be a regexp).
=item B<--disconnect-status>
Status if ESX host disconnected (default: 'unknown').
=item B<--filter-services>
Filter services you want to check (can be a regexp).
=back
=cut

View File

@ -54,6 +54,7 @@ sub new {
'memory-host' => 'apps::vmware::connector::mode::memoryhost', 'memory-host' => 'apps::vmware::connector::mode::memoryhost',
'memory-vm' => 'apps::vmware::connector::mode::memoryvm', 'memory-vm' => 'apps::vmware::connector::mode::memoryvm',
'net-host' => 'apps::vmware::connector::mode::nethost', 'net-host' => 'apps::vmware::connector::mode::nethost',
'service-host' => 'apps::vmware::connector::mode::servicehost',
'snapshot-vm' => 'apps::vmware::connector::mode::snapshotvm', 'snapshot-vm' => 'apps::vmware::connector::mode::snapshotvm',
'stat-connectors' => 'apps::vmware::connector::mode::statconnectors', 'stat-connectors' => 'apps::vmware::connector::mode::statconnectors',
'status-host' => 'apps::vmware::connector::mode::statushost', 'status-host' => 'apps::vmware::connector::mode::statushost',

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::cim_card;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Card');
$self->{output}->output_add(long_msg => "Checking cim cards");
$self->{components}->{cim_card} = {name => 'cards', total => 0, skip => 0};
return if ($self->check_filter(section => 'cim_card'));
foreach (@{$result}) {
my $instance = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
next if ($self->check_filter(section => 'cim_card', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping card '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{cim_card}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Card '%s' status is '%s' [instance: %s].",
$_->{ElementName}, $status,
$instance
));
my $exit = $self->get_severity(section => 'cim_card', label => 'default', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Card '%s' status is '%s'",
$_->{ElementName}, $status));
}
}
}
1;

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::cim_computersystem;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem');
$self->{output}->output_add(long_msg => "Checking cim computer systems");
$self->{components}->{cim_computersystem} = {name => 'computer systems', total => 0, skip => 0};
return if ($self->check_filter(section => 'cim_computersystem'));
foreach (@{$result}) {
my $instance = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
next if ($self->check_filter(section => 'cim_computersystem', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping computer system '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{cim_computersystem}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Computer system '%s' status is '%s' [instance: %s].",
$_->{ElementName}, $status,
$instance
));
my $exit = $self->get_severity(section => 'cim_computersystem', label => 'default', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Computer system '%s' status is '%s'",
$_->{ElementName}, $status));
}
}
}
1;

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::cim_memory;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Memory');
$self->{output}->output_add(long_msg => "Checking cim memories");
$self->{components}->{cim_memory} = {name => 'memories', total => 0, skip => 0};
return if ($self->check_filter(section => 'cim_memory'));
foreach (@{$result}) {
my $instance = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
next if ($self->check_filter(section => 'cim_memory', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping memory '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{cim_memory}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Memory '%s' status is '%s' [instance: %s].",
$_->{ElementName}, $status,
$instance
));
my $exit = $self->get_severity(section => 'cim_memory', label => 'default', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Memory '%s' status is '%s'",
$_->{ElementName}, $status));
}
}
}
1;

View File

@ -0,0 +1,111 @@
#
# 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::vmware::wsman::mode::components::cim_numericsensor;
use strict;
use warnings;
use apps::vmware::wsman::mode::components::resources qw($mapping_units $mapping_sensortype);
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_NumericSensor');
$self->{output}->output_add(long_msg => "Checking cim numeric sensors");
$self->{components}->{cim_numericsensor} = {name => 'numeric sensors', total => 0, skip => 0};
return if ($self->check_filter(section => 'cim_numericsensor'));
foreach (@{$result}) {
my $sensor_type = defined($mapping_sensortype->{$_->{SensorType}}) ? $mapping_sensortype->{$_->{SensorType}} : 'unknown';
my $name = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
my $instance = $sensor_type . '_' . $name;
next if ($self->check_filter(section => 'cim_numericsensor', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping numeric sensor '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{cim_numericsensor}->{total}++;
my $value = $_->{CurrentReading};
$value = $value * 10 ** int($_->{UnitModifier}) if (defined($value) && $value =~ /\d/);
$self->{output}->output_add(long_msg => sprintf("Numeric sensor '%s' status is '%s' [instance: %s, current value: %s].",
$_->{ElementName}, $status,
$instance, defined($value) ? $value : '-'
));
my $exit = $self->get_severity(section => 'cim_numericsensor', label => 'default', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Numeric sensor '%s' status is '%s'",
$_->{ElementName}, $status));
}
next if (!defined($value) || $value !~ /\d/);
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'cim_numericsensor', instance => $instance, value => $value);
if ($checked == 0) {
my ($warn_th, $crit_th);
$warn_th = $_->{LowerThresholdNonCritical} * 10 ** int($_->{UnitModifier}) . ':' if (defined($_->{LowerThresholdNonCritical}) &&
$_->{LowerThresholdNonCritical} =~ /\d/);
if (defined($warn_th)) {
$warn_th .= ($_->{UpperThresholdNonCritical} * 10 ** int($_->{UnitModifier})) if (defined($_->{UpperThresholdNonCritical}) &&
$_->{UpperThresholdNonCritical} =~ /\d/);
} else {
$warn_th = '~:' . ($_->{UpperThresholdNonCritical} * 10 ** int($_->{UnitModifier})) if (defined($_->{UpperThresholdNonCritical}) &&
$_->{UpperThresholdNonCritical} =~ /\d/);
}
$crit_th = $_->{LowerThresholdCritical} * 10 ** int($_->{UnitModifier}) . ':' if (defined($_->{LowerThresholdCritical}) &&
$_->{LowerThresholdCritical} =~ /\d/);
if (defined($crit_th)) {
$crit_th .= ($_->{UpperThresholdCritical} * 10 ** int($_->{UnitModifier})) if (defined($_->{UpperThresholdCritical}) &&
$_->{UpperThresholdCritical} =~ /\d/);
} else {
$crit_th = '~:' . ($_->{UpperThresholdCritical} * 10 ** int($_->{UnitModifier})) if (defined($_->{UpperThresholdCritical}) &&
$_->{UpperThresholdCritical} =~ /\d/);
}
$self->{perfdata}->threshold_validate(label => 'warning-cim_numericsensor-instance-' . $instance, value => $warn_th);
$self->{perfdata}->threshold_validate(label => 'critical-cim_numericsensor-instance-' . $instance, value => $crit_th);
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-cim_numericsensor-instance-' . $instance);
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-cim_numericsensor-instance-' . $instance);
}
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Numeric sensor '%s' value is %s %s",
$_->{ElementName}, $value,
defined($mapping_units->{$_->{BaseUnits}}) ? $mapping_units->{$_->{BaseUnits}} : '-'));
}
my $min = defined($_->{MinReadable}) && $_->{MinReadable} =~ /\d/ ? $_->{MinReadable} * 10 ** int($_->{UnitModifier}) : undef;
my $max = defined($_->{MaxReadable}) && $_->{MaxReadable} =~ /\d/ ? $_->{MaxReadable} * 10 ** int($_->{UnitModifier}) : undef;
$self->{output}->perfdata_add(label => $instance, unit => $mapping_units->{$_->{BaseUnits}},
value => $value,
warning => $warn,
critical => $crit,
min => $min, max => $max);
}
}
1;

View File

@ -0,0 +1,62 @@
#
# 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::vmware::wsman::mode::components::cim_processor;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Processor');
$self->{output}->output_add(long_msg => "Checking cim processors");
$self->{components}->{cim_processor} = {name => 'processors', total => 0, skip => 0};
return if ($self->check_filter(section => 'cim_processor'));
foreach (@{$result}) {
my $instance = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
next if ($self->check_filter(section => 'cim_processor', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping processor '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{cim_processor}->{total}++;
my $model_name = defined($_->{ModelName}) && $_->{ModelName} ne '' ? $_->{ModelName} : 'unknown';
$model_name =~ s/\s+/ /g;
$self->{output}->output_add(long_msg => sprintf("Processor '%s' status is '%s' [instance: %s, Model: %s].",
$_->{ElementName}, $status,
$instance, $model_name
));
my $exit = $self->get_severity(section => 'cim_processor', label => 'default', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Processor '%s' status is '%s'",
$_->{ElementName}, $status));
}
}
}
1;

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::cim_recordlog;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_RecordLog');
$self->{output}->output_add(long_msg => "Checking cim recordlog");
$self->{components}->{cim_recordlog} = {name => 'recordlog', total => 0, skip => 0};
return if ($self->check_filter(section => 'cim_recordlog'));
foreach (@{$result}) {
my $instance = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
next if ($self->check_filter(section => 'cim_recordlog', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping record log '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{cim_recordlog}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Record log '%s' status is '%s' [instance: %s].",
$_->{ElementName}, $status,
$instance
));
my $exit = $self->get_severity(section => 'cim_recordlog', label => 'default', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Record log '%s' status is '%s'",
$_->{ElementName}, $status));
}
}
}
1;

View File

@ -0,0 +1,65 @@
#
# 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::vmware::wsman::mode::components::omc_discretesensor;
use strict;
use warnings;
use apps::vmware::wsman::mode::components::resources qw($mapping_EnableState);
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_DiscreteSensor');
$self->{output}->output_add(long_msg => "Checking OMC discrete sensors");
$self->{components}->{omc_discretesensor} = {name => 'omc discrete sensors', total => 0, skip => 0};
return if ($self->check_filter(section => 'omc_discretesensor'));
foreach (@{$result}) {
my $instance = $_->{Name};
next if ($self->check_filter(section => 'omc_discretesensor', instance => $instance));
if (defined($mapping_EnableState->{$_->{EnabledState}}) && $mapping_EnableState->{$_->{EnabledState}} !~ /enabled/i) {
$self->{output}->output_add(long_msg => sprintf("skipping discrete sensor '%s' : not enabled", $_->{Name}), debug => 1);
next;
}
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping discrete sensor '%s' : no status", $_->{Name}), debug => 1);
next;
}
$self->{components}->{omc_discretesensor}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Discrete sensor '%s' status is '%s' [instance: %s].",
$_->{Name}, $status,
$instance
));
my $exit = $self->get_severity(section => 'omc_discretesensor', label => 'default', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Discrete sensor '%s' status is '%s'",
$_->{Name}, $status));
}
}
}
1;

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::omc_fan;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_Fan');
$self->{output}->output_add(long_msg => "Checking OMC fans");
$self->{components}->{omc_fan} = {name => 'omc fans', total => 0, skip => 0};
return if ($self->check_filter(section => 'omc_fan'));
foreach (@{$result}) {
my $instance = $_->{Name};
next if ($self->check_filter(section => 'omc_fan', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping fan '%s' : no status", $_->{Name}), debug => 1);
next;
}
$self->{components}->{omc_fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance: %s].",
$_->{Name}, $status,
$instance
));
my $exit = $self->get_severity(section => 'omc_fan', label => 'default', value => $status);
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'",
$_->{Name}, $status));
}
}
}
1;

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::omc_psu;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_PowerSupply');
$self->{output}->output_add(long_msg => "Checking OMC power supplies");
$self->{components}->{omc_psu} = {name => 'omc psus', total => 0, skip => 0};
return if ($self->check_filter(section => 'omc_psu'));
foreach (@{$result}) {
my $instance = $_->{Name};
next if ($self->check_filter(section => 'omc_psu', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping power supply '%s' : no status", $_->{Name}), debug => 1);
next;
}
$self->{components}->{omc_psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance: %s].",
$_->{Name}, $status,
$instance
));
my $exit = $self->get_severity(section => 'omc_psu', label => 'default', value => $status);
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'",
$_->{Name}, $status));
}
}
}
1;

View File

@ -0,0 +1,173 @@
#
# 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::vmware::wsman::mode::components::resources;
use strict;
use warnings;
use Exporter;
our $mapping_HealthState;
our $mapping_OperationalStatus;
our $mapping_EnableState;
our $mapping_units;
our $mapping_sensortype;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw($mapping_HealthState $mapping_OperationalStatus $mapping_EnableState $mapping_units $mapping_sensortype);
$mapping_EnableState = {
0 => 'Unknown',
1 => 'Other',
2 => 'Enabled',
3 => 'Disabled',
4 => 'Shutting Down',
5 => 'Not Applicable',
6 => 'Enabled but Offline',
7 => 'In Test',
8 => 'Deferred',
9 => 'Quiesce',
10 => 'Starting',
};
$mapping_HealthState = {
0 => 'Unknown',
5 => 'OK',
10 => 'Degraded',
15 => 'Minor failure',
20 => 'Major failure',
25 => 'Critical failure',
30 => 'Non-recoverable error',
};
$mapping_OperationalStatus = {
0 => 'Unknown',
1 => 'Other',
2 => 'OK',
3 => 'Degraded',
4 => 'Stressed',
5 => 'Predictive Failure',
6 => 'Error',
7 => 'Non-Recoverable Error',
8 => 'Starting',
9 => 'Stopping',
10 => 'Stopped',
11 => 'In Service',
12 => 'No Contact',
13 => 'Lost Communication',
14 => 'Aborted',
15 => 'Dormant',
16 => 'Supporting Entity in Error',
17 => 'Completed',
18 => 'Power Mode',
19 => 'Relocating',
};
$mapping_sensortype = {
0 => 'unknown',
1 => 'other',
2 => 'temp', # Temperature
3 => 'volt', # Voltage
4 => 'current', # Current
5 => 'tachometer',
6 => 'counter',
7 => 'switch',
8 => 'lock',
9 => 'hum', # Humidity
10 => 'smoke_detection', # Smoke Detection
11 => 'presence',
12 => 'air_flow', # Air Flow
13 => 'power_consumption', # Power Consumption
14 => 'power_production', # Power Production
15 => 'pressure_intrusion', # PressureIntrusion
16 => 'intrusion',
};
$mapping_units = {
0 => '',
1 => '',
2 => 'C', # Degrees C
3 => 'F', # Degrees F
4 => 'K', # Degrees K
5 => 'V', # Volts
6 => 'A', # Amps,
7 => 'W', # Watts
8 => 'Joules',
9 => 'Coulombs',
10 => 'VA',
11 => 'Nits',
12 => 'Lumens',
13 => 'Lux',
14 => 'Candelas',
15 => 'kPa',
16 => 'PSI',
17 => 'Newtons',
18 => 'CFM',
19 => 'rpm',
20 => 'Hz', # Hertz
21 => 'Seconds',
22 => 'Minutes',
23 => 'Hours',
24 => 'Days',
25 => 'Weeks',
26 => 'Mils',
27 => 'Inches',
28 => 'Feet',
29 => 'Cubic_Inches',
30 => 'Cubic_Feet',
31 => 'Meters',
32 => 'Cubic_Centimeters',
33 => 'Cubic_Meters',
34 => 'Liters',
35 => 'Fluid_Ounces',
36 => 'Radians',
37 => 'Steradians',
38 => 'Revolutions',
39 => 'Cycles',
40 => 'Gravities',
41 => 'Ounces',
42 => 'Pounds',
43 => 'Foot_Pounds',
44 => 'Ounce_Inches',
45 => 'Gauss',
46 => 'Gilberts',
47 => 'Henries',
48 => 'Farads',
49 => 'Ohms',
50 => 'Siemens',
51 => 'Moles',
52 => 'Becquerels',
53 => 'PPM',
54 => 'Decibels',
55 => 'DbA',
56 => 'DbC',
57 => 'Grays',
58 => 'Sieverts',
59 => 'Color_Temperature_Degrees_K',
60 => 'b', # bits
61 => 'B', # Bytes
62 => 'Words',
63 => 'DoubleWords',
64 => 'QuadWords',
65 => '%', # Percentage,
66 => 'Pascals',
};
1;

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::vmware_battery;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.vmware.com/wbem/wscim/1/cim-schema/2/VMware_Battery');
$self->{output}->output_add(long_msg => "Checking vmware batteries");
$self->{components}->{vmware_battery} = {name => 'batteries', total => 0, skip => 0};
return if ($self->check_filter(section => 'vmware_battery'));
foreach (@{$result}) {
my $instance = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
next if ($self->check_filter(section => 'vmware_battery', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping battery '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{vmware_battery}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Battery '%s' status is '%s' [instance: %s].",
$_->{ElementName}, $status,
$instance
));
my $exit = $self->get_severity(section => 'vmware_battery', label => 'default', value => $status);
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'",
$_->{ElementName}, $status));
}
}
}
1;

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::vmware_controller;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.vmware.com/wbem/wscim/1/cim-schema/2/VMware_Controller');
$self->{output}->output_add(long_msg => "Checking vmware controller");
$self->{components}->{vmware_controller} = {name => 'controller', total => 0, skip => 0};
return if ($self->check_filter(section => 'vmware_controller'));
foreach (@{$result}) {
my $instance = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
next if ($self->check_filter(section => 'vmware_controller', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping controller '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{vmware_controller}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Controller '%s' status is '%s' [instance: %s].",
$_->{ElementName}, $status,
$instance
));
my $exit = $self->get_severity(section => 'vmware_controller', label => 'default', value => $status);
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'",
$_->{ElementName}, $status));
}
}
}
1;

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::vmware_sassataport;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.vmware.com/wbem/wscim/1/cim-schema/2/VMware_SASSATAPort');
$self->{output}->output_add(long_msg => "Checking vmware sas/sata ports");
$self->{components}->{vmware_sassataport} = {name => 'sas/sata ports', total => 0, skip => 0};
return if ($self->check_filter(section => 'vmware_sassataport'));
foreach (@{$result}) {
my $instance = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
next if ($self->check_filter(section => 'vmware_sassataport', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping sas/sata port '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{vmware_sassataport}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Sas/Sata port '%s' status is '%s' [instance: %s].",
$_->{ElementName}, $status,
$instance
));
my $exit = $self->get_severity(section => 'vmware_sassataport', label => 'default', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Sas/Sata port '%s' status is '%s'",
$_->{ElementName}, $status));
}
}
}
1;

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::vmware_storageextent;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.vmware.com/wbem/wscim/1/cim-schema/2/VMware_StorageExtent');
$self->{output}->output_add(long_msg => "Checking vmware storage extent");
$self->{components}->{vmware_storageextent} = {name => 'storage extent', total => 0, skip => 0};
return if ($self->check_filter(section => 'vmware_storageextent'));
foreach (@{$result}) {
my $instance = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
next if ($self->check_filter(section => 'vmware_storageextent', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping storage extent '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{vmware_storageextent}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Storage extent '%s' status is '%s' [instance: %s].",
$_->{ElementName}, $status,
$instance
));
my $exit = $self->get_severity(section => 'vmware_storageextent', label => 'default', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Storage extent '%s' status is '%s'",
$_->{ElementName}, $status));
}
}
}
1;

View File

@ -0,0 +1,60 @@
#
# 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::vmware::wsman::mode::components::vmware_storagevolume;
use strict;
use warnings;
sub check {
my ($self) = @_;
my $result = $self->{wsman}->request(uri => 'http://schemas.vmware.com/wbem/wscim/1/cim-schema/2/VMware_StorageVolume');
$self->{output}->output_add(long_msg => "Checking vmware storage volumes");
$self->{components}->{vmware_storagevolume} = {name => 'storage volumes', total => 0, skip => 0};
return if ($self->check_filter(section => 'vmware_storagevolume'));
foreach (@{$result}) {
my $instance = defined($_->{Name}) && $_->{Name} ne '' ? $_->{Name} : $_->{ElementName};
next if ($self->check_filter(section => 'vmware_storagevolume', instance => $instance));
my $status = $self->get_status(entry => $_);
if (!defined($status)) {
$self->{output}->output_add(long_msg => sprintf("skipping storage volume '%s' : no status", $_->{ElementName}), debug => 1);
next;
}
$self->{components}->{vmware_storagevolume}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Storage volume '%s' status is '%s' [instance: %s].",
$_->{ElementName}, $status,
$instance
));
my $exit = $self->get_severity(section => 'vmware_storagevolume', label => 'default', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Storage volume '%s' status is '%s'",
$_->{ElementName}, $status));
}
}
}
1;

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 apps::vmware::wsman::mode::hardware;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::vmware::wsman::mode::components::resources qw($mapping_HealthState $mapping_OperationalStatus);
my %type = ('cim_numericsensor' => 1);
my $thresholds = {
default => [
['Unknown', 'OK'],
['OK', 'OK'],
['Degraded', 'WARNING'],
['Minor failure', 'WARNING'],
['Major failure', 'CRITICAL'],
['Critical failure', 'CRITICAL'],
['Non-recoverable error', 'CRITICAL'],
['Other', 'UNKNOWN'],
['Stressed', 'WARNING'],
['Predictive Failure', 'WARNING'],
['Error', 'CRITICAL'],
['Starting', 'OK'],
['Stopping', 'WARNING'],
['In Service', 'OK'],
['No Contact', 'CRITICAL'],
['Lost Communication', 'CRITICAL'],
['Aborted', 'CRITICAL'],
['Dormant', 'OK'],
['Supporting Entity in Error', 'CRITICAL'],
['Completed', 'OK'],
['Power Mode', 'OK'],
['Relocating', 'WARNING'],
],
};
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 =>
{
"filter:s@" => { name => 'filter' },
"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} = {};
$self->{no_components} = undef;
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->{filter} = [];
foreach my $val (@{$self->{option_results}->{filter}}) {
next if (!defined($val) || $val eq '');
my @values = split (/,/, $val);
push @{$self->{filter}}, { filter => $values[0], instance => $values[1] };
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
next if (!defined($val) || $val eq '');
my @values = split (/,/, $val);
if (scalar(@values) < 3) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $instance, $status, $filter);
if (scalar(@values) == 3) {
($section, $status, $filter) = @values;
$instance = '.*';
} else {
($section, $instance, $status, $filter) = @values;
}
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, instance => $instance };
}
$self->{numeric_threshold} = {};
foreach my $option (('warning', 'critical')) {
foreach my $val (@{$self->{option_results}->{$option}}) {
next if (!defined($val) || $val eq '');
if ($val !~ /^(.*?),(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $instance, $value) = ($1, $2, $3);
if (!defined($type{$section})) {
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
$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, instance => $instance };
}
}
}
sub get_type {
my ($self, %options) = @_;
my $result = $self->{wsman}->request(uri => 'http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_SMASHFirmwareIdentity');
$result = pop(@$result);
$self->{manufacturer} = 'unknown';
if (defined($result->{Manufacturer}) && $result->{Manufacturer} ne '') {
$self->{manufacturer} = $result->{Manufacturer};
}
$result = $self->{wsman}->request(uri => 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis');
$result = pop(@$result);
my $model = defined($result->{Model}) && $result->{Model} ne '' ? $result->{Model} : 'unknown';
$self->{output}->output_add(long_msg => sprintf("Manufacturer : %s, Model : %s", $self->{manufacturer}, $model));
}
sub get_status {
my ($self, %options) = @_;
my $status;
if ($self->{manufacturer} =~ /HP/i) {
$status = $mapping_HealthState->{$options{entry}->{HealthState}} if (defined($options{entry}->{HealthState}) &&
defined($mapping_HealthState->{$options{entry}->{HealthState}}));
} else {
$status = $mapping_OperationalStatus->{$options{entry}->{OperationalStatus}} if (defined($options{entry}->{OperationalStatus}) &&
defined($mapping_OperationalStatus->{$options{entry}->{OperationalStatus}}));
}
return $status;
}
sub run {
my ($self, %options) = @_;
$self->{wsman} = $options{wsman};
$self->get_type();
my @components = ('omc_discretesensor', 'omc_fan', 'omc_psu', 'vmware_storageextent', 'vmware_controller',
'vmware_storagevolume', 'vmware_battery', 'vmware_sassataport', 'cim_card',
'cim_computersystem', 'cim_numericsensor', 'cim_memory', 'cim_processor', 'cim_recordlog');
foreach (@components) {
if (/$self->{option_results}->{component}/) {
my $mod_name = "apps::vmware::wsman::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('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 sensors 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 sensors are checked.');
}
$self->{output}->display();
$self->{output}->exit();
}
sub check_filter {
my ($self, %options) = @_;
foreach (@{$self->{filter}}) {
if ($options{section} =~ /$_->{filter}/) {
if (!defined($options{instance}) && !defined($_->{instance})) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
return 1;
} elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
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} =~ /$_->{instance}/) {
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 &&
(!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) {
$status = $_->{status};
return $status;
}
}
}
my $label = defined($options{label}) ? $options{label} : $options{section};
foreach (@{$thresholds->{$label}}) {
if ($options{value} =~ /$$_[0]/i) {
$status = $$_[1];
return $status;
}
}
return $status;
}
1;
__END__
=head1 MODE
Check ESXi Hardware.
Example: centreon_plugins.pl --plugin=apps::vmware::wsman::plugin --mode=hardware --hostname='XXX.XXX.XXX.XXX'
--wsman-username='XXXX' --wsman-password='XXXX' --wsman-scheme=https --wsman-port=443 --verbose
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'omc_discretesensor', 'omc_fan', 'omc_psu', 'vmware_storageextent', 'vmware_controller',
'vmware_storagevolume', 'vmware_battery', 'vmware_sassataport', 'cim_card',
'cim_computersystem', 'cim_numericsensor', 'cim_memory', 'cim_processor', 'cim_recordlog'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=cim_card --filter=cim_recordlog)
Can also exclude specific instance: --filter='omc_psu,Power Supply 1'
=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,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='cim_card,CRITICAL,^(?!(OK)$)'
=item B<--warning>
Set warning threshold for temperatures (syntax: type,instance,threshold)
Example: --warning='cim_numericsensor,.*,30'
=item B<--critical>
Set critical threshold for temperatures (syntax: type,instance,threshold)
Example: --critical='cim_numericsensor,.*,40'
=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::vmware::wsman::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_wsman);
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}} = (
'hardware' => 'apps::vmware::wsman::mode::hardware',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check VMWare ESXi Hardware (ws-management protocol).
=cut

View File

@ -161,7 +161,7 @@ sub run {
$self->manage_selection(); $self->manage_selection();
my $multiple = 1; my $multiple = 1;
if (scalar(keys %{$self->{ap_selected}}) == 1) { if (scalar(keys %{$self->{ap_selected}}) <= 1) {
$multiple = 0; $multiple = 0;
} }
@ -234,15 +234,19 @@ my $mapping3 = {
bsnAPAdminStatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.37', map => \%map_admin_status }, bsnAPAdminStatus => { oid => '.1.3.6.1.4.1.14179.2.2.1.1.37', map => \%map_admin_status },
}; };
my $oid_agentInventoryMachineModel = '.1.3.6.1.4.1.14179.1.1.1.3';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{ap_selected} = {}; $self->{ap_selected} = {};
$self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $mapping->{bsnAPName}->{oid} }, $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_agentInventoryMachineModel },
{ oid => $mapping->{bsnAPName}->{oid} },
{ oid => $mapping2->{bsnAPOperationStatus}->{oid} }, { oid => $mapping2->{bsnAPOperationStatus}->{oid} },
{ oid => $mapping3->{bsnAPAdminStatus}->{oid} }, { oid => $mapping3->{bsnAPAdminStatus}->{oid} },
], ],
nothing_quit => 1); nothing_quit => 1);
$self->{output}->output_add(long_msg => "Model: " . $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'});
foreach my $oid (keys %{$self->{results}->{ $mapping->{bsnAPName}->{oid} }}) { foreach my $oid (keys %{$self->{results}->{ $mapping->{bsnAPName}->{oid} }}) {
$oid =~ /^$mapping->{bsnAPName}->{oid}\.(.*)$/; $oid =~ /^$mapping->{bsnAPName}->{oid}\.(.*)$/;
my $instance = $1; my $instance = $1;
@ -251,7 +255,7 @@ sub manage_selection {
my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{ $mapping3->{bsnAPAdminStatus}->{oid} }, instance => $instance); my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{ $mapping3->{bsnAPAdminStatus}->{oid} }, instance => $instance);
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$result->{bsnAPName} !~ /$self->{option_results}->{filter_name}/) { $result->{bsnAPName} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "Skipping '" . $result->{bsnAPName} . "': no matching filter."); $self->{output}->output_add(long_msg => "Skipping '" . $result->{bsnAPName} . "': no matching filter.", debug => 1);
next; next;
} }
@ -260,8 +264,8 @@ sub manage_selection {
} }
if (scalar(keys %{$self->{ap_selected}}) <= 0) { if (scalar(keys %{$self->{ap_selected}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found."); $self->{output}->output_add(severity => 'OK',
$self->{output}->option_exit(); short_msg => 'No AP associated (can be: slave wireless controller or your filter)');
} }
} }

View File

@ -221,16 +221,20 @@ my $mapping2 = {
bsnMobileStationSsid => { oid => '.1.3.6.1.4.1.14179.2.1.4.1.7' }, bsnMobileStationSsid => { oid => '.1.3.6.1.4.1.14179.2.1.4.1.7' },
}; };
my $oid_agentInventoryMachineModel = '.1.3.6.1.4.1.14179.1.1.1.3';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{global} = { total => 0, total_idle => 0, total_aaapending => 0, total_authenticated => 0, $self->{global} = { total => 0, total_idle => 0, total_aaapending => 0, total_authenticated => 0,
total_associated => 0, total_powersave => 0, total_disassociated => 0, total_associated => 0, total_powersave => 0, total_disassociated => 0,
total_tobedeleted => 0, total_probing => 0, total_blacklisted => 0}; total_tobedeleted => 0, total_probing => 0, total_blacklisted => 0};
$self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $mapping->{bsnMobileStationStatus}->{oid} }, $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_agentInventoryMachineModel },
{ oid => $mapping->{bsnMobileStationStatus}->{oid} },
{ oid => $mapping2->{bsnMobileStationSsid}->{oid} }, { oid => $mapping2->{bsnMobileStationSsid}->{oid} },
], ],
nothing_quit => 1); nothing_quit => 1);
$self->{output}->output_add(long_msg => "Model: " . $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'});
foreach my $oid (keys %{$self->{results}->{ $mapping->{bsnMobileStationStatus}->{oid} }}) { foreach my $oid (keys %{$self->{results}->{ $mapping->{bsnMobileStationStatus}->{oid} }}) {
$oid =~ /^$mapping->{bsnMobileStationStatus}->{oid}\.(.*)$/; $oid =~ /^$mapping->{bsnMobileStationStatus}->{oid}\.(.*)$/;
my $instance = $1; my $instance = $1;

View File

@ -55,11 +55,11 @@ my $maps_counters = {
], ],
} }
}, },
'003_nsr' => { set => { '003_snr' => { set => {
key_values => [ { name => 'apSignalToNoiseRatio' }, { name => 'bssid' }, ], key_values => [ { name => 'apSignalToNoiseRatio' }, { name => 'bssid' }, ],
output_template => 'Signal to noise ratio : %d', output_template => 'Signal to noise ratio : %d',
perfdatas => [ perfdatas => [
{ label => 'nsr', value => 'apSignalToNoiseRatio_absolute', template => '%d', { label => 'snr', value => 'apSignalToNoiseRatio_absolute', template => '%d',
label_extra_instance => 1, instance_use => 'bssid_absolute' }, label_extra_instance => 1, instance_use => 'bssid_absolute' },
], ],
} }

View File

@ -396,7 +396,7 @@ sub manage_selection {
my $total_timeticks = 0; my $total_timeticks = 0;
foreach my $oid (keys %{$self->{results}->{$oid_wlsxUserEntry}}) { foreach my $oid (keys %{$self->{results}->{$oid_wlsxUserEntry}}) {
$oid =~ /^$mapping->{nUserAuthenticationMethod}->{oid}\.(.*)$/; next if ($oid !~ /^$mapping->{nUserAuthenticationMethod}->{oid}\.(.*)$/);
my $instance = $1; my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxUserEntry}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxUserEntry}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{nUserApBSSID}->{oid}}, instance => $instance); my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{nUserApBSSID}->{oid}}, instance => $instance);

View File

@ -56,6 +56,11 @@ sub check {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcPhysicalStatus}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcPhysicalStatus}, instance => $instance);
my $physical_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance}; my $physical_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
if (!defined($physical_descr)) {
$self->{output}->output_add(long_msg => sprintf("skipped instance '%s': no description", $instance));
next;
}
next if ($self->check_exclude(section => 'physical', instance => $instance)); next if ($self->check_exclude(section => 'physical', instance => $instance));
$self->{components}->{physical}->{total}++; $self->{components}->{physical}->{total}++;

View File

@ -64,7 +64,7 @@ sub check {
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is %s [instance: %s] [value: %s C]", $self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is %s [instance: %s] [value: %s C]",
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState}, $result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState},
$instance, $result->{ciscoEnvMonTemperatureStatusValue})); $instance, defined($result->{ciscoEnvMonTemperatureStatusValue}) ? $result->{ciscoEnvMonTemperatureStatusValue} : '-'));
my $exit = $self->get_severity(section => 'temperature', value => $result->{ciscoEnvMonTemperatureState}); my $exit = $self->get_severity(section => 'temperature', value => $result->{ciscoEnvMonTemperatureState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
@ -72,6 +72,8 @@ sub check {
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState})); $result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState}));
} }
next if (!defined($result->{ciscoEnvMonTemperatureStatusValue}));
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{ciscoEnvMonTemperatureStatusValue}); my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{ciscoEnvMonTemperatureStatusValue});
if ($checked == 0) { if ($checked == 0) {
my $warn_th = undef; my $warn_th = undef;

View File

@ -73,10 +73,12 @@ sub check {
$result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState})); $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState}));
} }
$result->{ciscoEnvMonVoltageStatusValue} = $result->{ciscoEnvMonVoltageStatusValue} / 1000;
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{ciscoEnvMonVoltageStatusValue}); my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{ciscoEnvMonVoltageStatusValue});
if ($checked == 0) { if ($checked == 0) {
my $warn_th = undef; my $warn_th = undef;
my $crit_th = $result->{ciscoEnvMonVoltageThresholdLow} . ':' . $result->{ciscoEnvMonVoltageThresholdHigh}; my $crit_th = ((defined($result->{ciscoEnvMonVoltageThresholdLow}) && $result->{ciscoEnvMonVoltageThresholdLow} =~ /\d/) ? sprintf("%.3f", $result->{ciscoEnvMonVoltageThresholdLow} / 1000) : 0) . ':' .
((defined($result->{ciscoEnvMonVoltageThresholdHigh}) && $result->{ciscoEnvMonVoltageThresholdHigh} =~ /\d/) ? sprintf("%.3f", $result->{ciscoEnvMonVoltageThresholdHigh} / 1000) : '');
$self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th); $self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th);
$self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th); $self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th);
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance); $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance);
@ -84,10 +86,10 @@ sub check {
} }
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2, $self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Voltage '%s' is %s V", $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageStatusValue})); short_msg => sprintf("Voltage '%s' is %.3f V", $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageStatusValue}));
} }
$self->{output}->perfdata_add(label => "voltage_" . $result->{ciscoEnvMonVoltageStatusDescr}, unit => 'V', $self->{output}->perfdata_add(label => "voltage_" . $result->{ciscoEnvMonVoltageStatusDescr}, unit => 'V',
value => $result->{ciscoEnvMonVoltageStatusValue}, value => sprintf("%.3f", $result->{ciscoEnvMonVoltageStatusValue}),
warning => $warn, warning => $warn,
critical => $crit); critical => $crit);
} }

View File

@ -0,0 +1,82 @@
#
# 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::common::force10::snmp::mode::components::fan;
use strict;
use warnings;
my %map_status = (
1 => 'up',
2 => 'down',
3 => 'absent',
);
my $mapping = {
sseries => {
OperStatus => { oid => '.1.3.6.1.4.1.6027.3.10.1.2.4.1.2', map => \%map_status },
},
mseries => {
OperStatus => { oid => '.1.3.6.1.4.1.6027.3.19.1.2.3.1.2', map => \%map_status },
},
zseries => {
OperStatus => { oid => '.1.3.6.1.4.1.6027.3.25.1.2.7.1.2', map => \%map_status },
},
};
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{sseries}->{OperStatus}->{oid} },
{ oid => $mapping->{mseries}->{OperStatus}->{oid} }, { oid => $mapping->{zseries}->{OperStatus}->{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_filter(section => 'fan'));
foreach my $name (keys %{$mapping}) {
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{$name}->{OperStatus}->{oid}}})) {
next if ($oid !~ /^$mapping->{$name}->{OperStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping->{$name}, results => $self->{results}->{$mapping->{$name}->{OperStatus}->{oid}}, instance => $instance);
next if ($result->{OperStatus} =~ /absent/i &&
$self->absent_problem(section => 'fan', instance => $instance));
next if ($self->check_filter(section => 'fan', instance => $instance));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance: %s]",
$instance, $result->{OperStatus},
$instance));
my $exit = $self->get_severity(section => 'fan', value => $result->{OperStatus});
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->{OperStatus}));
}
}
}
}
1;

View File

@ -0,0 +1,90 @@
#
# 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::common::force10::snmp::mode::components::psu;
use strict;
use warnings;
my %map_status = (
1 => 'up',
2 => 'down',
3 => 'absent',
);
my %map_mstatus = (
1 => 'normal',
2 => 'warning',
3 => 'critical',
4 => 'shutdown',
5 => 'notPresent',
6 => 'notFunctioning',
);
my $mapping = {
sseries => {
OperStatus => { oid => '.1.3.6.1.4.1.6027.3.10.1.2.3.1.2', map => \%map_status },
},
mseries => {
OperStatus => { oid => '.1.3.6.1.4.1.6027.3.19.1.2.2.1.2', map => \%map_mstatus },
},
zseries => {
OperStatus => { oid => '.1.3.6.1.4.1.6027.3.25.1.2.6.1.2', map => \%map_status },
},
};
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{sseries}->{OperStatus}->{oid} },
{ oid => $mapping->{mseries}->{OperStatus}->{oid} }, { oid => $mapping->{zseries}->{OperStatus}->{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_filter(section => 'psu'));
foreach my $name (keys %{$mapping}) {
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{$name}->{OperStatus}->{oid}}})) {
next if ($oid !~ /^$mapping->{$name}->{OperStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping->{$name}, results => $self->{results}->{$mapping->{$name}->{OperStatus}->{oid}}, instance => $instance);
next if ($result->{OperStatus} =~ /absent|notPresent/i &&
$self->absent_problem(section => 'psu', instance => $instance));
next if ($self->check_filter(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance: %s]",
$instance, $result->{OperStatus},
$instance));
my $exit = $self->get_severity(section => 'psu', value => $result->{OperStatus});
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->{OperStatus}));
}
}
}
}
1;

View File

@ -0,0 +1,76 @@
#
# 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::common::force10::snmp::mode::components::temperature;
use strict;
use warnings;
my $mapping = {
sseries => {
Temp => { oid => '.1.3.6.1.4.1.6027.3.10.1.2.2.1.14' },
},
mseries => {
Temp => { oid => '.1.3.6.1.4.1.6027.3.19.1.2.1.1.14' },
},
};
my $oid_deviceSensorValueEntry = '.1.3.6.1.4.1.3417.2.1.1.1.1.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{sseries}->{Temp}->{oid} },
{ oid => $mapping->{mseries}->{Temp}->{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_filter(section => 'temperature'));
foreach my $name (keys %{$mapping}) {
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{$name}->{Temp}->{oid}}})) {
next if ($oid !~ /^$mapping->{$name}->{Temp}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping->{$name}, results => $self->{results}->{$mapping->{$name}->{Temp}->{oid}}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' is %s C [instance: %s]",
$instance, $result->{Temp},
$instance));
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{Temp});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' is %s C", $instance, $result->{Temp}));
}
$self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C',
value => $result->{Temp},
warning => $warn,
critical => $crit);
}
}
}
1;

View File

@ -0,0 +1,243 @@
#
# 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::common::force10::snmp::mode::cpu;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::values;
my $instance_mode;
my $maps_counters = {
cpu => {
'000_5s' => {
set => {
key_values => [ { name => 'usage_5s' }, { name => 'display' } ],
output_template => '%s %% (5sec)', output_error_template => "%s (5sec)",
perfdatas => [
{ label => 'cpu_5s', value => 'usage_5s_absolute', template => '%d',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
],
},
},
'001_1m' => {
set => {
key_values => [ { name => 'usage_1m' }, { name => 'display' } ],
output_template => '%s %% (1m)', output_error_template => "%s (1min)",
perfdatas => [
{ label => 'cpu_1m', value => 'usage_1m_absolute', template => '%d',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
],
},
},
'002_5m' => {
set => {
key_values => [ { name => 'usage_5m' }, { name => 'display' } ],
output_template => '%s %% (5min)', output_error_template => "%s (5min)",
perfdatas => [
{ label => 'cpu_5m', value => 'usage_5m_absolute', template => '%d',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
],
},
},
}
};
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 =>
{
});
foreach my $key (('cpu')) {
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(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 (('cpu')) {
foreach (keys %{$maps_counters->{$key}}) {
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
}
}
$instance_mode = $self;
}
sub run_instances {
my ($self, %options) = @_;
my $multiple = 1;
if (scalar(keys %{$self->{cpu}}) == 1) {
$multiple = 0;
}
if ($multiple == 1) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All CPU usages are ok');
}
foreach my $id (sort keys %{$self->{cpu}}) {
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits = ();
foreach (sort keys %{$maps_counters->{cpu}}) {
my $obj = $maps_counters->{cpu}->{$_}->{obj};
$obj->set(instance => $id);
my ($value_check) = $obj->execute(values => $self->{cpu}->{$id});
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(extra_instance => $multiple);
}
my $prefix = "CPU Usage ";
if ($multiple == 1) {
$prefix = sprintf("CPU '%s' Usage ", $self->{cpu}->{$id}->{display});
}
$self->{output}->output_add(long_msg => "${prefix}$long_msg");
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 => "${prefix}$short_msg"
);
}
if ($multiple == 0) {
$self->{output}->output_add(short_msg => "${prefix}$long_msg");
}
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
$self->run_instances();
$self->{output}->display();
$self->{output}->exit();
}
my $mapping = {
sseries => {
Util5Sec => { oid => '.1.3.6.1.4.1.6027.3.10.1.2.9.1.2' },
Util1Min => { oid => '.1.3.6.1.4.1.6027.3.10.1.2.9.1.3' },
Util5Min => { oid => '.1.3.6.1.4.1.6027.3.10.1.2.9.1.4' },
},
mseries => {
Util5Sec => { oid => '.1.3.6.1.4.1.6027.3.19.1.2.8.1.2' },
Util1Min => { oid => '.1.3.6.1.4.1.6027.3.19.1.2.8.1.3' },
Util5Min => { oid => '.1.3.6.1.4.1.6027.3.19.1.2.8.1.4' },
},
zseries => {
Util5Sec => { oid => '.1.3.6.1.4.1.6027.3.25.1.2.3.1.1' },
Util1Min => { oid => '.1.3.6.1.4.1.6027.3.25.1.2.3.1.2' },
Util5Min => { oid => '.1.3.6.1.4.1.6027.3.25.1.2.3.1.3' },
},
};
sub manage_selection {
my ($self, %options) = @_;
my $oids = { sseries => '.1.3.6.1.4.1.6027.3.10.1.2.9.1', mseries => '.1.3.6.1.4.1.6027.3.19.1.2.8.1', zseries => '.1.3.6.1.4.1.6027.3.25.1.2.3.1' };
my $results = $options{snmp}->get_multiple_table(oids => [ { oid => $oids->{sseries} }, { oid => $oids->{mseries} }, { oid => $oids->{zseries} } ],
nothing_quit => 1);
$self->{cpu} = {};
foreach my $name (keys %{$oids}) {
foreach my $oid (keys %{$results->{$oids->{$name}}}) {
next if ($oid !~ /^$mapping->{$name}->{Util5Min}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping->{$name}, results => $results->{$oids->{$name}}, instance => $instance);
$self->{cpu}->{$instance} = { display => $instance,
usage_5s => $result->{Util5Sec},
usage_1m => $result->{Util1Min},
usage_5m => $result->{Util5Min},
};
}
}
if (scalar(keys %{$self->{cpu}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check cpu usages.
=over 8
=item B<--warning-*>
Threshold warning.
Can be: '5s', '1m', '5m'.
=item B<--critical-*>
Threshold critical.
Can be: '5s', '1m', '5m'.
=back
=cut

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 centreon::common::force10::snmp::mode::hardware;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
my $thresholds = {
fan => [
['up', 'OK'],
['absent', 'OK'],
['down', 'CRITICAL'],
],
psu => [
['up', 'OK'],
['absent', 'OK'],
['down', 'CRITICAL'],
['normal', 'OK'],
['warning', 'WARNING'],
['critical', 'CRITICAL'],
['shutdown', 'CRITICAL'],
['notPresent', 'OK'],
['notFunctioning', '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 =>
{
"filter:s@" => { name => 'filter' },
"absent-problem:s@" => { name => 'absent_problem' },
"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} = {};
$self->{no_components} = undef;
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->{filter} = [];
foreach my $val (@{$self->{option_results}->{filter}}) {
next if (!defined($val) || $val eq '');
my @values = split (/,/, $val);
push @{$self->{filter}}, { filter => $values[0], instance => $values[1] };
}
$self->{absent_problem} = [];
foreach my $val (@{$self->{option_results}->{absent_problem}}) {
next if (!defined($val) || $val eq '');
my @values = split (/,/, $val);
push @{$self->{absent_problem}}, { filter => $values[0], instance => $values[1] };
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
next if (!defined($val) || $val eq '');
my @values = split (/,/, $val);
if (scalar(@values) < 3) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $instance, $status, $filter);
if (scalar(@values) == 3) {
($section, $status, $filter) = @values;
$instance = '.*';
} else {
($section, $instance, $status, $filter) = @values;
}
if ($section !~ /^psu|fan$/) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload section '" . $val . "'.");
$self->{output}->option_exit();
}
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, instance => $instance };
}
$self->{numeric_threshold} = {};
foreach my $option (('warning', 'critical')) {
foreach my $val (@{$self->{option_results}->{$option}}) {
next if (!defined($val) || $val eq '');
if ($val !~ /^(.*?),(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $instance, $value) = ($1, $2, $3);
if ($section !~ /^temperature$/) {
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
$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, instance => $instance };
}
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $snmp_request = [];
my @components = ('fan', 'psu', 'temperature');
foreach (@components) {
if (/$self->{option_results}->{component}/) {
my $mod_name = "centreon::common::force10::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}) == 0) {
$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 (@components) {
if (/$self->{option_results}->{component}/) {
my $mod_name = "centreon::common::force10::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 absent_problem {
my ($self, %options) = @_;
foreach (@{$self->{absent_problem}}) {
if ($options{section} =~ /$_->{filter}/) {
if (!defined($_->{instance}) || $options{instance} =~ /$_->{instance}/) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Component '%s' instance '%s' is not present",
$options{section}, $options{instance}));
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)"));
$self->{components}->{$options{section}}->{skip}++;
return 1;
}
}
}
return 0;
}
sub check_filter {
my ($self, %options) = @_;
foreach (@{$self->{filter}}) {
if ($options{section} =~ /$_->{filter}/) {
if (!defined($options{instance}) && !defined($_->{instance})) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
return 1;
} elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
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} =~ /$_->{instance}/) {
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 &&
(!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) {
$status = $_->{status};
return $status;
}
}
}
my $label = defined($options{label}) ? $options{label} : $options{section};
foreach (@{$thresholds->{$label}}) {
if ($options{value} =~ /$$_[0]/i) {
$status = $$_[1];
return $status;
}
}
return $status;
}
1;
__END__
=head1 MODE
Check Hardware (Fan, Power Supply, Temperature).
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'temperature', 'fan', 'psu'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=temperature --filter=psu)
Can also exclude specific instance: --filter=fan,1
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
Can be specific or global: --absent-problem=fan,1
=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,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='psu,WARNING,^(?!(up)$)'
=item B<--warning>
Set warning threshold for temperatures (syntax: type,instance,threshold)
Example: --warning='temperature,.*,30'
=item B<--critical>
Set critical threshold for temperatures (syntax: type,instance,threshold)
Example: --critical='temperature,.*,40'
=back
=cut

View File

@ -0,0 +1,213 @@
#
# 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::common::force10::snmp::mode::memory;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::values;
my $instance_mode;
my $maps_counters = {
mem => {
'000_usage' => {
set => {
key_values => [ { name => 'usage' }, { name => 'display' } ],
output_template => '%s %%', output_error_template => "%s",
perfdatas => [
{ label => 'used', value => 'usage_absolute', template => '%d',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
],
},
},
}
};
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 =>
{
});
foreach my $key (('mem')) {
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(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 (('mem')) {
foreach (keys %{$maps_counters->{$key}}) {
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
}
}
$instance_mode = $self;
}
sub run_instances {
my ($self, %options) = @_;
my $multiple = 1;
if (scalar(keys %{$self->{mem}}) == 1) {
$multiple = 0;
}
if ($multiple == 1) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All memory usages are ok');
}
foreach my $id (sort keys %{$self->{mem}}) {
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits = ();
foreach (sort keys %{$maps_counters->{mem}}) {
my $obj = $maps_counters->{mem}->{$_}->{obj};
$obj->set(instance => $id);
my ($value_check) = $obj->execute(values => $self->{mem}->{$id});
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(extra_instance => $multiple);
}
my $prefix = "Memory Usage ";
if ($multiple == 1) {
$prefix = sprintf("Memory '%s' Usage ", $self->{mem}->{$id}->{display});
}
$self->{output}->output_add(long_msg => "${prefix}$long_msg");
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 => "${prefix}$short_msg"
);
}
if ($multiple == 0) {
$self->{output}->output_add(short_msg => "${prefix}$long_msg");
}
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
$self->run_instances();
$self->{output}->display();
$self->{output}->exit();
}
my $mapping = {
sseries => {
MemUsageUtil => { oid => '.1.3.6.1.4.1.6027.3.10.1.2.9.1.5' },
},
mseries => {
MemUsageUtil => { oid => '.1.3.6.1.4.1.6027.3.19.1.2.8.1.5' },
},
zseries => {
MemUsageUtil => { oid => '.1.3.6.1.4.1.6027.3.25.1.2.3.1.4' },
},
};
sub manage_selection {
my ($self, %options) = @_;
my $oids = { sseries => '.1.3.6.1.4.1.6027.3.10.1.2.9.1', mseries => '.1.3.6.1.4.1.6027.3.19.1.2.8.1', zseries => '.1.3.6.1.4.1.6027.3.25.1.2.3.1' };
my $results = $options{snmp}->get_multiple_table(oids => [ { oid => $oids->{sseries} }, { oid => $oids->{mseries} }, { oid => $oids->{zseries} } ],
nothing_quit => 1);
$self->{mem} = {};
foreach my $name (keys %{$oids}) {
foreach my $oid (keys %{$results->{$oids->{$name}}}) {
next if ($oid !~ /^$mapping->{$name}->{MemUsageUtil}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping->{$name}, results => $results->{$oids->{$name}}, instance => $instance);
$self->{mem}->{$instance} = { display => $instance,
usage => $result->{MemUsageUtil},
};
}
}
if (scalar(keys %{$self->{mem}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check memory usages.
=over 8
=item B<--warning-usage>
Threshold warning (in percent).
=item B<--critical-usage>
Threshold critical (in percent).
=back
=cut

View File

@ -89,7 +89,7 @@ sub GetOptions {
splice @ARGV, $i, 1; splice @ARGV, $i, 1;
$num_args--; $num_args--;
} else { } else {
warn "argument $ARGV[$i] alone" if ($warn_message == 1); warn "argument $ARGV[$i] alone" if ($warn_message == 1 && $i != 0);
$i++; $i++;
} }
} }

View File

@ -25,6 +25,8 @@ use warnings;
use DBI; use DBI;
use Digest::MD5 qw(md5_hex); use Digest::MD5 qw(md5_hex);
my %handlers = ( ALRM => {} );
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = {}; my $self = {};
@ -50,6 +52,7 @@ sub new {
"password:s@" => { name => 'password' }, "password:s@" => { name => 'password' },
"connect-options:s@" => { name => 'connect_options' }, "connect-options:s@" => { name => 'connect_options' },
"sql-errors-exit:s" => { name => 'sql_errors_exit', default => 'unknown' }, "sql-errors-exit:s" => { name => 'sql_errors_exit', default => 'unknown' },
"timeout:i" => { name => 'timeout' },
}); });
} }
$options{options}->add_help(package => __PACKAGE__, sections => 'DBI OPTIONS', once => 1); $options{options}->add_help(package => __PACKAGE__, sections => 'DBI OPTIONS', once => 1);
@ -69,9 +72,33 @@ sub new {
# Sometimes, we need to set ENV # Sometimes, we need to set ENV
$self->{env} = undef; $self->{env} = undef;
$self->set_signal_handlers();
return $self; 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 => $self->{sql_errors_exit},
short_msg => "Timeout");
$self->{output}->display();
$self->{output}->exit();
}
# Method to manage multiples # Method to manage multiples
sub set_options { sub set_options {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -111,6 +138,12 @@ sub check_options {
$self->{env} = (defined($self->{option_results}->{env})) ? shift(@{$self->{option_results}->{env}}) : undef; $self->{env} = (defined($self->{option_results}->{env})) ? shift(@{$self->{option_results}->{env}}) : undef;
$self->{sql_errors_exit} = $self->{option_results}->{sql_errors_exit}; $self->{sql_errors_exit} = $self->{option_results}->{sql_errors_exit};
$self->{timeout} = 10;
if (defined($self->{option_results}->{timeout}) && $self->{option_results}->{timeout} =~ /^\d+$/ &&
$self->{option_results}->{timeout} > 0) {
$self->{timeout} = $self->{option_results}->{timeout};
}
if (!defined($self->{data_source}) || $self->{data_source} eq '') { if (!defined($self->{data_source}) || $self->{data_source} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify data_source arguments."); $self->{output}->add_option_msg(short_msg => "Need to specify data_source arguments.");
$self->{output}->option_exit(exit_litteral => $self->{sql_errors_exit}); $self->{output}->option_exit(exit_litteral => $self->{sql_errors_exit});
@ -169,12 +202,14 @@ sub connect {
} }
} }
alarm($self->{timeout}) if (defined($self->{timeout}));
$self->{instance} = DBI->connect( $self->{instance} = DBI->connect(
"DBI:". $self->{data_source}, "DBI:". $self->{data_source},
$self->{username}, $self->{username},
$self->{password}, $self->{password},
{ "RaiseError" => 0, "PrintError" => 0, "AutoCommit" => 1, %{$self->{connect_options_hash}} } { "RaiseError" => 0, "PrintError" => 0, "AutoCommit" => 1, %{$self->{connect_options_hash}} }
); );
alarm(0) if (defined($self->{timeout}));
if (!defined($self->{instance})) { if (!defined($self->{instance})) {
my $err_msg = sprintf("Cannot connect: %s", defined($DBI::errstr) ? $DBI::errstr : "(no error string)"); my $err_msg = sprintf("Cannot connect: %s", defined($DBI::errstr) ? $DBI::errstr : "(no error string)");
@ -272,6 +307,10 @@ Format: name=value,name2=value2,...
Exit code for DB Errors (default: unknown) Exit code for DB Errors (default: unknown)
=item B<--timeout>
Timeout in seconds for connection
=back =back
=head1 DESCRIPTION =head1 DESCRIPTION

View File

@ -25,7 +25,7 @@ use Pod::Find qw(pod_where);
use strict; use strict;
use warnings; use warnings;
my $alternative = 0; my $alternative = 1;
sub new { sub new {
my $class = shift; my $class = shift;

View File

@ -29,7 +29,9 @@ use FindBin;
use Pod::Usage; use Pod::Usage;
use Pod::Find qw(pod_where); use Pod::Find qw(pod_where);
my %handlers = ('DIE' => {}); my %handlers = (DIE => {});
my $global_version = 20151126;
sub new { sub new {
my $class = shift; my $class = shift;
@ -242,6 +244,10 @@ sub run {
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
if (!defined($self->{plugin}) || $self->{plugin} eq '') { if (!defined($self->{plugin}) || $self->{plugin} eq '') {
if (defined($self->{version})) {
$self->{output}->add_option_msg(short_msg => "Global Version: " . $global_version);
$self->{output}->option_exit(nolabel => 1);
}
$self->{output}->add_option_msg(short_msg => "Need to specify '--plugin' option."); $self->{output}->add_option_msg(short_msg => "Need to specify '--plugin' option.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
@ -285,7 +291,7 @@ Print available plugins.
=item B<--version> =item B<--version>
Print plugin version. Print global version.
=item B<--help> =item B<--help>

View File

@ -42,7 +42,7 @@ sub new {
'custommode:s' => { name => 'custommode_name' }, 'custommode:s' => { name => 'custommode_name' },
'list-custommode' => { name => 'list_custommode' }, 'list-custommode' => { name => 'list_custommode' },
'multiple' => { name => 'multiple' }, 'multiple' => { name => 'multiple' },
'sanity-options' => { name => 'sanity_options' }, 'sanity-options' => { name => 'sanity_options' }, # keep it for 6 month before remove it
} }
); );
$self->{version} = '1.0'; $self->{version} = '1.0';
@ -93,9 +93,7 @@ sub init {
if (defined($self->{list_custommode})) { if (defined($self->{list_custommode})) {
$self->list_custommode(); $self->list_custommode();
} }
if (defined($self->{sanity_options})) { $self->{options}->set_sanity();
$self->{options}->set_sanity();
}
# Output HELP # Output HELP
$self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS');
@ -264,10 +262,6 @@ Check minimal version of mode. If not, unknown error.
Display plugin version. Display plugin version.
=item B<--sanity-options>
Check unknown options (for debug purpose).
=item B<--custommode> =item B<--custommode>
Choose a custom mode. Choose a custom mode.

View File

@ -39,7 +39,7 @@ sub new {
'dyn-mode:s' => { name => 'dynmode_name' }, 'dyn-mode:s' => { name => 'dynmode_name' },
'list-mode' => { name => 'list_mode' }, 'list-mode' => { name => 'list_mode' },
'mode-version:s' => { name => 'mode_version' }, 'mode-version:s' => { name => 'mode_version' },
'sanity-options' => { name => 'sanity_options' }, 'sanity-options' => { name => 'sanity_options' }, # keep it for 6 month before remove it
} }
); );
$self->{version} = '1.0'; $self->{version} = '1.0';
@ -74,9 +74,7 @@ sub init {
if (defined($self->{list_mode})) { if (defined($self->{list_mode})) {
$self->list_mode(); $self->list_mode();
} }
if (defined($self->{sanity_options})) { $self->{options}->set_sanity();
$self->{options}->set_sanity();
}
# Output HELP # Output HELP
$self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS');
@ -200,10 +198,6 @@ Check minimal version of mode. If not, unknown error.
Display plugin version. Display plugin version.
=item B<--sanity-options>
Check unknown options (for debug purpose).
=back =back
=head1 DESCRIPTION =head1 DESCRIPTION

View File

@ -41,7 +41,7 @@ sub new {
'dyn-mode:s' => { name => 'dynmode_name' }, 'dyn-mode:s' => { name => 'dynmode_name' },
'list-mode' => { name => 'list_mode' }, 'list-mode' => { name => 'list_mode' },
'mode-version:s' => { name => 'mode_version' }, 'mode-version:s' => { name => 'mode_version' },
'sanity-options' => { name => 'sanity_options' }, 'sanity-options' => { name => 'sanity_options' }, # keep it for 6 month before remove it
} }
); );
$self->{version} = '1.0'; $self->{version} = '1.0';
@ -76,9 +76,7 @@ sub init {
if (defined($self->{list_mode})) { if (defined($self->{list_mode})) {
$self->list_mode(); $self->list_mode();
} }
if (defined($self->{sanity_options})) { $self->{options}->set_sanity();
$self->{options}->set_sanity();
}
# Output HELP # Output HELP
$self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS');
@ -208,10 +206,6 @@ Check minimal version of mode. If not, unknown error.
Display plugin version. Display plugin version.
=item B<--sanity-options>
Check unknown options (for debug purpose).
=back =back
=head1 DESCRIPTION =head1 DESCRIPTION

View File

@ -43,7 +43,7 @@ sub new {
'sqlmode:s' => { name => 'sqlmode_name', default => 'dbi' }, 'sqlmode:s' => { name => 'sqlmode_name', default => 'dbi' },
'list-sqlmode' => { name => 'list_sqlmode' }, 'list-sqlmode' => { name => 'list_sqlmode' },
'multiple' => { name => 'multiple' }, 'multiple' => { name => 'multiple' },
'sanity-options' => { name => 'sanity_options' }, 'sanity-options' => { name => 'sanity_options' }, # keep it for 6 month before remove it
} }
); );
$self->{version} = '1.0'; $self->{version} = '1.0';
@ -85,9 +85,7 @@ sub init {
if (defined($self->{list_sqlmode})) { if (defined($self->{list_sqlmode})) {
$self->list_sqlmode(); $self->list_sqlmode();
} }
if (defined($self->{sanity_options})) { $self->{options}->set_sanity();
$self->{options}->set_sanity();
}
# Output HELP # Output HELP
$self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS');
@ -261,10 +259,6 @@ Check minimal version of mode. If not, unknown error.
Display plugin version. Display plugin version.
=item B<--sanity-options>
Check unknown options (for debug purpose).
=item B<--sqlmode> =item B<--sqlmode>
Choose a sql mode (Default: "dbi"). Choose a sql mode (Default: "dbi").

View File

@ -41,7 +41,7 @@ sub new {
'dyn-mode:s' => { name => 'dynmode_name' }, 'dyn-mode:s' => { name => 'dynmode_name' },
'list-mode' => { name => 'list_mode' }, 'list-mode' => { name => 'list_mode' },
'mode-version:s' => { name => 'mode_version' }, 'mode-version:s' => { name => 'mode_version' },
'sanity-options' => { name => 'sanity_options' }, 'sanity-options' => { name => 'sanity_options' }, # keep it for 6 month before remove it
} }
); );
$self->{version} = '1.0'; $self->{version} = '1.0';
@ -76,9 +76,7 @@ sub init {
if (defined($self->{list_mode})) { if (defined($self->{list_mode})) {
$self->list_mode(); $self->list_mode();
} }
if (defined($self->{sanity_options})) { $self->{options}->set_sanity();
$self->{options}->set_sanity();
}
# Output HELP # Output HELP
$self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS'); $self->{options}->add_help(package => 'centreon::plugins::output', sections => 'OUTPUT OPTIONS');
@ -204,10 +202,6 @@ Check minimal version of mode. If not, unknown error.
Display plugin version. Display plugin version.
=item B<--sanity-options>
Check unknown options (for debug purpose).
=back =back
=head1 DESCRIPTION =head1 DESCRIPTION

View File

@ -312,8 +312,8 @@ sub request {
###### ######
# Check options # Check options
if (!defined($options{uri}) || !defined($options{wql_filter})) { if (!defined($options{uri})) {
$self->{output}->add_option_msg(short_msg => 'Need to specify wql_filter and uri options'); $self->{output}->add_option_msg(short_msg => 'Need to specify uri option');
$self->{output}->option_exit(exit_litteral => $self->{wsman_errors_exit}); $self->{output}->option_exit(exit_litteral => $self->{wsman_errors_exit});
} }
@ -328,9 +328,12 @@ sub request {
###### ######
# Filter/Enumerate # Filter/Enumerate
my $filter = new openwsman::Filter::() my $filter;
if (defined($options{wql_filter})) {
$filter = new openwsman::Filter::()
or $self->internal_exit(msg => 'Could not create filter'); or $self->internal_exit(msg => 'Could not create filter');
$filter->wql($options{wql_filter}); $filter->wql($options{wql_filter});
}
my $result = $self->{client}->enumerate($client_options, $filter, $options{uri}); my $result = $self->{client}->enumerate($client_options, $filter, $options{uri});
return undef if ($self->handle_dialog_fault(result => $result, msg => 'Could not enumerate instances: ', dont_quit => $dont_quit)); return undef if ($self->handle_dialog_fault(result => $result, msg => 'Could not enumerate instances: ', dont_quit => $dont_quit));

View File

@ -0,0 +1,2 @@
2015-11-26 Quentin Garnier
* initial release

View File

@ -27,11 +27,10 @@ use warnings;
use centreon::plugins::misc; use centreon::plugins::misc;
use POSIX; use POSIX;
use JSON; use JSON;
use Module::Load;
my $CloudwatchMetrics = { my $CloudwatchMetrics = {
cpu => "cloud::aws::mode::metrics::ec2instancecpu", cpu => "cloud::aws::mode::metrics::ec2instancecpu",
traffic' => "cloud::aws::mode::metrics::ec2instancenetwork", traffic => "cloud::aws::mode::metrics::ec2instancenetwork",
cpucreditusage => "cloud::aws::mode::metrics::ec2instancecpucreditusage", cpucreditusage => "cloud::aws::mode::metrics::ec2instancecpucreditusage",
cpucreditbalance => "cloud::aws::mode::metrics::ec2instancecpucreditbalance", cpucreditbalance => "cloud::aws::mode::metrics::ec2instancecpucreditbalance",
bucketsize => "cloud::aws::mode::metrics::s3bucketsize", bucketsize => "cloud::aws::mode::metrics::s3bucketsize",
@ -192,12 +191,12 @@ sub run {
my ( $msg, $exit_code, $awsapi ); my ( $msg, $exit_code, $awsapi );
if ( defined( $CloudwatchMetrics->{ $self->{option_results}->{metric} } ) ) if ( defined( $CloudwatchMetrics->{ $self->{option_results}->{metric} } ) ) {
{ centreon::plugins::misc::mymodule_load(output => $options{output}, module => $CloudwatchMetrics->{$self->{option_results}->{metric}},
load $CloudwatchMetrics->{ $self->{option_results}->{metric} },qw/cloudwatchCheck/; error_msg => "Cannot load module '" . $CloudwatchMetrics->{$self->{option_results}->{metric}} . "'.");
cloudwatchCheck($self); my $func = $CloudwatchMetrics->{$self->{option_results}->{metric}}->can('cloudwatchCheck');
} $func->($self);
else { } else {
$self->{output} $self->{output}
->add_option_msg( short_msg => "Wrong option. Cannot find metric '" ->add_option_msg( short_msg => "Wrong option. Cannot find metric '"
. $self->{option_results}->{metric} . $self->{option_results}->{metric}

View File

@ -138,7 +138,7 @@ sub S3 {
# Compute data # Compute data
foreach my $bucket (@buckets) { foreach my $bucket (@buckets) {
$self->{result}->{'S3'}->{ $bucket->{Name} } = $self->{result}->{'S3'}->{ $bucket->{Name} } =
{ Creation date => $bucket->{CreationDate} }; { 'Creation date' => $bucket->{CreationDate} };
$self->{result}->{count}->{'S3'}++; $self->{result}->{count}->{'S3'}++;
} }
} }
@ -166,7 +166,7 @@ sub RDS {
} }
sub disco_format { sub disco_format {
my ( $self, %options ) = @_; my ($self, %options) = @_;
my $names = [ 'name', 'id', 'state', 'service' ]; my $names = [ 'name', 'id', 'state', 'service' ];
$self->{output}->add_disco_format( elements => $names ); $self->{output}->add_disco_format( elements => $names );

View File

@ -557,15 +557,6 @@ The mapping between 'snmpwalk' options and "centreon-plugins" options:
Miscellaneous Miscellaneous
------------- -------------
I use an option but it doesn't seem to work
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Before opening a ticket on the github, please use the option ``--sanity-options``. It checks if you have misspell an option:
::
$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=traffic --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --interface='.*' --name --regex --verbose --skip --skip-speed0 --sanity-options
Unknown option: regex
I get the error: "UNKNOWN: Need to specify '--custommode'." I get the error: "UNKNOWN: Need to specify '--custommode'."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -557,15 +557,6 @@ L'association entre les options 'snmpwalk' et les options "centreon-plugins" :
Divers Divers
------ ------
J'utilise une options mais il semblerait qu'elle ne fonctionne pas
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Avant d'ouvrir un ticket sur github, utilisez l'option ``--sanity-options``. Cela vérifie si vous avez mal orthographié une option :
::
$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=traffic --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --interface='.*' --name --regex --verbose --skip --skip-speed0 --sanity-options
Unknown option: regex
J'ai l'erreur: "UNKNOWN: Need to specify '--custommode'." J'ai l'erreur: "UNKNOWN: Need to specify '--custommode'."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -93,6 +93,7 @@ sub check {
my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{batteryPredictedCapicity}->{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); my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{batteryLearnState}->{oid}}, instance => $instance);
$result4->{batteryLearnState} = defined($result4->{batteryLearnState}) ? $result4->{batteryLearnState} : '-'; $result4->{batteryLearnState} = defined($result4->{batteryLearnState}) ? $result4->{batteryLearnState} : '-';
$result3->{batteryPredictedCapicity} = defined($result3->{batteryPredictedCapicity}) ? $result3->{batteryPredictedCapicity} : '-';
next if ($self->check_exclude(section => 'cachebattery', instance => $instance)); next if ($self->check_exclude(section => 'cachebattery', instance => $instance));

View File

@ -83,6 +83,7 @@ sub check {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_channelEntry}, instance => $instance); 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 $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); my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{channelBusType}->{oid}}, instance => $instance);
$result3->{channelBusType} = defined($result3->{channelBusType}) ? $result3->{channelBusType} : '-';
next if ($self->check_exclude(section => 'connector', instance => $instance)); next if ($self->check_exclude(section => 'connector', instance => $instance));

View File

@ -85,7 +85,8 @@ sub check {
$self->{output}->output_add(long_msg => sprintf("Cpu '%s' status is '%s' [instance: %s, manufacturer name: %s, brand name: %s, state: %s, speed: %s]", $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, $instance, $result->{processorDeviceStatus}, $instance,
$result2->{processorDeviceManufacturerName}, $result4->{processorDeviceBrandName}, $result2->{processorDeviceManufacturerName},
defined($result4->{processorDeviceBrandName}) ? $result4->{processorDeviceBrandName} : '-',
$result2->{processorDeviceStatusState}, $result3->{processorDeviceCurrentSpeed} $result2->{processorDeviceStatusState}, $result3->{processorDeviceCurrentSpeed}
)); ));
my $exit = $self->get_severity(section => 'cpu', value => $result->{processorDeviceStatus}); my $exit = $self->get_severity(section => 'cpu', value => $result->{processorDeviceStatus});

View File

@ -107,7 +107,8 @@ sub check {
$self->{output}->output_add(long_msg => sprintf("Physical Disk '%s' status is '%s' [instance: %s, state: %s, spare state: %s, smart alert: %s]", $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, $result->{arrayDiskName}, $result4->{arrayDiskComponentStatus}, $instance,
$result2->{arrayDiskState}, $result3->{arrayDiskSpareState}, $result5->{arrayDiskSmartAlertIndication} $result2->{arrayDiskState}, $result3->{arrayDiskSpareState},
defined($result5->{arrayDiskSmartAlertIndication}) ? $result5->{arrayDiskSmartAlertIndication} : '-'
)); ));
my $exit = $self->get_severity(section => 'physicaldisk', value => $result4->{arrayDiskComponentStatus}); my $exit = $self->get_severity(section => 'physicaldisk', value => $result4->{arrayDiskComponentStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
@ -116,11 +117,13 @@ sub check {
$result->{arrayDiskName}, $result4->{arrayDiskComponentStatus})); $result->{arrayDiskName}, $result4->{arrayDiskComponentStatus}));
} }
$exit = $self->get_severity(section => 'physicaldisk_smartalert', value => $result5->{arrayDiskSmartAlertIndication}); if (defined($result5->{arrayDiskSmartAlertIndication})) {
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $exit = $self->get_severity(section => 'physicaldisk_smartalert', value => $result5->{arrayDiskSmartAlertIndication});
$self->{output}->output_add(severity => $exit, if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
short_msg => sprintf("physical disk '%s' has received a predictive failure alert", $self->{output}->output_add(severity => $exit,
$result->{arrayDiskName})); short_msg => sprintf("physical disk '%s' has received a predictive failure alert",
$result->{arrayDiskName}));
}
} }
} }
} }

View File

@ -100,7 +100,8 @@ sub check {
$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]", $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, $instance, $result->{powerSupplyStatus}, $instance,
$result->{powerSupplyLocationName}, $result->{powerSupplyType}, $result->{powerSupplyOutputWatts}, $result->{powerSupplyLocationName}, $result->{powerSupplyType},
defined($result->{powerSupplyOutputWatts}) ? $result->{powerSupplyOutputWatts} : '-',
$result2->{powerSupplySensorState}, $result2->{powerSupplyConfigurationErrorType} $result2->{powerSupplySensorState}, $result2->{powerSupplyConfigurationErrorType}
)); ));
my $exit = $self->get_severity(section => 'psu', value => $result->{powerSupplyStatus}); my $exit = $self->get_severity(section => 'psu', value => $result->{powerSupplyStatus});

View File

@ -23,18 +23,26 @@ package hardware::server::ibm::bladecenter::snmp::mode::components::ambient;
use strict; use strict;
use warnings; use warnings;
# In MIB 'mmblade.mib'
my $oid_temperature = '.1.3.6.1.4.1.2.3.51.2.2.1'; my $oid_temperature = '.1.3.6.1.4.1.2.3.51.2.2.1';
my $oid_end = '.1.3.6.1.4.1.2.3.51.2.2.1.5';
my $oid_rearLEDCardTempMax = '.1.3.6.1.4.1.2.3.51.2.2.1.5.3.0';
# In MIB 'mmblade.mib' and 'cme.mib'
my $oids = { my $oids = {
mm => '.1.3.6.1.4.1.2.3.51.2.2.1.1.2.0', bladecenter => {
frontpanel => '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.0', mm => '.1.3.6.1.4.1.2.3.51.2.2.1.1.2.0',
frontpanel2 => '.1.3.6.1.4.1.2.3.51.2.2.1.5.2.0', frontpanel => '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.0',
frontpanel2 => '.1.3.6.1.4.1.2.3.51.2.2.1.5.2.0',
},
pureflex => {
ambient => '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.0', # rearLEDCardTempAvg
}
}; };
sub load { sub load {
my (%options) = @_; my (%options) = @_;
push @{$options{request}}, { oid => $oid_temperature }; push @{$options{request}}, { oid => $oid_temperature, end => $oid_end };
} }
sub check { sub check {
@ -44,9 +52,16 @@ sub check {
$self->{components}->{ambient} = {name => 'ambient', total => 0, skip => 0}; $self->{components}->{ambient} = {name => 'ambient', total => 0, skip => 0};
return if ($self->check_exclude(section => 'ambient')); return if ($self->check_exclude(section => 'ambient'));
foreach my $temp (('mm', 'frontpanel', 'frontpanel2')) { my @sensors = ('mm', 'frontpanel', 'frontpanel2');
if (!defined($self->{results}->{$oid_temperature}->{$oids->{$temp}}) || my $label = 'bladecenter';
$self->{results}->{$oid_temperature}->{$oids->{$temp}} !~ /([0-9\.]+)/) { if (defined($self->{results}->{$oid_temperature}->{$oid_rearLEDCardTempMax})) {
@sensors = ('ambient');
$label = 'pureflex';
}
foreach my $temp (@sensors) {
if (!defined($self->{results}->{$oid_temperature}->{$oids->{$label}->{$temp}}) ||
$self->{results}->{$oid_temperature}->{$oids->{$label}->{$temp}} !~ /([0-9\.]+)/) {
$self->{output}->output_add(long_msg => sprintf("skip ambient '%s': no values", $self->{output}->output_add(long_msg => sprintf("skip ambient '%s': no values",
$temp)); $temp));
next; next;

View File

@ -48,7 +48,7 @@ my %map_blade_power_state = (
4 => 'hibernate', 4 => 'hibernate',
); );
# In MIB 'CPQSTDEQ-MIB.mib' # In MIB 'mmblade.mib' and 'cme.mib'
my $mapping = { my $mapping = {
bladeId => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.2' }, bladeId => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.2' },
bladeExists => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.3', map => \%map_blade_exists }, bladeExists => { oid => '.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.3', map => \%map_blade_exists },
@ -77,8 +77,10 @@ sub check {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeSystemStatusEntry}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeSystemStatusEntry}, instance => $instance);
next if ($self->check_exclude(section => 'blade', instance => $result->{bladeId})); next if ($self->check_exclude(section => 'blade', instance => $result->{bladeId}));
next if ($result->{bladeExists} =~ /No/i && if ($result->{bladeExists} =~ /false/i) {
$self->absent_problem(section => 'blade', instance => $result->{bladeId})); $self->{output}->output_add(long_msg => "skipping blade '" . $instance . "' : not exits");
next;
}
$self->{components}->{blade}->{total}++; $self->{components}->{blade}->{total}++;
if ($result->{bladePowerState} =~ /off/) { if ($result->{bladePowerState} =~ /off/) {

View File

@ -0,0 +1,86 @@
#
# 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::ibm::bladecenter::snmp::mode::components::chassisfan;
use strict;
use warnings;
my %map_state = (
0 => 'unknown',
1 => 'good',
2 => 'warning',
3 => 'bad',
);
# In MIB 'mmblade.mib' and 'cme.mib'
my $mapping = {
chassisFanState => { oid => '.1.3.6.1.4.1.2.3.51.2.2.3.50.1.4', map => \%map_state },
chassisFanSpeedRPM => { oid => '.1.3.6.1.4.1.2.3.51.2.2.3.50.1.5' },
};
my $oid_chassisFansEntry = '.1.3.6.1.4.1.2.3.51.2.2.3.50.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $oid_chassisFansEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking chassis fan");
$self->{components}->{chassisfan} = {name => 'chassis fan', total => 0, skip => 0};
return if ($self->check_exclude(section => 'chassisfan'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_chassisFansEntry}})) {
next if ($oid !~ /^$mapping->{chassisFanState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_chassisFansEntry}, instance => $instance);
next if ($self->check_exclude(section => 'chassisfan', instance => $instance));
$self->{components}->{chassisfan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Chassis fan '%s' is %s rpm [status: %s, instance: %s]",
$instance, $result->{chassisFanSpeedRPM}, $result->{chassisFanState},
$instance));
my $exit = $self->get_severity(section => 'chassisfan', value => $result->{chassisFanState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Chassis fan '%s' status is %s",
$instance, $result->{chassisFanState}));
}
if (defined($result->{chassisFanSpeedRPM}) && $result->{chassisFanSpeedRPM} =~ /[0-9]/) {
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'chassisfan', instance => $instance, value => $result->{chassisFanSpeedRPM});
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Chassis fan '%s' speed is %s rpm", $instance, $result->{chassisFanSpeedRPM}));
}
$self->{output}->perfdata_add(label => "chassisfan_" . $instance, unit => 'rpm',
value => $result->{chassisFanSpeedRPM},
warning => $warn,
critical => $crit,
min => 0);
}
}
}
1;

View File

@ -23,7 +23,7 @@ package hardware::server::ibm::bladecenter::snmp::mode::components::chassisstatu
use strict; use strict;
use warnings; use warnings;
# In MIB 'mmblade.mib' # In MIB 'mmblade.mib' and 'cme.mib'
my $oid_mmBistAndChassisStatus = '.1.3.6.1.4.1.2.3.51.2.2.5.2'; my $oid_mmBistAndChassisStatus = '.1.3.6.1.4.1.2.3.51.2.2.5.2';
my $oid_bistLogicalNetworkLink = '.1.3.6.1.4.1.2.3.51.2.2.5.2.30.0'; my $oid_bistLogicalNetworkLink = '.1.3.6.1.4.1.2.3.51.2.2.5.2.30.0';
my $oids = { my $oids = {

View File

@ -0,0 +1,95 @@
#
# 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::ibm::bladecenter::snmp::mode::components::fanpack;
use strict;
use warnings;
my %map_state = (
0 => 'unknown',
1 => 'good',
2 => 'warning',
3 => 'bad',
);
my %map_exists = (
0 => 'false',
1 => 'true',
);
# In MIB 'mmblade.mib' and 'cme.mib'
my $mapping = {
fanPackExists => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.2', map => \%map_exists },
fanPackState => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.3', map => \%map_state },
fanPackAverageSpeedRPM => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.6' },
};
my $oid_fanPackEntry = '.1.3.6.1.4.1.2.3.51.2.2.6.1.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $oid_fanPackEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fanpack");
$self->{components}->{fanpack} = {name => 'fanpacks', total => 0, skip => 0};
return if ($self->check_exclude(section => 'fanpack'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanPackEntry}})) {
next if ($oid !~ /^$mapping->{fanPackState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanPackEntry}, instance => $instance);
if ($result->{fanPackExists} =~ /false/i) {
$self->{output}->output_add(long_msg => "skipping fanpack '" . $instance . "' : not exits");
next;
}
next if ($self->check_exclude(section => 'fanpack', instance => $instance));
$self->{components}->{fanpack}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fanpack '%s' is %s rpm [status: %s, instance: %s]",
$instance, $result->{fanPackAverageSpeedRPM}, $result->{fanPackState},
$instance));
my $exit = $self->get_severity(section => 'fanpack', value => $result->{fanPackState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fanpack '%s' status is %s",
$instance, $result->{fanPackState}));
}
if (defined($result->{fanPackAverageSpeedRPM}) && $result->{fanPackAverageSpeedRPM} =~ /[0-9]/) {
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fanpack', instance => $instance, value => $result->{fanPackAverageSpeedRPM});
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Fanpack '%s' speed is %s rpm", $instance, $result->{fanPackAverageSpeedRPM}));
}
$self->{output}->perfdata_add(label => "fanpack_" . $instance, unit => 'rpm',
value => $result->{fanPackAverageSpeedRPM},
warning => $warn,
critical => $crit,
min => 0);
}
}
}
1;

View File

@ -35,7 +35,7 @@ my %map_pw_exists = (
1 => 'true', 1 => 'true',
); );
# In MIB 'CPQSTDEQ-MIB.mib' # In MIB 'mmblade.mib' and 'cme.mib'
my $mapping = { my $mapping = {
powerModuleExists => { oid => '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.2', map => \%map_pw_exists }, powerModuleExists => { oid => '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.2', map => \%map_pw_exists },
powerModuleState => { oid => '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.3', map => \%map_pw_state }, powerModuleState => { oid => '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.3', map => \%map_pw_state },

View File

@ -0,0 +1,71 @@
#
# 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::ibm::bladecenter::snmp::mode::components::switchmodule;
use strict;
use warnings;
my %map_state = (
0 => 'unknown',
1 => 'good',
2 => 'warning',
3 => 'bad',
);
# In MIB 'mmblade.mib' and 'cme.mib'
my $mapping = {
smHealthState => { oid => '.1.3.6.1.4.1.2.3.51.2.22.3.1.1.1.15', map => \%map_state },
};
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping->{smHealthState}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking switch module");
$self->{components}->{switchmodule} = {name => 'switch modules', total => 0, skip => 0};
return if ($self->check_exclude(section => 'switchmodule'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{smHealthState}->{oid}}})) {
$oid =~ /^$mapping->{smHealthState}->{oid}\.(.*)/;
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{smHealthState}->{oid}}, instance => $instance);
next if ($self->check_exclude(section => 'switchmodule', instance => $instance));
$self->{components}->{switchmodule}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Switch module '%s' status is %s [instance: %s]",
$instance, $result->{smHealthState},
$instance));
my $exit = $self->get_severity(section => 'switchmodule', value => $result->{smHealthState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Switch module '%s' status is %s",
$instance, $result->{smHealthState}));
}
}
}
1;

View File

@ -23,7 +23,7 @@ package hardware::server::ibm::bladecenter::snmp::mode::components::systemhealth
use strict; use strict;
use warnings; use warnings;
# In MIB 'mmblade.mib' # In MIB 'mmblade.mib' and 'cme.mib'
my $oid_systemHealthStat = '.1.3.6.1.4.1.2.3.51.2.2.7.1'; my $oid_systemHealthStat = '.1.3.6.1.4.1.2.3.51.2.2.7.1';
my %map_systemhealth_state = ( my %map_systemhealth_state = (

View File

@ -42,12 +42,30 @@ my $thresholds = {
['warning', 'WARNING'], ['warning', 'WARNING'],
['notAvailable', 'UNKNOWN'], ['notAvailable', 'UNKNOWN'],
], ],
fanpack => [
['unknown', 'UNKNOWN'],
['good', 'OK'],
['warning', 'WARNING'],
['bad', 'CRITICAL'],
],
chassisfan => [
['unknown', 'UNKNOWN'],
['good', 'OK'],
['warning', 'WARNING'],
['bad', 'CRITICAL'],
],
blower => [ blower => [
['unknown', 'UNKNOWN'], ['unknown', 'UNKNOWN'],
['good', 'OK'], ['good', 'OK'],
['warning', 'WARNING'], ['warning', 'WARNING'],
['bad', 'CRITICAL'], ['bad', 'CRITICAL'],
], ],
switchmodule => [
['unknown', 'UNKNOWN'],
['good', 'OK'],
['warning', 'WARNING'],
['bad', 'CRITICAL'],
],
blowerctrl => [ blowerctrl => [
['unknown', 'UNKNOWN'], ['unknown', 'UNKNOWN'],
['operational', 'OK'], ['operational', 'OK'],
@ -132,8 +150,8 @@ sub check_options {
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
my ($section, $regexp, $value) = ($1, $2, $3); my ($section, $regexp, $value) = ($1, $2, $3);
if ($section !~ /(blower|ambient)/) { if ($section !~ /(blower|ambient|fanpack|chassisfan)/) {
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: blower or ambient)."); $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: blower, fanpack, chassisfan or ambient).");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
my $position = 0; my $position = 0;
@ -156,7 +174,7 @@ sub run {
$self->{snmp} = $options{snmp}; $self->{snmp} = $options{snmp};
my $snmp_request = []; my $snmp_request = [];
my @components = ('ambient', 'powermodule', 'blade', 'blower', 'systemhealth', 'chassisstatus'); my @components = ('ambient', 'powermodule', 'blade', 'blower', 'fanpack', 'chassisfan', 'systemhealth', 'chassisstatus', 'switchmodule');
foreach (@components) { foreach (@components) {
if (/$self->{option_results}->{component}/) { if (/$self->{option_results}->{component}/) {
my $mod_name = "hardware::server::ibm::bladecenter::snmp::mode::components::$_"; my $mod_name = "hardware::server::ibm::bladecenter::snmp::mode::components::$_";
@ -289,14 +307,15 @@ __END__
=head1 MODE =head1 MODE
Check Hardware (Ambient temperatures, Blowers, Power modules, Blades, System Health, Chassis status). Check Hardware (Ambient temperatures, Blowers, Power modules, Blades, System Health, Chassis status, Fanpack).
=over 8 =over 8
=item B<--component> =item B<--component>
Which component to check (Default: 'all'). Which component to check (Default: 'all').
Can be: 'ambient', 'powermodule', 'blower', 'blade', 'systemhealth', 'chassisstatus'. Can be: 'ambient', 'powermodule', 'fanpack', 'chassisfan',
'blower', 'blade', 'systemhealth', 'chassisstatus', 'switchmodule'.
=item B<--exclude> =item B<--exclude>

View File

@ -44,6 +44,6 @@ __END__
=head1 PLUGIN DESCRIPTION =head1 PLUGIN DESCRIPTION
Check IBM Chassis BladeCenter (H, HT, T) in SNMP. Check IBM Chassis BladeCenter (H, HT, T, Pureflex) in SNMP.
=cut =cut

View File

@ -76,11 +76,15 @@ sub run {
my $result = $self->{snmp}->get_table(oid => $oid_upsBattery, nothing_quit => 1); my $result = $self->{snmp}->get_table(oid => $oid_upsBattery, nothing_quit => 1);
my $current = defined($result->{$oid_upsBatteryCurrent}) ? $result->{$oid_upsBatteryCurrent} * 0.1 : 0; my $current = (defined($result->{$oid_upsBatteryCurrent}) && $result->{$oid_upsBatteryCurrent} =~ /\d/) ?
my $voltage = defined($result->{$oid_upsBatteryVoltage}) ? $result->{$oid_upsBatteryVoltage} * 0.1 : 0; $result->{$oid_upsBatteryCurrent} * 0.1 : 0;
my $voltage = (defined($result->{$oid_upsBatteryVoltage}) && $result->{$oid_upsBatteryVoltage} =~ /\d/) ?
$result->{$oid_upsBatteryVoltage} * 0.1 : 0;
my $temp = defined($result->{$oid_upsBatteryTemperature}) ? $result->{$oid_upsBatteryTemperature} : 0; my $temp = defined($result->{$oid_upsBatteryTemperature}) ? $result->{$oid_upsBatteryTemperature} : 0;
my $min_remain = defined($result->{$oid_upsEstimatedMinutesRemaining}) ? $result->{$oid_upsEstimatedMinutesRemaining} : 'unknown'; my $min_remain = (defined($result->{$oid_upsEstimatedMinutesRemaining}) && $result->{$oid_upsEstimatedMinutesRemaining} =~ /\d/) ?
my $charge_remain = defined($result->{$oid_upsEstimatedChargeRemaining}) ? $result->{$oid_upsEstimatedChargeRemaining} : 'unknown'; $result->{$oid_upsEstimatedMinutesRemaining} : 'unknown';
my $charge_remain = (defined($result->{$oid_upsEstimatedChargeRemaining}) && $result->{$oid_upsEstimatedChargeRemaining} =~ /\d/) ?
$result->{$oid_upsEstimatedChargeRemaining} : 'unknown';
my $status = defined($result->{$oid_upsBatteryStatus}) ? $result->{$oid_upsBatteryStatus} : 1; # we put unknown ??? my $status = defined($result->{$oid_upsBatteryStatus}) ? $result->{$oid_upsBatteryStatus} : 1; # we put unknown ???
$self->{output}->output_add(severity => ${$battery_status{$status}}[1], $self->{output}->output_add(severity => ${$battery_status{$status}}[1],

View File

@ -142,7 +142,7 @@ sub run {
my @exits; my @exits;
foreach (keys %{$maps_counters}) { foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
if (defined($self->{counters_value}->{$instance}->{$_}) && $self->{counters_value}->{$instance}->{$_} != 0) { if (defined($self->{counters_value}->{$instance}->{$_}) && $self->{counters_value}->{$instance}->{$_} =~ /\d/ && $self->{counters_value}->{$instance}->{$_} != 0) {
push @exits, $self->{perfdata}->threshold_check(value => $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]); push @exits, $self->{perfdata}->threshold_check(value => $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
} }
} }
@ -155,7 +155,7 @@ sub run {
my $str_output = "Input Line '$instance_output' "; my $str_output = "Input Line '$instance_output' ";
my $str_append = ''; my $str_append = '';
foreach (keys %{$maps_counters}) { foreach (keys %{$maps_counters}) {
next if (!defined($self->{counters_value}->{$instance}->{$_}) || $self->{counters_value}->{$instance}->{$_} == 0); next if (!defined($self->{counters_value}->{$instance}->{$_}) || $self->{counters_value}->{$instance}->{$_} !~ /\d/ || $self->{counters_value}->{$instance}->{$_} == 0);
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}); $str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor});
$str_append = ', '; $str_append = ', ';

View File

@ -182,7 +182,7 @@ sub run {
my @exits; my @exits;
foreach (keys %{$maps_counters}) { foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
if (defined($self->{counters_value}->{$instance}->{$_}) && $self->{counters_value}->{$instance}->{$_} == $maps_counters->{$_}->{no_present}) { if (defined($self->{counters_value}->{$instance}->{$_}) && $self->{counters_value}->{$instance}->{$_} =~ /\d/ && $self->{counters_value}->{$instance}->{$_} != $maps_counters->{$_}->{no_present}) {
push @exits, $self->{perfdata}->threshold_check(value => $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]); push @exits, $self->{perfdata}->threshold_check(value => $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
} }
} }
@ -195,7 +195,7 @@ sub run {
my $str_output = "Output Line '$instance_output' "; my $str_output = "Output Line '$instance_output' ";
my $str_append = ''; my $str_append = '';
foreach (keys %{$maps_counters}) { foreach (keys %{$maps_counters}) {
next if (!defined($self->{counters_value}->{$instance}->{$_}) || $self->{counters_value}->{$instance}->{$_} == $maps_counters->{$_}->{no_present}); next if (!defined($self->{counters_value}->{$instance}->{$_}) || $self->{counters_value}->{$instance}->{$_} !~ /\d/ || $self->{counters_value}->{$instance}->{$_} == $maps_counters->{$_}->{no_present});
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}); $str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor});
$str_append = ', '; $str_append = ', ';

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 network::3com::snmp::mode::components::fan;
use strict;
use warnings;
my %map_status = (
1 => 'active',
2 => 'deactive',
3 => 'not-install',
4 => 'unsupport',
);
# In MIB 'a3com-huawei-splat-devm'
my $mapping = {
hwDevMFanStatus => { oid => '.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2', map => \%map_status },
};
my $oid_hwdevMFanStatusEntry = '.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $oid_hwdevMFanStatusEntry };
}
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_filter(section => 'fan'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hwdevMFanStatusEntry}})) {
next if ($oid !~ /^$mapping->{hwDevMFanStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hwdevMFanStatusEntry}, instance => $instance);
next if ($result->{hwDevMFanStatus} =~ /not-install/i &&
$self->absent_problem(section => 'fan', instance => $instance));
next if ($self->check_filter(section => 'fan', instance => $instance));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance: %s]",
$instance, $result->{hwDevMFanStatus},
$instance));
my $exit = $self->get_severity(section => 'fan', value => $result->{hwDevMFanStatus});
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->{hwDevMFanStatus}));
}
}
}
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 network::3com::snmp::mode::components::psu;
use strict;
use warnings;
my %map_status = (
1 => 'active',
2 => 'deactive',
3 => 'not-install',
4 => 'unsupport',
);
# In MIB 'a3com-huawei-splat-devm'
my $mapping = {
hwDevMPowerStatus => { oid => '.1.3.6.1.4.1.43.45.1.2.23.1.9.1.2.1.2', map => \%map_status },
};
my $oid_hwdevMPowerStatusEntry = '.1.3.6.1.4.1.43.45.1.2.23.1.9.1.2.1';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $oid_hwdevMPowerStatusEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hwdevMPowerStatusEntry}})) {
next if ($oid !~ /^$mapping->{hwDevMPowerStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hwdevMPowerStatusEntry}, instance => $instance);
next if ($result->{hwDevMPowerStatus} =~ /not-install/i &&
$self->absent_problem(section => 'psu', instance => $instance));
next if ($self->check_filter(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance: %s]",
$instance, $result->{hwDevMPowerStatus},
$instance));
my $exit = $self->get_severity(section => 'psu', value => $result->{hwDevMPowerStatus});
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->{hwDevMPowerStatus}));
}
}
}
1;

View File

@ -0,0 +1,229 @@
#
# 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 network::3com::snmp::mode::cpu;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::values;
my $instance_mode;
my $maps_counters = {
cpu => {
'000_5s' => {
set => {
key_values => [ { name => 'usage_5s' }, { name => 'display' } ],
output_template => '%s %% (5sec)', output_error_template => "%s (5sec)",
perfdatas => [
{ label => 'cpu_5s', value => 'usage_5s_absolute', template => '%d',
unit => '%', min => 0, max => 100 },
],
},
},
'001_1m' => {
set => {
key_values => [ { name => 'usage_1m' }, { name => 'display' } ],
output_template => '%s %% (1m)', output_error_template => "%s (1min)",
perfdatas => [
{ label => 'cpu_1m', value => 'usage_1m_absolute', template => '%d',
unit => '%', min => 0, max => 100 },
],
},
},
'002_5m' => {
set => {
key_values => [ { name => 'usage_5m' }, { name => 'display' } ],
output_template => '%s %% (5min)', output_error_template => "%s (5min)",
perfdatas => [
{ label => 'cpu_5m', value => 'usage_5m_absolute', template => '%d',
unit => '%', min => 0, max => 100 },
],
},
},
}
};
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 =>
{
});
foreach my $key (('cpu')) {
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(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 (('cpu')) {
foreach (keys %{$maps_counters->{$key}}) {
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
}
}
$instance_mode = $self;
}
sub run_instances {
my ($self, %options) = @_;
my $multiple = 1;
if (scalar(keys %{$self->{cpu}}) == 1) {
$multiple = 0;
}
if ($multiple == 1) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All CPU usages are ok');
}
foreach my $id (sort keys %{$self->{cpu}}) {
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits = ();
foreach (sort keys %{$maps_counters->{cpu}}) {
my $obj = $maps_counters->{cpu}->{$_}->{obj};
$obj->set(instance => $id);
my ($value_check) = $obj->execute(values => $self->{cpu}->{$id});
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(extra_instance => $multiple);
}
my $prefix = "CPU Usage ";
if ($multiple == 1) {
$prefix = sprintf("CPU '%s' Usage ", $self->{cpu}->{$id}->{display});
}
$self->{output}->output_add(long_msg => "${prefix}$long_msg");
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 => "${prefix}$short_msg"
);
}
if ($multiple == 0) {
$self->{output}->output_add(short_msg => "${prefix}$long_msg");
}
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
$self->run_instances();
$self->{output}->display();
$self->{output}->exit();
}
my $mapping = {
hwCpuCostRate => { oid => '.1.3.6.1.4.1.43.45.1.6.1.1.1.2' },
hwCpuCostRatePer1Min => { oid => '.1.3.6.1.4.1.43.45.1.6.1.1.1.3' },
hwCpuCostRatePer5Min => { oid => '.1.3.6.1.4.1.43.45.1.6.1.1.1.4' },
};
sub manage_selection {
my ($self, %options) = @_;
# a3com-huawei-splat-devm.mib
my $oid_hwCpuEntry = '.1.3.6.1.4.1.43.45.1.6.1.1.1';
my $results = $options{snmp}->get_table(oid => $oid_hwCpuEntry, nothing_quit => 1);
$self->{cpu} = {};
foreach my $oid (keys %{$results}) {
next if ($oid !~ /^$mapping->{hwCpuCostRatePer5Min}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
$self->{cpu}->{$instance} = { display => $instance,
usage_5s => $result->{hwCpuCostRate},
usage_1m => $result->{hwCpuCostRatePer1Min},
usage_5m => $result->{hwCpuCostRatePer5Min},
};
}
if (scalar(keys %{$self->{cpu}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check cpu usages.
=over 8
=item B<--warning-*>
Threshold warning.
Can be: '5s', '1m', '5m'.
=item B<--critical-*>
Threshold critical.
Can be: '5s', '1m', '5m'.
=back
=cut

View File

@ -0,0 +1,275 @@
#
# 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 network::3com::snmp::mode::hardware;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
my $thresholds = {
fan => [
['active', 'OK'],
['deactive', 'CRITICAL'],
['not-install', 'OK'],
['unsupport', 'WARNING'],
],
psu => [
['active', 'OK'],
['deactive', 'CRITICAL'],
['not-install', 'OK'],
['unsupport', 'WARNING'],
],
};
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 =>
{
"filter:s@" => { name => 'filter' },
"absent-problem:s@" => { name => 'absent_problem' },
"component:s" => { name => 'component', default => '.*' },
"no-component:s" => { name => 'no_component' },
"threshold-overload:s@" => { name => 'threshold_overload' },
});
$self->{components} = {};
$self->{no_components} = undef;
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->{filter} = [];
foreach my $val (@{$self->{option_results}->{filter}}) {
next if (!defined($val) || $val eq '');
my @values = split (/,/, $val);
push @{$self->{filter}}, { filter => $values[0], instance => $values[1] };
}
$self->{absent_problem} = [];
foreach my $val (@{$self->{option_results}->{absent_problem}}) {
next if (!defined($val) || $val eq '');
my @values = split (/,/, $val);
push @{$self->{absent_problem}}, { filter => $values[0], instance => $values[1] };
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
next if (!defined($val) || $val eq '');
my @values = split (/,/, $val);
if (scalar(@values) < 3) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $instance, $status, $filter);
if (scalar(@values) == 3) {
($section, $status, $filter) = @values;
$instance = '.*';
} else {
($section, $instance, $status, $filter) = @values;
}
if ($section !~ /^psu|fan$/) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload section '" . $val . "'.");
$self->{output}->option_exit();
}
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, instance => $instance };
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $snmp_request = [];
my @components = ('psu', 'fan');
foreach (@components) {
if (/$self->{option_results}->{component}/) {
my $mod_name = "network::3com::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}) == 0) {
$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 (@components) {
if (/$self->{option_results}->{component}/) {
my $mod_name = "network::3com::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 absent_problem {
my ($self, %options) = @_;
foreach (@{$self->{absent_problem}}) {
if ($options{section} =~ /$_->{filter}/) {
if (!defined($_->{instance}) || $options{instance} =~ /$_->{instance}/) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Component '%s' instance '%s' is not present",
$options{section}, $options{instance}));
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)"));
$self->{components}->{$options{section}}->{skip}++;
return 1;
}
}
}
return 0;
}
sub check_filter {
my ($self, %options) = @_;
foreach (@{$self->{filter}}) {
if ($options{section} =~ /$_->{filter}/) {
if (!defined($options{instance}) && !defined($_->{instance})) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
return 1;
} elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
return 1;
}
}
}
return 0;
}
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 &&
(!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) {
$status = $_->{status};
return $status;
}
}
}
my $label = defined($options{label}) ? $options{label} : $options{section};
foreach (@{$thresholds->{$label}}) {
if ($options{value} =~ /$$_[0]/i) {
$status = $$_[1];
return $status;
}
}
return $status;
}
1;
__END__
=head1 MODE
Check Hardware (Power Supply, Fan).
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'fan', 'psu'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=fan)
Can also exclude specific instance: --filter=fan,1
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
Can be specific or global: --absent-problem=fan,2
=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,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='fan,CRITICAL,^(?!(active)$)'
=back
=cut

View File

@ -0,0 +1,250 @@
#
# 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 network::3com::snmp::mode::memory;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::values;
my $instance_mode;
my $maps_counters = {
mem => {
'000_usage' => {
set => {
key_values => [ { name => 'display' }, { name => 'total' }, { name => 'used' } ],
closure_custom_calc => \&custom_usage_calc,
closure_custom_output => \&custom_usage_output,
closure_custom_perfdata => \&custom_usage_perfdata,
closure_custom_threshold_check => \&custom_usage_threshold,
},
},
}
};
sub custom_usage_perfdata {
my ($self, %options) = @_;
my $extra_label = '';
if (!defined($options{extra_instance}) || $options{extra_instance} != 0) {
$extra_label .= '_' . $self->{result_values}->{display};
}
$self->{output}->perfdata_add(label => 'used' . $extra_label, unit => 'B',
value => $self->{result_values}->{used},
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_usage_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_usage_output {
my ($self, %options) = @_;
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
return $msg;
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'};
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
$self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
return 0;
}
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 =>
{
});
foreach my $key (('mem')) {
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(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 (('mem')) {
foreach (keys %{$maps_counters->{$key}}) {
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
}
}
$instance_mode = $self;
}
sub run_instances {
my ($self, %options) = @_;
my $multiple = 1;
if (scalar(keys %{$self->{mem}}) == 1) {
$multiple = 0;
}
if ($multiple == 1) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All memory usages are ok');
}
foreach my $id (sort keys %{$self->{mem}}) {
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits = ();
foreach (sort keys %{$maps_counters->{mem}}) {
my $obj = $maps_counters->{mem}->{$_}->{obj};
$obj->set(instance => $id);
my ($value_check) = $obj->execute(values => $self->{mem}->{$id});
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(extra_instance => $multiple);
}
my $prefix = '';
if ($multiple == 1) {
$prefix = sprintf("Memory '%s' ", $self->{mem}->{$id}->{display});
}
$self->{output}->output_add(long_msg => "${prefix}$long_msg");
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 => "${prefix}$short_msg"
);
}
if ($multiple == 0) {
$self->{output}->output_add(short_msg => "${prefix}$long_msg");
}
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
$self->run_instances();
$self->{output}->display();
$self->{output}->exit();
}
my $mapping = {
hwMemSize => { oid => '.1.3.6.1.4.1.43.45.1.6.1.2.1.1.2' },
hwMemFree => { oid => '.1.3.6.1.4.1.43.45.1.6.1.2.1.1.3' },
};
sub manage_selection {
my ($self, %options) = @_;
# a3com-huawei-splat-devm.mib
my $oid_hwMemEntry = '.1.3.6.1.4.1.43.45.1.6.1.2.1.1';
my $results = $options{snmp}->get_table(oid => $oid_hwMemEntry, nothing_quit => 1);
$self->{mem} = {};
foreach my $oid (keys %{$results}) {
next if ($oid !~ /^$mapping->{hwMemSize}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
my $total = $result->{hwMemSize};
my $used = $result->{hwMemSize} - $result->{hwMemFree};
$self->{mem}->{$instance} = { display => $instance, used => $used, total => $total };
}
if (scalar(keys %{$self->{mem}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check memory usages.
=over 8
=item B<--warning-usage>
Threshold warning (in percent).
=item B<--critical-usage>
Threshold critical (in percent).
=back
=cut

View File

@ -0,0 +1,52 @@
#
# 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 network::3com::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'network::3com::snmp::mode::cpu',
'hardware' => 'network::3com::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::3com::snmp::mode::memory',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check 3com equipment (old legacy. Maybe you should use 'network::h3c' plugin) in SNMP.
=cut

View File

@ -61,7 +61,7 @@ sub check {
my $instance = $1; my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_deviceDiskValueEntry}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_deviceDiskValueEntry}, instance => $instance);
next if ($result->{deviceDiskStatus} !~ /notpresent/i && next if ($result->{deviceDiskStatus} =~ /notpresent/i &&
$self->absent_problem(section => 'disk', instance => $instance)); $self->absent_problem(section => 'disk', instance => $instance));
next if ($self->check_filter(section => 'disk', instance => $instance)); next if ($self->check_filter(section => 'disk', instance => $instance));
$self->{components}->{disk}->{total}++; $self->{components}->{disk}->{total}++;
@ -72,7 +72,7 @@ sub check {
my $exit = $self->get_severity(section => 'disk', value => $result->{deviceDiskStatus}); my $exit = $self->get_severity(section => 'disk', value => $result->{deviceDiskStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Sensor '%s' operational status is %s", short_msg => sprintf("Disk '%s' status is %s",
$result->{deviceDiskSerialN}, $result->{deviceDiskStatus})); $result->{deviceDiskSerialN}, $result->{deviceDiskStatus}));
} }
} }

View File

@ -0,0 +1,53 @@
#
# 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 network::dell::sseries::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
# $options->{options} = options object
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'centreon::common::force10::snmp::mode::cpu',
'hardware' => 'centreon::common::force10::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'centreon::common::force10::snmp::mode::memory',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Dell S-Series in SNMP.
=cut

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 network::digi::portserverts::snmp::mode::cpu;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
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) = @_;
$self->{snmp} = $options{snmp};
# Between 0 and 255 (don't know why you can value over 100)
my $oid_processorCurrentUtilization = '.1.3.6.1.4.1.332.11.5.3.3.21.11.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_processorCurrentUtilization], nothing_quit => 1);
my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_processorCurrentUtilization},
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("CPU Usage : %.2f", $result->{$oid_processorCurrentUtilization}));
$self->{output}->perfdata_add(label => "cpu",
value => $result->{$oid_processorCurrentUtilization},
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 current processor usage.
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=back
=cut

View File

@ -0,0 +1,204 @@
#
# 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 network::digi::portserverts::snmp::mode::memory;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::values;
my $maps_counters = {
global => {
'000_usage' => { set => {
key_values => [ { name => 'free' }, { name => 'total' } ],
closure_custom_calc => \&custom_usage_calc,
closure_custom_output => \&custom_usage_output,
closure_custom_perfdata => \&custom_usage_perfdata,
closure_custom_threshold_check => \&custom_usage_threshold,
}
},
},
};
sub custom_usage_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(label => 'used', unit => 'B',
value => $self->{result_values}->{used},
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_usage_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_usage_output {
my ($self, %options) = @_;
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Memory Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
return $msg;
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_total'} - $options{new_datas}->{$self->{instance} . '_free'};
$self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'};
$self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
return 0;
}
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 =>
{
});
foreach my $key (('global')) {
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(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 (('global')) {
foreach (keys %{$maps_counters->{$key}}) {
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
}
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->manage_selection();
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits;
foreach (sort keys %{$maps_counters->{global}}) {
my $obj = $maps_counters->{global}->{$_}->{obj};
use Data::Dumper;
Data::Dumper::Dumper($obj);
$obj->set(instance => 'global');
my ($value_check) = $obj->execute(values => $self->{global});
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 => "$short_msg"
);
} else {
$self->{output}->output_add(short_msg => "$long_msg");
}
$self->{output}->display();
$self->{output}->exit();
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_memoryTotalMemory = '.1.3.6.1.4.1.332.11.5.3.3.22.11.0';
my $oid_memoryAvailable = '.1.3.6.1.4.1.332.11.5.3.3.22.12.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_memoryTotalMemory, $oid_memoryAvailable],
nothing_quit => 1);
$self->{global} = { free => $result->{$oid_memoryAvailable}, total => $result->{$oid_memoryTotalMemory} };
}
1;
__END__
=head1 MODE
Check memory usage.
=over 8
=item B<--warning-usage>
Threshold warning (in percent).
=item B<--critical-usage>
Threshold critical (in percent).
=back
=cut

View File

@ -0,0 +1,52 @@
#
# 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 network::digi::portserverts::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
# $options->{options} = options object
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'network::digi::portserverts::snmp::mode::cpu',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::digi::portserverts::snmp::mode::memory',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Digi PortServer TS equipments in SNMP.
=cut

View File

@ -260,6 +260,10 @@ sub manage_selection {
my $instance = $1; my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_extremeCpuMonitorSystemEntry}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_extremeCpuMonitorSystemEntry}, instance => $instance);
foreach (keys %{$mapping}) {
$result->{$_} = undef if (defined($result->{$_}) && $result->{$_} =~ /n\/a/i);
}
$self->{cpu}->{$instance} = {num => $instance, %$result}; $self->{cpu}->{$instance} = {num => $instance, %$result};
} }

View File

@ -52,7 +52,6 @@ my $maps_counters = {
}, },
}; };
sub custom_threshold_output { sub custom_threshold_output {
my ($self, %options) = @_; my ($self, %options) = @_;

View File

@ -57,6 +57,7 @@ sub check {
foreach my $instance (sort $self->get_instance_class(class => { $options{component_class} => 1 })) { foreach my $instance (sort $self->get_instance_class(class => { $options{component_class} => 1 })) {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance);
next if (!defined($result->{EntityExtErrorStatus}));
next if ($self->check_exclude(section => $options{component}, instance => $instance)); next if ($self->check_exclude(section => $options{component}, instance => $instance));
if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) {
$self->absent_problem(section => $options{component}, instance => $instance); $self->absent_problem(section => $options{component}, instance => $instance);

View File

@ -45,6 +45,7 @@ sub check {
foreach my $instance (sort $self->get_instance_class(class => { 7 => 1 })) { foreach my $instance (sort $self->get_instance_class(class => { 7 => 1 })) {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance);
next if (!defined($result->{EntityExtErrorStatus}));
next if ($self->check_exclude(section => 'fan', instance => $instance)); next if ($self->check_exclude(section => 'fan', instance => $instance));
if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) {
$self->absent_problem(section => 'fan', instance => $instance); $self->absent_problem(section => 'fan', instance => $instance);

View File

@ -45,6 +45,7 @@ sub check {
foreach my $instance (sort $self->get_instance_class(class => { 6 => 1 }) ) { foreach my $instance (sort $self->get_instance_class(class => { 6 => 1 }) ) {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance);
next if (!defined($result->{EntityExtErrorStatus}));
next if ($self->check_exclude(section => 'psu', instance => $instance)); next if ($self->check_exclude(section => 'psu', instance => $instance));
if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) {
$self->absent_problem(section => 'psu', instance => $instance); $self->absent_problem(section => 'psu', instance => $instance);

View File

@ -58,6 +58,7 @@ sub check {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance); my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance);
next if (!defined($result->{EntityExtErrorStatus}));
next if ($self->check_exclude(section => 'sensor', instance => $instance)); next if ($self->check_exclude(section => 'sensor', instance => $instance));
if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) {
$self->absent_problem(section => 'sensor', instance => $instance); $self->absent_problem(section => 'sensor', instance => $instance);

View File

@ -78,7 +78,7 @@ sub run {
my $spu_done = 0; my $spu_done = 0;
my $cp_total = $result->{$oid_nsResSessMaxium}; my $cp_total = $result->{$oid_nsResSessMaxium};
my $cp_used = $result->{$oid_nsResSessAllocate}; my $cp_used = $result->{$oid_nsResSessAllocate};
my $cp_failed = $result->{oid_nsResSessAllocate}; my $cp_failed = $result->{$oid_nsResSessFailed};
my $prct_used = $cp_used * 100 / $cp_total; my $prct_used = $cp_used * 100 / $cp_total;
my $prct_failed = $cp_failed * 100 / $cp_total; my $prct_failed = $cp_failed * 100 / $cp_total;
$spu_done = 1; $spu_done = 1;

View File

@ -46,10 +46,13 @@ sub new {
"command-options:s" => { name => 'command_options', default => '' }, "command-options:s" => { name => 'command_options', default => '' },
"error-type:s" => { name => 'error_type' }, "error-type:s" => { name => 'error_type' },
"error-class:s" => { name => 'error_class' }, "error-class:s" => { name => 'error_class' },
"error-id:s" => { name => 'error_id' },
"retention:s" => { name => 'retention' }, "retention:s" => { name => 'retention' },
"timezone:s" => { name => 'timezone' }, "timezone:s" => { name => 'timezone' },
"description" => { name => 'description' }, "description" => { name => 'description' },
"filter-resource:s" => { name => 'filter_resource' }, "filter-resource:s" => { name => 'filter_resource' },
"filter-id:s" => { name => 'filter_id' },
"exclude-id:s" => { name => 'exclude_id' },
}); });
$self->{result} = {}; $self->{result} = {};
return $self; return $self;
@ -58,6 +61,11 @@ sub new {
sub check_options { sub check_options {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->SUPER::init(%options); $self->SUPER::init(%options);
if (defined($self->{option_results}->{exclude_id}) && defined($self->{option_results}->{error_id})) {
$self->{output}->add_option_msg(short_msg => "Please use --error-id OR --exclude-id, these options are mutually exclusives");
$self->{output}->option_exit();
}
} }
sub manage_selection { sub manage_selection {
@ -70,6 +78,12 @@ sub manage_selection {
if (defined($self->{option_results}->{error_class})){ if (defined($self->{option_results}->{error_class})){
$extra_options .= ' -d '.$self->{option_results}->{error_class}; $extra_options .= ' -d '.$self->{option_results}->{error_class};
} }
if (defined($self->{option_results}->{error_id}) && $self->{option_results}->{error_id} ne ''){
$extra_options.= ' -j '.$self->{option_results}->{error_id};
}
if (defined($self->{option_results}->{exclude_id}) && $self->{option_results}->{exclude_id} ne ''){
$extra_options.= ' -k '.$self->{option_results}->{exclude_id};
}
if (defined($self->{option_results}->{retention}) && $self->{option_results}->{retention} ne ''){ if (defined($self->{option_results}->{retention}) && $self->{option_results}->{retention} ne ''){
my $retention = time() - $self->{option_results}->{retention}; my $retention = time() - $self->{option_results}->{retention};
if (defined($self->{option_results}->{timezone})){ if (defined($self->{option_results}->{timezone})){
@ -126,7 +140,7 @@ sub run {
$self->manage_selection(); $self->manage_selection();
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(severity => 'OK',
short_msg => sprintf("No error found since %s seconds%s.", $extra_message)); short_msg => sprintf("No error found%s.", $extra_message));
my $total_error = 0; my $total_error = 0;
foreach my $errpt_error (sort(keys %{$self->{result}})) { foreach my $errpt_error (sort(keys %{$self->{result}})) {
@ -138,7 +152,8 @@ sub run {
next if (defined($self->{option_results}->{filter_resource}) && $self->{option_results}->{filter_resource} ne '' && next if (defined($self->{option_results}->{filter_resource}) && $self->{option_results}->{filter_resource} ne '' &&
$resource_name !~ /$self->{option_results}->{filter_resource}/); $resource_name !~ /$self->{option_results}->{filter_resource}/);
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
$identifier !~ /$self->{option_results}->{filter_id}/);
$total_error++; $total_error++;
if (defined($self->{option_results}->{description})) { if (defined($self->{option_results}->{description})) {
$self->{output}->output_add(long_msg => sprintf("Error '%s' Date: %s ResourceName: %s Description: %s", $identifier, $self->{output}->output_add(long_msg => sprintf("Error '%s' Date: %s ResourceName: %s Description: %s", $identifier,
@ -213,18 +228,30 @@ Filter error type separated by a coma (INFO, PEND, PERF, PERM, TEMP, UNKN).
Filter error class ('H' for hardware, 'S' for software, '0' for errlogger, 'U' for undetermined). Filter error class ('H' for hardware, 'S' for software, '0' for errlogger, 'U' for undetermined).
=item B<--error-id>
Filter specific error code (can be a comma separated list).
=item B<--retention> =item B<--retention>
Retention time of errors in seconds. Retention time of errors in seconds.
=item B<--description> =item B<--verbose>
Print error description in output. Print error description in long output. [ Error 'CODE' Date: Timestamp ResourceName: RsrcName Description: Desc ]
=item B<--filter-resource> =item B<--filter-resource>
Filter resource (can use a regexp). Filter resource (can use a regexp).
=item B<--filter-id>
Filter error code (can use a regexp).
=item B<--exclude-id>
Filter on specific error code (can be a comma separated list).
=back =back
=cut =cut

View File

@ -99,6 +99,11 @@ sub run {
short_msg => 'Exit code from command'); short_msg => 'Exit code from command');
} }
if (defined($exit_code)) {
$self->{output}->perfdata_add(label => "code",
value => $exit_code);
}
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
} }

View File

@ -117,6 +117,29 @@ my $maps_counters = {
} }
}, },
}, },
sum => {
'000_sum-read-write' => { set => {
key_values => [ { name => 'sum_read_write', diff => 1 } ],
per_second => 1,
output_template => 'R+W I/O : %s %s/s', output_error_template => "R+W I/O : %s",
output_change_bytes => 1,
perfdatas => [
{ label => 'sum_read_write', value => 'sum_read_write_per_second', template => '%d',
unit => 'B/s', min => 0 },
],
}
},
'001_sum-read-write-iops' => { set => {
key_values => [ { name => 'sum_read_write_iops', diff => 1 } ],
per_second => 1,
output_template => 'R+W IOPs : %.2f', output_error_template => "R+W IOPs : %s",
perfdatas => [
{ label => 'sum_read_write_iops', value => 'sum_read_write_iops_per_second', template => '%.2f',
unit => 'iops', min => 0 },
],
}
},
},
}; };
my $oid_diskIODevice = '.1.3.6.1.4.1.2021.13.15.1.1.2'; my $oid_diskIODevice = '.1.3.6.1.4.1.2021.13.15.1.1.2';
@ -142,7 +165,7 @@ sub new {
$self->{device_id_selected} = {}; $self->{device_id_selected} = {};
$self->{statefile_value} = centreon::plugins::statefile->new(%options); $self->{statefile_value} = centreon::plugins::statefile->new(%options);
foreach my $key (('total', 'disk')) { foreach my $key (('total', 'disk', 'sum')) {
foreach (keys %{$maps_counters->{$key}}) { foreach (keys %{$maps_counters->{$key}}) {
my ($id, $name) = split /_/; my ($id, $name) = split /_/;
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
@ -165,7 +188,7 @@ sub check_options {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->SUPER::init(%options); $self->SUPER::init(%options);
foreach my $key (('total', 'disk')) { foreach my $key (('total', 'disk', 'sum')) {
foreach (keys %{$maps_counters->{$key}}) { foreach (keys %{$maps_counters->{$key}}) {
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
} }
@ -208,17 +231,58 @@ sub check_total {
my $exit = $self->{output}->get_most_critical(status => [ @exits ]); my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => "Total $short_msg" short_msg => "All devices [$short_msg]"
); );
} else { } else {
$self->{output}->output_add(short_msg => "Total $long_msg"); $self->{output}->output_add(short_msg => "All devices [$long_msg]");
}
}
sub check_sum {
my ($self, %options) = @_;
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits = ();
foreach (sort keys %{$maps_counters->{sum}}) {
my $obj = $maps_counters->{sum}->{$_}->{obj};
$obj->set(instance => 'sum');
my ($value_check) = $obj->execute(values => $self->{sum_global},
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 => "Server overall [$short_msg]"
);
} else {
$self->{output}->output_add(short_msg => "Server overall [$long_msg]");
} }
} }
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp}; $self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname(); $self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port(); $self->{snmp_port} = $self->{snmp}->get_port();
@ -241,6 +305,7 @@ sub run {
if ($multiple == 1) { if ($multiple == 1) {
$self->check_total(); $self->check_total();
$self->check_sum();
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(severity => 'OK',
short_msg => 'All devices are ok.'); short_msg => 'All devices are ok.');
} }
@ -288,6 +353,7 @@ sub run {
} }
} }
$self->{statefile_value}->write(data => $self->{new_datas}); $self->{statefile_value}->write(data => $self->{new_datas});
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
@ -314,12 +380,20 @@ sub add_result {
$self->{device_id_selected}->{$options{instance}}->{write_iops} = $self->{results}->{$oid_diskIOWrites}->{$oid_diskIOWrites . '.' . $options{instance}}; $self->{device_id_selected}->{$options{instance}}->{write_iops} = $self->{results}->{$oid_diskIOWrites}->{$oid_diskIOWrites . '.' . $options{instance}};
$self->{global}->{total_write_iops} += $self->{device_id_selected}->{$options{instance}}->{write_iops}; $self->{global}->{total_write_iops} += $self->{device_id_selected}->{$options{instance}}->{write_iops};
} }
if ($self->{global}->{total_read} && $self->{global}->{total_write}) {
$self->{sum_global}->{sum_read_write} = $self->{global}->{total_read} + $self->{global}->{total_write};
}
if ($self->{global}->{total_read_iops} && $self->{global}->{total_write_iops}) {
$self->{sum_global}->{sum_read_write_iops} = $self->{global}->{total_read_iops} + $self->{global}->{total_write_iops};
}
} }
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{global} = { total_read => 0, total_write => 0, total_read_iops => 0, total_write_iops => 0 }; $self->{global} = { total_read => 0, total_write => 0, total_read_iops => 0, total_write_iops => 0 };
$self->{sum_global} = { sum_read_write => 0, sum_read_write_iops => 0 };
$self->{results} = $self->{snmp}->get_multiple_table(oids => [ $self->{results} = $self->{snmp}->get_multiple_table(oids => [
{ oid => $oid_diskIODevice }, { oid => $oid_diskIODevice },
{ oid => $oid_diskIOReads }, { oid => $oid_diskIOReads },
@ -340,7 +414,7 @@ sub manage_selection {
$oid =~ /\.(\d+)$/; $oid =~ /\.(\d+)$/;
my $instance = $1; my $instance = $1;
my $filter_name = $self->{results}->{$oid_diskIODevice}->{$oid}; my $filter_name = $self->{results}->{$oid_diskIODevice}->{$oid};
if (!defined($self->{option_results}->{device})) { if (!defined($self->{option_results}->{device}) || $self->{option_results}->{device} eq '') {
$self->add_result(instance => $instance); $self->add_result(instance => $instance);
next; next;
} }
@ -400,13 +474,15 @@ Check read/write I/O disks (bytes per secondes, IOPs).
Threshold warning. Threshold warning.
Can be: 'read', 'write', 'read-iops', 'write-iops', Can be: 'read', 'write', 'read-iops', 'write-iops',
'total-read', 'total-write', 'total-read-iops', 'total-write-iops'. 'total-read', 'total-write', 'total-read-iops', 'total-write-iops',
'sum-read-write', 'sum-read-write-iops'.
=item B<--critical-*> =item B<--critical-*>
Threshold critical. Threshold critical.
Can be: 'read', 'write', 'read-iops', 'write-iops', Can be: 'read', 'write', 'read-iops', 'write-iops',
'total-read', 'total-write', 'total-read-iops', 'total-write-iops'. 'total-read', 'total-write', 'total-read-iops', 'total-write-iops',
'sum-read-write', 'sum-read-write-iops'.
=item B<--device> =item B<--device>

View File

@ -24,10 +24,22 @@ use base qw(centreon::plugins::mode);
use strict; use strict;
use warnings; use warnings;
use centreon::plugins::statefile; use centreon::plugins::values;
my $oid_dskPath = '.1.3.6.1.4.1.2021.9.1.2'; my $maps_counters = {
my $oid_dskPercentNode = '.1.3.6.1.4.1.2021.9.1.10'; disk => {
'000_usage' => {
set => {
key_values => [ { name => 'usage' }, { name => 'display' } ],
output_template => 'Used: %s %%', output_error_template => "%s",
perfdatas => [
{ label => 'used', value => 'usage_absolute', template => '%d',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
],
},
},
}
};
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
@ -37,20 +49,29 @@ sub new {
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments =>
{ {
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
"name" => { name => 'use_name' }, "name" => { name => 'use_name' },
"diskpath:s" => { name => 'diskpath' }, "diskpath:s" => { name => 'diskpath' },
"regexp" => { name => 'use_regexp' }, "regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' }, "regexp-isensitive" => { name => 'use_regexpi' },
"filter-device:s" => { name => 'filter_device' },
"display-transform-src:s" => { name => 'display_transform_src' }, "display-transform-src:s" => { name => 'display_transform_src' },
"display-transform-dst:s" => { name => 'display_transform_dst' }, "display-transform-dst:s" => { name => 'display_transform_dst' },
"show-cache" => { name => 'show_cache' },
}); });
$self->{diskpath_id_selected} = []; foreach my $key (('disk')) {
$self->{statefile_cache} = centreon::plugins::statefile->new(%options); 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(output => $self->{output}, perfdata => $self->{perfdata},
label => $name);
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
}
}
return $self; return $self;
} }
@ -59,145 +80,141 @@ sub check_options {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->SUPER::init(%options); $self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { foreach my $key (('disk')) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); foreach (keys %{$maps_counters->{$key}}) {
$self->{output}->option_exit(); $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
}
} }
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 { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp}; $self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
$self->manage_selection(); $self->manage_selection();
$self->{snmp}->load(oids => [$oid_dskPercentNode], instances => $self->{diskpath_id_selected}); my $multiple = 1;
my $result = $self->{snmp}->get_leef(nothing_quit => 1); if (scalar(keys %{$self->{disk_selected}}) == 1) {
$multiple = 0;
if (!defined($self->{option_results}->{diskpath}) || defined($self->{option_results}->{use_regexp})) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All inode partitions are ok.');
} }
foreach (sort @{$self->{diskpath_id_selected}}) { if ($multiple == 1) {
my $name_diskpath = $self->get_display_value(id => $_); $self->{output}->output_add(severity => 'OK',
short_msg => 'All inode partitions are ok');
}
my $prct_used = $result->{$oid_dskPercentNode . '.' . $_}; foreach my $id (sort keys %{$self->{disk_selected}}) {
my $prct_free = 100 - $prct_used; my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits;
foreach (sort keys %{$maps_counters->{disk}}) {
my $obj = $maps_counters->{disk}->{$_}->{obj};
$obj->set(instance => $id);
my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my ($value_check) = $obj->execute(values => $self->{disk_selected}->{$id});
$self->{output}->output_add(long_msg => sprintf("Inodes partition '%s' Used: %s %% Free: %s %%", if ($value_check != 0) {
$name_diskpath, $prct_used, $prct_free)); $long_msg .= $long_msg_append . $obj->output_error();
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1) || (defined($self->{option_results}->{diskpath}) && !defined($self->{option_results}->{use_regexp}))) { $long_msg_append = ', ';
$self->{output}->output_add(severity => $exit, next;
short_msg => sprintf("Inodes partition '%s' Used: %s %% Free: %s %%", }
$name_diskpath, $prct_used, $prct_free)); 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(extra_instance => $multiple);
} }
my $label = 'used'; $self->{output}->output_add(long_msg => "Inode partition '" . $self->{disk_selected}->{$id}->{display} . "' $long_msg");
my $extra_label = ''; my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
$extra_label = '_' . $name_diskpath if (!defined($self->{option_results}->{diskpath}) || defined($self->{option_results}->{use_regexp})); if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
$self->{output}->perfdata_add(label => $label . $extra_label, unit => '%', $self->{output}->output_add(severity => $exit,
value => $prct_used, short_msg => "Inode partition '" . $self->{disk_selected}->{$id}->{display} . "' $short_msg"
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), );
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), }
min => 0, max => 100);
if ($multiple == 0) {
$self->{output}->output_add(short_msg => "Inode partition '" . $self->{disk_selected}->{$id}->{display} . "' $long_msg");
}
} }
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
} }
sub reload_cache { my $mapping = {
my ($self) = @_; dskPath => { oid => '.1.3.6.1.4.1.2021.9.1.2' },
my $datas = {}; dskDevice => { oid => '.1.3.6.1.4.1.2021.9.1.3' },
dskPercentNode => { oid => '.1.3.6.1.4.1.2021.9.1.10' },
my $result = $self->{snmp}->get_table(oid => $oid_dskPath); };
$datas->{last_timestamp} = time();
$datas->{all_ids} = [];
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($key !~ /\.([0-9]+)$/);
push @{$datas->{all_ids}}, $1;
$datas->{'dskPath_' . $1} = $self->{output}->to_utf8($result->{$key});
}
if (scalar(@{$datas->{all_ids}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "Can't construct cache...");
$self->{output}->option_exit();
}
$self->{statefile_cache}->write(data => $datas);
}
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
# init cache file my $results = $self->{snmp}->get_multiple_table(oids => [ { oid => $mapping->{dskPath}->{oid} },
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); { oid => $mapping->{dskDevice}->{oid} },
if (defined($self->{option_results}->{show_cache})) { { oid => $mapping->{dskPercentNode}->{oid} } ],
$self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content()); return_type => 1, nothing_quit => 1);
$self->{output}->option_exit(); $self->{disk_selected} = {};
} foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$results})) {
next if ($oid !~ /^$mapping->{dskPath}->{oid}\.(.*)/);
my $instance = $1;
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp'); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
if ($has_cache_file == 0 || !defined($timestamp_cache) || $result->{dskPath} = $self->get_display_value(value => $result->{dskPath});
((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60))) {
$self->reload_cache();
$self->{statefile_cache}->read();
}
my $all_ids = $self->{statefile_cache}->get(name => 'all_ids'); $self->{output}->output_add(long_msg => sprintf("disk path : '%s', device : '%s'", $result->{dskPath}, $result->{dskDevice}), debug => 1);
if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{diskpath})) {
# get by ID if (!defined($result->{dskPercentNode})) {
push @{$self->{diskpath_id_selected}}, $self->{option_results}->{diskpath}; $self->{output}->output_add(long_msg => sprintf("skipping '%s' : no inode usage value", $result->{dskPath}), debug => 1);
my $name = $self->{statefile_cache}->get(name => 'dskPath_' . $self->{option_results}->{diskpath}); next;
if (!defined($name)) {
$self->{output}->add_option_msg(short_msg => "No disk path found for id '" . $self->{option_results}->{diskpath} . "'.");
$self->{output}->option_exit();
} }
} else { if (defined($result->{dskDevice}) && defined($self->{option_results}->{filter_device}) &&
foreach my $i (@{$all_ids}) { $self->{option_results}->{filter_device} ne '' && $result->{dskDevice} !~ /$self->{option_results}->{filter_device}/) {
my $filter_name = $self->{statefile_cache}->get(name => 'dskPath_' . $i); $self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter disk device", $result->{dskPath}), debug => 1);
next if (!defined($filter_name)); next;
if (!defined($self->{option_results}->{diskpath})) { }
push @{$self->{diskpath_id_selected}}, $i;
if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{diskpath})) {
if ($self->{option_results}->{diskpath} !~ /(^|\s|,)$instance(\s*,|$)/) {
$self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter id disk path", $result->{dskPath}), debug => 1);
next; next;
} }
if (defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{diskpath}/i) { } elsif (defined($self->{option_results}->{diskpath}) && $self->{option_results}->{diskpath} ne '') {
push @{$self->{diskpath_id_selected}}, $i; if (defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) && $result->{dskPath} !~ /$self->{option_results}->{diskpath}/i) {
$self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter disk path", $result->{dskPath}), debug => 1);
next;
} }
if (defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{diskpath}/) { if (defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $result->{dskPath} !~ /$self->{option_results}->{diskpath}/) {
push @{$self->{diskpath_id_selected}}, $i; $self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter disk path", $result->{dskPath}), debug => 1);
next;
} }
if (!defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name eq $self->{option_results}->{diskpath}) { if (!defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $result->{dskPath} ne $self->{option_results}->{diskpath}) {
push @{$self->{diskpath_id_selected}}, $i; $self->{output}->output_add(long_msg => sprintf("skipping '%s' : filter disk path", $result->{dskPath}), debug => 1);
next;
} }
} }
if (scalar(@{$self->{diskpath_id_selected}}) <= 0) { $self->{disk_selected}->{$instance} = { display => $result->{dskPath},
if (defined($self->{option_results}->{diskpath})) { usage => $result->{dskPercentNode} };
$self->{output}->add_option_msg(short_msg => "No disk path found for name '" . $self->{option_results}->{diskpath} . "' (maybe you should reload cache file)."); }
} else {
$self->{output}->add_option_msg(short_msg => "No disk path found (maybe you should reload cache file)."); if (scalar(keys %{$self->{disk_selected}}) <= 0) {
} $self->{output}->add_option_msg(short_msg => "No entry found.");
$self->{output}->option_exit(); $self->{output}->option_exit();
}
} }
} }
sub get_display_value { sub get_display_value {
my ($self, %options) = @_; my ($self, %options) = @_;
my $value = $self->{statefile_cache}->get(name => 'dskPath_' . $options{id}); my $value = $options{value};
if (defined($self->{option_results}->{display_transform_src})) { if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst})); $self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
@ -217,11 +234,11 @@ Need to enable "includeAllDisks 10%" on snmpd.conf.
=over 8 =over 8
=item B<--warning> =item B<--warning-usage>
Threshold warning in percent. Threshold warning in percent.
=item B<--critical> =item B<--critical-usage>
Threshold critical in percent. Threshold critical in percent.
@ -241,10 +258,6 @@ Allows to use regexp to filter diskpath (with option --name).
Allows to use regexp non case-sensitive (with --regexp). Allows to use regexp non case-sensitive (with --regexp).
=item B<--reload-cache-time>
Time in seconds before reloading cache file (default: 180).
=item B<--display-transform-src> =item B<--display-transform-src>
Regexp src to transform display value. (security risk!!!) Regexp src to transform display value. (security risk!!!)
@ -253,9 +266,9 @@ Regexp src to transform display value. (security risk!!!)
Regexp dst to transform display value. (security risk!!!) Regexp dst to transform display value. (security risk!!!)
=item B<--show-cache> =item B<--filter-device>
Display cache storage datas. Filter device name (Can be a regexp).
=back =back

View File

@ -1217,6 +1217,10 @@ sub add_result_cast {
} }
} }
foreach (('iucast', 'imcast', 'ibcast', 'oucast', 'omcast', 'omcast')) {
$self->{interface_selected}->{$options{instance}}->{$_} = 0 if (!defined($self->{interface_selected}->{$options{instance}}->{$_}));
}
$self->{interface_selected}->{$options{instance}}->{total_in_packets} = $self->{interface_selected}->{$options{instance}}->{iucast} + $self->{interface_selected}->{$options{instance}}->{imcast} + $self->{interface_selected}->{$options{instance}}->{ibcast}; $self->{interface_selected}->{$options{instance}}->{total_in_packets} = $self->{interface_selected}->{$options{instance}}->{iucast} + $self->{interface_selected}->{$options{instance}}->{imcast} + $self->{interface_selected}->{$options{instance}}->{ibcast};
$self->{interface_selected}->{$options{instance}}->{total_out_packets} = $self->{interface_selected}->{$options{instance}}->{oucast} + $self->{interface_selected}->{$options{instance}}->{omcast} + $self->{interface_selected}->{$options{instance}}->{obcast}; $self->{interface_selected}->{$options{instance}}->{total_out_packets} = $self->{interface_selected}->{$options{instance}}->{oucast} + $self->{interface_selected}->{$options{instance}}->{omcast} + $self->{interface_selected}->{$options{instance}}->{obcast};
} }

View File

@ -35,6 +35,7 @@ sub new {
'numeric-value' => 'snmp_standard::mode::numericvalue', 'numeric-value' => 'snmp_standard::mode::numericvalue',
'string-value' => 'snmp_standard::mode::stringvalue', 'string-value' => 'snmp_standard::mode::stringvalue',
'dynamic-command' => 'snmp_standard::mode::dynamiccommand', 'dynamic-command' => 'snmp_standard::mode::dynamiccommand',
'uptime' => 'snmp_standard::mode::uptime',
); );
return $self; return $self;
@ -46,6 +47,6 @@ __END__
=head1 PLUGIN DESCRIPTION =head1 PLUGIN DESCRIPTION
Check SNMP values (string, numeric or execute commands). Check SNMP values (string, numeric or execute commands) or standard (uptime).
=cut =cut

View File

@ -28,14 +28,23 @@ use centreon::plugins::values;
my $maps_counters = { my $maps_counters = {
'000_usage' => { set => { '000_usage' => { set => {
key_values => [ { name => 'name' }, { name => 'used' }, { name => 'total' }, key_values => [ { name => 'name' }, { name => 'used' }, { name => 'total' },
{ name => 'dfCompressSavedPercent' }, { name => 'dfDedupeSavedPercent' } ], { name => 'dfCompressSavedPercent' }, { name => 'dfDedupeSavedPercent' } ],
closure_custom_calc => \&custom_usage_calc, closure_custom_calc => \&custom_usage_calc,
closure_custom_output => \&custom_usage_output, closure_custom_output => \&custom_usage_output,
closure_custom_perfdata => \&custom_usage_perfdata, closure_custom_perfdata => \&custom_usage_perfdata,
closure_custom_threshold_check => \&custom_usage_threshold, closure_custom_threshold_check => \&custom_usage_threshold,
} }
}, },
'001_inodes' => { set => {
key_values => [ { name => 'dfPerCentInodeCapacity' }, { name => 'name' } ],
output_template => 'Inodes Used : %s %%', output_error_template => "Inodes : %s",
perfdatas => [
{ label => 'inodes', value => 'dfPerCentInodeCapacity_absolute', template => '%d',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'name_absolute' },
],
}
},
}; };
my $instance_mode; my $instance_mode;
@ -178,7 +187,6 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp}; $self->{snmp} = $options{snmp};
$self->manage_selection(); $self->manage_selection();
@ -249,10 +257,12 @@ my $mapping = {
dfType => { oid => '.1.3.6.1.4.1.789.1.5.4.1.23', map => \%map_types }, dfType => { oid => '.1.3.6.1.4.1.789.1.5.4.1.23', map => \%map_types },
}; };
my $mapping2 = { my $mapping2 = {
dfKBytesTotal => { oid => '.1.3.6.1.4.1.789.1.5.4.1.3' }, dfFileSys => { oid => '.1.3.6.1.4.1.789.1.5.4.1.2' },
dfKBytesUsed => { oid => '.1.3.6.1.4.1.789.1.5.4.1.4' }, dfKBytesTotal => { oid => '.1.3.6.1.4.1.789.1.5.4.1.3' },
df64TotalKBytes => { oid => '.1.3.6.1.4.1.789.1.5.4.1.29' }, dfKBytesUsed => { oid => '.1.3.6.1.4.1.789.1.5.4.1.4' },
df64UsedKBytes => { oid => '.1.3.6.1.4.1.789.1.5.4.1.30' }, dfPerCentInodeCapacity => { oid => '.1.3.6.1.4.1.789.1.5.4.1.9' },
df64TotalKBytes => { oid => '.1.3.6.1.4.1.789.1.5.4.1.29' },
df64UsedKBytes => { oid => '.1.3.6.1.4.1.789.1.5.4.1.30' },
dfCompressSavedPercent => { oid => '.1.3.6.1.4.1.789.1.5.4.1.38' }, dfCompressSavedPercent => { oid => '.1.3.6.1.4.1.789.1.5.4.1.38' },
dfDedupeSavedPercent => { oid => '.1.3.6.1.4.1.789.1.5.4.1.40' }, dfDedupeSavedPercent => { oid => '.1.3.6.1.4.1.789.1.5.4.1.40' },
}; };
@ -260,18 +270,28 @@ my $mapping2 = {
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $oid_dfFileSys = '.1.3.6.1.4.1.789.1.5.4.1.2'; my $oids = [
{ oid => $mapping->{dfType}->{oid} },
{ oid => $mapping2->{dfFileSys}->{oid} },
{ oid => $mapping2->{dfKBytesTotal}->{oid} },
{ oid => $mapping2->{dfKBytesUsed}->{oid} },
{ oid => $mapping2->{dfPerCentInodeCapacity}->{oid} },
{ oid => $mapping2->{dfCompressSavedPercent}->{oid} },
{ oid => $mapping2->{dfDedupeSavedPercent}->{oid} },
];
if (!$self->{snmp}->is_snmpv1()) {
push @{$oids}, { oid => $mapping2->{df64TotalKBytes}->{oid} }, { oid => $mapping2->{df64UsedKBytes}->{oid} };
}
my $results = $self->{snmp}->get_multiple_table(oids => [ my $results = $self->{snmp}->get_multiple_table(oids => $oids, return_type => 1, nothing_quit => 1);
{ oid => $oid_dfFileSys },
{ oid => $mapping->{dfType}->{oid} },
], nothing_quit => 1);
$self->{filesys_selected} = {}; $self->{filesys_selected} = {};
foreach my $oid (keys %{$results->{$oid_dfFileSys}}) { foreach my $oid (keys %{$results}) {
$oid =~ /^$oid_dfFileSys\.(\d+)/; next if ($oid !~ /^$mapping2->{dfFileSys}->{oid}\.(\d+)/);
my $instance = $1; my $instance = $1;
my $name = $results->{$oid_dfFileSys}->{$oid}; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results->{$mapping->{dfType}->{oid}}, instance => $instance); my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance);
my $name = $result2->{dfFileSys};
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) { $name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "Skipping '" . $name . "': no matching filter name."); $self->{output}->output_add(long_msg => "Skipping '" . $name . "': no matching filter name.");
@ -284,31 +304,23 @@ sub manage_selection {
} }
$self->{filesys_selected}->{$instance} = { name => $name }; $self->{filesys_selected}->{$instance} = { name => $name };
$self->{filesys_selected}->{$instance}->{total} = $result2->{dfKBytesTotal} * 1024;
$self->{filesys_selected}->{$instance}->{used} = $result2->{dfKBytesUsed} * 1024;
if (defined($result2->{df64TotalKBytes}) && $result2->{df64TotalKBytes} > 0) {
$self->{filesys_selected}->{$instance}->{total} = $result2->{df64TotalKBytes} * 1024;
$self->{filesys_selected}->{$instance}->{used} = $result2->{df64UsedKBytes} * 1024;
}
$self->{filesys_selected}->{$instance}->{dfCompressSavedPercent} = $result2->{dfCompressSavedPercent};
$self->{filesys_selected}->{$instance}->{dfDedupeSavedPercent} = $result2->{dfDedupeSavedPercent};
if ($self->{filesys_selected}->{$instance}->{total} > 0) {
$self->{filesys_selected}->{$instance}->{dfPerCentInodeCapacity} = $result2->{dfPerCentInodeCapacity};
}
} }
if (scalar(keys %{$self->{filesys_selected}}) <= 0) { if (scalar(keys %{$self->{filesys_selected}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found."); $self->{output}->add_option_msg(short_msg => "No entry found.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
my $instances = [keys %{$self->{filesys_selected}}];
if (!$self->{snmp}->is_snmpv1()) {
$self->{snmp}->load(oids => [$mapping2->{df64TotalKBytes}->{oid}, $mapping2->{df64UsedKBytes}->{oid}], instances => $instances);
}
$self->{snmp}->load(oids => [$mapping2->{dfKBytesTotal}->{oid}, $mapping2->{dfKBytesUsed}->{oid},
$mapping2->{dfDedupeSavedPercent}->{oid}, $mapping2->{dfCompressSavedPercent}->{oid}], instances => $instances);
my $result = $self->{snmp}->get_leef();
foreach (@$instances) {
my $result = $self->{snmp}->map_instance(mapping => $mapping2, results => $result, instance => $_);
$self->{filesys_selected}->{$_}->{total} = $result->{dfKBytesTotal} * 1024;
$self->{filesys_selected}->{$_}->{used} = $result->{dfKBytesUsed} * 1024;
if (defined($result->{df64TotalKBytes}) && $result->{df64TotalKBytes} > 0) {
$self->{filesys_selected}->{$_}->{total} = $result->{df64TotalKBytes} * 1024;
$self->{filesys_selected}->{$_}->{used} = $result->{df64UsedKBytes} * 1024;
}
$self->{filesys_selected}->{$_}->{dfCompressSavedPercent} = $result->{dfCompressSavedPercent};
$self->{filesys_selected}->{$_}->{dfDedupeSavedPercent} = $result->{dfDedupeSavedPercent};
}
} }
1; 1;
@ -321,13 +333,15 @@ Check filesystem usage (volumes, snapshots and aggregates also).
=over 8 =over 8
=item B<--warning-usage> =item B<--warning-*>
Threshold warning. Threshold warning.
Can be: usage, inodes (%).
=item B<--critical-usage> =item B<--critical-*>
Threshold critical. Threshold critical.
Can be: usage, inodes (%).
=item B<--units> =item B<--units>

View File

@ -0,0 +1,264 @@
#
# 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 storage::nimble::snmp::mode::globalstats;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use centreon::plugins::values;
use centreon::plugins::statefile;
my $maps_counters = {
global => {
'000_read' => { set => {
key_values => [ { name => 'read', diff => 1 } ],
per_second => 1,
output_template => 'Read I/O : %s %s/s', output_error_template => "Read I/O : %s",
output_change_bytes => 1,
perfdatas => [
{ label => 'read', value => 'read_per_second', template => '%d',
unit => 'B/s' },
],
}
},
'001_write' => { set => {
key_values => [ { name => 'write', diff => 1 } ],
per_second => 1,
output_template => 'Write I/O : %s %s/s', output_error_template => "Write I/O : %s",
output_change_bytes => 1,
perfdatas => [
{ label => 'write', value => 'write_per_second', template => '%d',
unit => 'B/s', min => 0 },
],
}
},
'002_read-iops' => { set => {
key_values => [ { name => 'read_iops', diff => 1 } ],
per_second => 1,
output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s",
perfdatas => [
{ label => 'read_iops', value => 'read_iops_per_second', template => '%.2f',
unit => 'iops', min => 0 },
],
}
},
'003_write-iops' => { set => {
key_values => [ { name => 'write_iops', diff => 1 } ],
per_second => 1,
output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s",
perfdatas => [
{ label => 'write_iops', value => 'write_iops_per_second', template => '%.2f',
unit => 'iops', min => 0 },
],
}
},
'004_read-time' => { set => {
key_values => [ { name => 'read_time', diff => 1 } ],
output_template => 'Read Time : %.3f s', output_error_template => "Read Time : %s",
perfdatas => [
{ label => 'read_time', value => 'read_time_absolute', template => '%.3f',
unit => 's', min => 0 },
],
}
},
'005_write-time' => { set => {
key_values => [ { name => 'write_time', diff => 1 } ],
output_template => 'Write Time : %.3f s', output_error_template => "Write Time : %s",
perfdatas => [
{ label => 'write_time', value => 'write_time_absolute', template => '%.3f',
unit => 's', min => 0 },
],
}
},
},
};
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 =>
{
"filter-counters:s" => { name => 'filter_counters' },
});
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
foreach my $key (('global')) {
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 (('global')) {
foreach (keys %{$maps_counters->{$key}}) {
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
}
}
$self->{statefile_value}->check_options(%options);
}
sub run_global {
my ($self, %options) = @_;
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits;
foreach (sort keys %{$maps_counters->{global}}) {
if (defined($self->{option_results}->{filter_counters}) && $self->{option_results}->{filter_counters} ne '' &&
$_ !~ /$self->{option_results}->{filter_counters}/) {
$self->{output}->output_add(long_msg => "skipping counter $_", debug => 1);
next;
}
my $obj = $maps_counters->{global}->{$_}->{obj};
$obj->set(instance => 'global');
my ($value_check) = $obj->execute(new_datas => $self->{new_datas},
values => $self->{global});
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 => "$short_msg"
);
} else {
$self->{output}->output_add(short_msg => "$long_msg");
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
$self->{new_datas} = {};
$self->{statefile_value}->read(statefile => $self->{cache_name});
$self->{new_datas}->{last_timestamp} = time();
$self->run_global();
$self->{statefile_value}->write(data => $self->{new_datas});
$self->{output}->display();
$self->{output}->exit();
}
sub manage_selection {
my ($self, %options) = @_;
if ($options{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
$self->{output}->option_exit();
}
$self->{cache_name} = "nimble_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
$self->{global} = {};
my $oid_globalStats = '.1.3.6.1.4.1.37447.1.3';
my $oid_ioReads = '.1.3.6.1.4.1.37447.1.3.2.0';
my $oid_ioReadBytes = '.1.3.6.1.4.1.37447.1.3.8.0';
my $oid_ioReadTimeMicrosec = '.1.3.6.1.4.1.37447.1.3.6.0';
my $oid_ioWrites = '.1.3.6.1.4.1.37447.1.3.4.0';
my $oid_ioWriteBytes = '.1.3.6.1.4.1.37447.1.3.10.0';
my $oid_ioWriteTimeMicrosec = '.1.3.6.1.4.1.37447.1.3.7.0';
my $result = $options{snmp}->get_table(oid => $oid_globalStats,
nothing_quit => 1);
$self->{global}->{read} = defined($result->{$oid_ioReadBytes}) ? $result->{$oid_ioReadBytes} : undef;
$self->{global}->{read_iops} = defined($result->{$oid_ioReads}) ? $result->{$oid_ioReads} : undef;
$self->{global}->{read_time} = defined($result->{$oid_ioReadTimeMicrosec}) ? $result->{$oid_ioReadTimeMicrosec} / 1000000 : undef;
$self->{global}->{write} = defined($result->{$oid_ioWriteBytes}) ? $result->{$oid_ioWriteBytes} : undef;
$self->{global}->{write_iops} = defined($result->{$oid_ioWrites}) ? $result->{$oid_ioWrites} : undef;
$self->{global}->{write_time} = defined($result->{$oid_ioWriteTimeMicrosec}) ? $result->{$oid_ioWriteTimeMicrosec} / 1000000: undef;
}
1;
__END__
=head1 MODE
Check global statistics of storage.
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'read', 'read-iops', 'write', 'write-iops',
'read-time', 'write-time'.
=item B<--critical-*>
Threshold critical.
Can be: 'read', 'read-iops', 'write', 'write-iops',
'read-time', 'write-time'.
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='-iops$'
=back
=cut

View File

@ -0,0 +1,259 @@
#
# 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 storage::nimble::snmp::mode::volumeusage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::values;
my $instance_mode;
my $maps_counters = {
vol => {
'000_usage' => {
set => {
key_values => [ { name => 'display' }, { name => 'total' }, { name => 'used' } ],
closure_custom_calc => \&custom_usage_calc,
closure_custom_output => \&custom_usage_output,
closure_custom_perfdata => \&custom_usage_perfdata,
closure_custom_threshold_check => \&custom_usage_threshold,
},
},
}
};
sub custom_usage_perfdata {
my ($self, %options) = @_;
my $extra_label = '';
if (!defined($options{extra_instance}) || $options{extra_instance} != 0) {
$extra_label .= '_' . $self->{result_values}->{display};
}
$self->{output}->perfdata_add(label => 'used' . $extra_label, unit => 'B',
value => $self->{result_values}->{used},
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_usage_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_usage_output {
my ($self, %options) = @_;
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
return $msg;
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'};
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
$self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
return 0;
}
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 =>
{
"filter-name:s" => { name => 'filter_name' },
});
foreach my $key (('vol')) {
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(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 (('vol')) {
foreach (keys %{$maps_counters->{$key}}) {
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
}
}
$instance_mode = $self;
}
sub run_instances {
my ($self, %options) = @_;
my $multiple = 1;
if (scalar(keys %{$self->{vol}}) == 1) {
$multiple = 0;
}
if ($multiple == 1) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All volume usages are ok');
}
foreach my $id (sort keys %{$self->{vol}}) {
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits = ();
foreach (sort keys %{$maps_counters->{vol}}) {
my $obj = $maps_counters->{vol}->{$_}->{obj};
$obj->set(instance => $id);
my ($value_check) = $obj->execute(values => $self->{vol}->{$id});
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(extra_instance => $multiple);
}
$self->{output}->output_add(long_msg => "Volume '$self->{vol}->{$id}->{display}' $long_msg");
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 => "Volume '$self->{vol}->{$id}->{display}' $short_msg"
);
}
if ($multiple == 0) {
$self->{output}->output_add(short_msg => "Volume '$self->{vol}->{$id}->{display}' $long_msg");
}
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
$self->run_instances();
$self->{output}->display();
$self->{output}->exit();
}
my $mapping = {
volName => { oid => '.1.3.6.1.4.1.37447.1.2.1.3' },
volSizeLow => { oid => '.1.3.6.1.4.1.37447.1.2.1.4' }, # seems in MB
volSizeHigh => { oid => '.1.3.6.1.4.1.37447.1.2.1.5' }, # seems in MB
volUsageLow => { oid => '.1.3.6.1.4.1.37447.1.2.1.6' }, # seems in MB
volUsageHigh => { oid => '.1.3.6.1.4.1.37447.1.2.1.7' }, # seems in MB
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_volEntry = '.1.3.6.1.4.1.37447.1.2.1';
my $results = $options{snmp}->get_table(oid => $oid_volEntry, nothing_quit => 1);
$self->{vol} = {};
foreach my $oid (keys %{$results}) {
next if ($oid !~ /^$mapping->{volName}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$result->{volName} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "Skipping '" . $result->{volName} . "': no matching vserver name.", debug => 1);
next;
}
my $total = (($result->{volSizeHigh} << 32) + $result->{volSizeLow}) * 1024 * 1024;
my $used = (($result->{volUsageHigh} << 32) + $result->{volUsageLow}) * 1024 * 1024;
$self->{vol}->{$instance} = { display => $result->{volName}, used => $used, total => $total };
}
if (scalar(keys %{$self->{vol}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check volume usages.
=over 8
=item B<--filter-name>
Filter by name (regexp can be used).
=item B<--warning-usage>
Threshold warning (in percent).
=item B<--critical-usage>
Threshold critical (in percent).
=back
=cut

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