This commit is contained in:
root 2014-07-09 15:27:13 +02:00
commit 4f5d0fb5d9
26 changed files with 1009 additions and 293 deletions

View File

@ -211,7 +211,7 @@ sub run {
sub manage_selection {
my ($self, %options) = @_;
$all_ids = [];
my $all_ids = [];
$self->{names} = {};
my $result = $self->{snmp}->get_table(oid => $oid_pfsenseInterfaceName, nothing_quit => 1);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {

View File

@ -34,7 +34,7 @@
# Based on De Bodt Lieven plugin
####################################################################################
package hardware::sensors::sequoia::em01::web::mode::contact;
package hardware::sensors::sensormetrix::em01::web::mode::contact;
use base qw(centreon::plugins::mode);
@ -120,7 +120,7 @@ __END__
=head1 MODE
Check sensor voltage.
Check sensor contact.
=over 8

View File

@ -34,7 +34,7 @@
# Based on De Bodt Lieven plugin
####################################################################################
package hardware::sensors::sequoia::em01::web::mode::flood;
package hardware::sensors::sensormetrix::em01::web::mode::flood;
use base qw(centreon::plugins::mode);

View File

@ -34,7 +34,7 @@
# Based on De Bodt Lieven plugin
####################################################################################
package hardware::sensors::sequoia::em01::web::mode::humidity;
package hardware::sensors::sensormetrix::em01::web::mode::humidity;
use base qw(centreon::plugins::mode);

View File

@ -34,7 +34,7 @@
# Based on De Bodt Lieven plugin
####################################################################################
package hardware::sensors::sequoia::em01::web::mode::illumination;
package hardware::sensors::sensormetrix::em01::web::mode::illumination;
use base qw(centreon::plugins::mode);
@ -93,7 +93,7 @@ sub run {
my $webcontent = centreon::plugins::httplib::connect($self);
my $illumination;
if ($webcontent !~ /<body>(.*)<\/body>/msi || $1 !~ /IL\s*([0-9\.]+)/i) {
if ($webcontent !~ /<body>(.*)<\/body>/msi || $1 !~ /IL(?:\s*:\s*|\s*)([0-9\.]+)/i) {
$self->{output}->add_option_msg(short_msg => "Could not find illumination information.");
$self->{output}->option_exit();
}

View File

@ -34,7 +34,7 @@
# Based on De Bodt Lieven plugin
####################################################################################
package hardware::sensors::sequoia::em01::web::mode::temperature;
package hardware::sensors::sensormetrix::em01::web::mode::temperature;
use base qw(centreon::plugins::mode);
@ -162,11 +162,11 @@ Threshold for HTTP timeout
=item B<--warning>
Warning Threshold for Humidity
Warning Threshold for Temperature
=item B<--critical>
Critical Threshold for Humidity
Critical Threshold for Temperature
=back

View File

@ -34,7 +34,7 @@
# Based on De Bodt Lieven plugin
####################################################################################
package hardware::sensors::sequoia::em01::web::mode::thermistor;
package hardware::sensors::sensormetrix::em01::web::mode::thermistor;
use base qw(centreon::plugins::mode);
@ -162,11 +162,11 @@ Threshold for HTTP timeout
=item B<--warning>
Warning Threshold for Humidity
Warning Threshold for Thermistor Temperature
=item B<--critical>
Critical Threshold for Humidity
Critical Threshold for Thermistor Temperature
=back

View File

@ -34,7 +34,7 @@
# Based on De Bodt Lieven plugin
####################################################################################
package hardware::sensors::sequoia::em01::web::mode::voltage;
package hardware::sensors::sensormetrix::em01::web::mode::voltage;
use base qw(centreon::plugins::mode);

View File

@ -33,7 +33,7 @@
#
####################################################################################
package hardware::sensors::sequoia::em01::web::plugin;
package hardware::sensors::sensormetrix::em01::web::plugin;
use strict;
use warnings;
@ -47,13 +47,13 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'contact' => 'hardware::sensors::sequoia::em01::web::mode::contact',
'temperature' => 'hardware::sensors::sequoia::em01::web::mode::temperature',
'humidity' => 'hardware::sensors::sequoia::em01::web::mode::humidity',
'illumination' => 'hardware::sensors::sequoia::em01::web::mode::illumination',
'flood' => 'hardware::sensors::sequoia::em01::web::mode::flood',
'thermistor' => 'hardware::sensors::sequoia::em01::web::mode::thermistor',
'voltage' => 'hardware::sensors::sequoia::em01::web::mode::voltage',
'contact' => 'hardware::sensors::sensormetrix::em01::web::mode::contact',
'temperature' => 'hardware::sensors::sensormetrix::em01::web::mode::temperature',
'humidity' => 'hardware::sensors::sensormetrix::em01::web::mode::humidity',
'illumination' => 'hardware::sensors::sensormetrix::em01::web::mode::illumination',
'flood' => 'hardware::sensors::sensormetrix::em01::web::mode::flood',
'thermistor' => 'hardware::sensors::sensormetrix::em01::web::mode::thermistor',
'voltage' => 'hardware::sensors::sensormetrix::em01::web::mode::voltage',
);
return $self;
@ -65,6 +65,6 @@ __END__
=head1 PLUGIN DESCRIPTION
Check Sequoia em01 sensors through webpage.
Check Sensormetrix em01 sensors through webpage.
=cut

View File

@ -0,0 +1,221 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Stéphane Duret <sduret@merethis.com>
#
####################################################################################
package hardware::ups::eaton::mode::group;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
my %oids = (
'.1.3.6.1.4.1.534.6.6.7.5.3.1.3' => { counter => 'voltage', no_present => 0 }, # in mVolt groupVoltage
'.1.3.6.1.4.1.534.6.6.7.5.4.1.3' => { counter => 'current', no_present => 0 }, # in mA groupCurrent
'.1.3.6.1.4.1.534.6.6.7.5.5.1.3' => { counter => 'power', no_present => 0 }, # in Watt groupWatts
);
my $oid_groups = '.1.3.6.1.4.1.534.6.6.7.5';
my $maps_counters = {
voltage => { thresholds => {
warning_voltage => { label => 'warning-voltage', exit_value => 'warning' },
critical_voltage => { label => 'critical-voltage', exit_value => 'critical' },
},
output_msg => 'Voltage : %.2f V',
factor => 0.001, unit => 'V',
},
current => { thresholds => {
warning_current => { label => 'warning-current', exit_value => 'warning' },
critical_current => { label => 'critical-current', exit_value => 'critical' },
},
output_msg => 'Current : %.2f A',
factor => 0.001, unit => 'A',
},
power => { thresholds => {
warning_power => { label => 'warning-power', exit_value => 'warning' },
critical_power => { label => 'critical-power', exit_value => 'critical' },
},
output_msg => 'Power : %.2f W',
factor => 1, unit => 'W',
},
};
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"exclude:s" => { name => 'exclude', },
});
foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
$options{options}->add_options(arguments => {
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
});
}
}
$self->{counters_value} = {};
$self->{instances_done} = {};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
$self->{output}->option_exit();
}
}
}
}
sub build_values {
my ($self, %options) = @_;
my $counters_value = {};
my $instance = undef;
foreach my $oid (keys %oids) {
if ($options{current} =~ /^$oid\.(.*)/) {
$instance = $1;
last;
}
}
# Skip already done
if (!defined($instance) || defined($self->{instances_done}->{$instance})) {
return 0;
}
$self->{instances_done}->{$instance} = 1;
$self->{counters_value}->{$instance} = {};
foreach my $oid (keys %oids) {
my $full_oid = $oid . '.' . $instance;
$self->{counters_value}->{$instance}->{$oids{$oid}->{counter}} = defined($options{result}->{$oid . '.' . $instance}) ? $options{result}->{$oid . '.' . $instance} : 0;
}
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
my $result = $self->{snmp}->get_table(oid => $oid_groups, nothing_quit => 1);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$self->build_values(current => $key, result => $result);
}
my $num = scalar(keys %{$self->{instances_done}});
foreach my $instance (keys %{$self->{instances_done}}) {
my $instance_output = $instance;
$instance_output =~ s/\./#/g;
my @exits;
foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
next if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} ne '' && $_ =~ /$self->{option_results}->{exclude}/);
if (defined($self->{counters_value}->{$instance}->{$_}) && $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} }]);
}
}
}
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
my $extra_label = '';
$extra_label = '_' . $instance_output if ($num > 1);
my $str_output = "Group '$instance_output' ";
my $str_append = '';
foreach (keys %{$maps_counters}) {
next if (!defined($self->{counters_value}->{$instance}->{$_}));
next if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} ne '' && $_ =~ /$self->{option_results}->{exclude}/);
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor});
$str_append = ', ';
my ($warning, $critical);
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
}
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
value => sprintf("%.2f", $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}),
warning => $warning,
critical => $critical);
}
$self->{output}->output_add(severity => $exit,
short_msg => $str_output);
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Group metrics (voltage, current and power).
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'voltage', 'current', 'power'.
=item B<--critical-*>
Threshold critical.
Can be: 'voltage', 'current', 'power'.
=item B<--exclude>
Metrics excluded.
Can be: 'voltage', 'current', 'power'.
Use | if you want to exclude two or more metrics.
=back
=cut

View File

@ -0,0 +1,226 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Stéphane Duret <sduret@merethis.com>
#
####################################################################################
package hardware::ups::eaton::mode::outlet;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
my %oids = (
'.1.3.6.1.4.1.534.6.6.7.6.3.1.2' => { counter => 'voltage', no_present => 0 }, # in mVolt outletVoltage
'.1.3.6.1.4.1.534.6.6.7.6.4.1.3' => { counter => 'current', no_present => 0 }, # in mA outletCurrent
'.1.3.6.1.4.1.534.6.6.7.6.5.1.3' => { counter => 'power', no_present => 0 }, # in Watt outletWatts
);
my $oid_outlets = '.1.3.6.1.4.1.534.6.6.7.6';
my $maps_counters = {
voltage => { thresholds => {
warning_voltage => { label => 'warning-voltage', exit_value => 'warning' },
critical_voltage => { label => 'critical-voltage', exit_value => 'critical' },
},
output_msg => 'Voltage : %.2f V',
factor => 0.001, unit => 'V',
},
current => { thresholds => {
warning_current => { label => 'warning-current', exit_value => 'warning' },
critical_current => { label => 'critical-current', exit_value => 'critical' },
},
output_msg => 'Current : %.2f A',
factor => 0.001, unit => 'A',
},
power => { thresholds => {
warning_power => { label => 'warning-power', exit_value => 'warning' },
critical_power => { label => 'critical-power', exit_value => 'critical' },
},
output_msg => 'Power : %.2f W',
factor => 1, unit => 'W',
},
};
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"exclude:s" => { name => 'exclude', },
});
foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
$options{options}->add_options(arguments => {
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
});
}
}
$self->{counters_value} = {};
$self->{instances_done} = {};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
$self->{output}->option_exit();
}
}
}
}
sub build_values {
my ($self, %options) = @_;
my $counters_value = {};
my $instance = undef;
foreach my $oid (keys %oids) {
#if ($options{current} =~ /^$oid_outlets\.(.*)/) {
if ($options{current} =~ /^$oid\.(.*)/) {
$instance = $1;
#$instance =~ s/1\.1\.3\.//g;
last;
}
}
# Skip already done
if (!defined($instance) || defined($self->{instances_done}->{$instance})) {
return 0;
}
$self->{instances_done}->{$instance} = 1;
$self->{counters_value}->{$instance} = {};
foreach my $oid (keys %oids) {
my $full_oid = $oid . '.' . $instance;
$self->{counters_value}->{$instance}->{$oids{$oid}->{counter}} = defined($options{result}->{$oid . '.' . $instance}) ? $options{result}->{$oid . '.' . $instance} : 0;
}
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
#my $oid_outletName = '.1.3.6.1.4.1.534.6.6.7.6.1.1.3';
#my $result = $self->{snmp}->get_table(oid => $oid_outletName, nothing_quit => 1);
my $result = $self->{snmp}->get_table(oid => $oid_outlets, nothing_quit => 1);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$self->build_values(current => $key, result => $result);
}
my $num = scalar(keys %{$self->{instances_done}});
foreach my $instance (keys %{$self->{instances_done}}) {
my $instance_output = $instance;
$instance_output =~ s/\./#/g;
my @exits;
foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
next if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} ne '' && $_ =~ /$self->{option_results}->{exclude}/);
if (defined($self->{counters_value}->{$instance}->{$_}) && $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} }]);
}
}
}
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
my $extra_label = '';
$extra_label = '_' . $instance_output if ($num > 1);
my $str_output = "Outlet '$instance_output' ";
my $str_append = '';
foreach (keys %{$maps_counters}) {
#next if (!defined($self->{counters_value}->{$instance}->{$_}) || $self->{counters_value}->{$instance}->{$_} == 0);
next if (!defined($self->{counters_value}->{$instance}->{$_}));
next if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} ne '' && $_ =~ /$self->{option_results}->{exclude}/);
$str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor});
$str_append = ', ';
my ($warning, $critical);
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
}
$self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit},
value => sprintf("%.2f", $self->{counters_value}->{$instance}->{$_} * $maps_counters->{$_}->{factor}),
warning => $warning,
critical => $critical);
}
$self->{output}->output_add(severity => $exit,
short_msg => $str_output);
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Outlet metrics (voltage, current and power).
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'voltage', 'current', 'power'.
=item B<--critical-*>
Threshold critical.
Can be: 'voltage', 'current', 'power'.
=item B<--exclude>
Metrics excluded.
Can be: 'voltage', 'current', 'power'.
Use | if you want to exclude two or more metrics.
=back
=cut

View File

@ -0,0 +1,65 @@
################################################################################
# Copyright 2005-2014 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Stéphane Duret <sduret@merethis.com>
#
####################################################################################
package hardware::ups::eaton::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} = '0.1';
%{$self->{modes}} = (
'group' => 'hardware::ups::eaton::mode::group',
'outlet' => 'hardware::ups::eaton::mode::outlet',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Eaton EPDU in SNMP.
=cut

View File

@ -158,7 +158,7 @@ sub run {
foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
if (defined($self->{counters_value}->{$instance}->{$_}) && $self->{counters_value}->{$instance}->{$_} != 0) {
push @exits, $self->{perfdata}->threshold_check(value => $self->{counters_value}->{$instance}->{$_}, 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} }]);
}
}
}

View File

@ -198,7 +198,7 @@ sub run {
foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
if (defined($self->{counters_value}->{$instance}->{$_}) && $self->{counters_value}->{$instance}->{$_} != 0) {
push @exits, $self->{perfdata}->threshold_check(value => $self->{counters_value}->{$instance}->{$_}, 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} }]);
}
}
}

View File

@ -46,7 +46,7 @@ my %map_status = (
sub check {
my ($self) = @_;
$self->{components}->{fans} = {name => 'fans', total => 0, skip => 0};
$self->{components}->{fans} = {name => 'fans', total => 0};
$self->{output}->output_add(long_msg => "Checking fans");
return if ($self->check_exclude(section => 'fans'));

View File

@ -46,7 +46,7 @@ my %map_status = (
sub check {
my ($self) = @_;
$self->{components}->{modules} = {name => 'modules', total => 0, skip => 0};
$self->{components}->{modules} = {name => 'modules', total => 0};
$self->{output}->output_add(long_msg => "Checking modules");
return if ($self->check_exclude(section => 'modules'));
@ -62,11 +62,11 @@ sub check {
my $instance = $1;
next if ($self->check_exclude(section => 'modules', instance => $instance));
$self->{components}->{modules}->{total}++;
my $type = $result->{$oid_nsSlotType . '.' . $instance};
my $status = $result->{$oid_nsSlotStatus . '.' . $instance};
$self->{components}->{modules}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s].",
$type, $map_status{$status}, $instance));
if ($status != 1) {

View File

@ -46,7 +46,7 @@ my %map_status = (
sub check {
my ($self) = @_;
$self->{components}->{psus} = {name => 'psus', total => 0, skip => 0};
$self->{components}->{psus} = {name => 'psus', total => 0};
$self->{output}->output_add(long_msg => "Checking power supplies");
return if ($self->check_exclude(section => 'psus'));

View File

@ -42,7 +42,7 @@ sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperatures} = {name => 'temperatures', total => 0, skip => 0};
$self->{components}->{temperatures} = {name => 'temperatures', total => 0};
return if ($self->check_exclude('temperatures'));
my $oid_nsTemperatureEntry = '.1.3.6.1.4.1.3224.21.4.1';
@ -58,10 +58,10 @@ sub check {
next if ($self->check_exclude(section => 'temperatures', instance => $instance));
my $temperature_name = $result->{$oid_nsTemperatureDesc . '.' . $instance};
my $temperature_name = $result->{$oid_nsTemperatureDesc . '.' . $instance};
my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_nsTemperatureCur . '.' . $instance},
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_nsTemperatureCur . '.' . $instance},
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{components}->{temperatures}->{total}++;
@ -71,13 +71,12 @@ sub check {
$self->{output}->output_add(severity => $exit_code,short_msg => sprintf($temperature_name . " is %.2f C", $result->{$oid_nsTemperatureCur . '.' . $instance}));
}
$temperature_name =~ s/\ /_/g;
$self->{output}->perfdata_add(label => $temperature_name, unit => 'C',
value => sprintf("%.2f", $result->{$oid_nsTemperatureCur . '.' . $instance}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
$temperature_name =~ s/\ /_/g;
$self->{output}->perfdata_add(label => $temperature_name , unit => 'C', value => sprintf("%.2f", $result->{$oid_nsTemperatureCur . '.' . $instance}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
}
}
}
1;

View File

@ -59,31 +59,31 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
($self->{warn1s}, $self->{warn4s}, $self->{warn64s}) = split /,/, $self->{option_results}->{warning};
($self->{crit1s}, $self->{crit4s}, $self->{crit64s}) = split /,/, $self->{option_results}->{critical};
($self->{warn1m}, $self->{warn5m}, $self->{warn15m}) = split /,/, $self->{option_results}->{warning};
($self->{crit1m}, $self->{crit5m}, $self->{crit15m}) = split /,/, $self->{option_results}->{critical};
if (($self->{perfdata}->threshold_validate(label => 'warn1min', value => $self->{warn1s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1s} . "'.");
if (($self->{perfdata}->threshold_validate(label => 'warn1min', value => $self->{warn1m})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1m} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warn5min', value => $self->{warn4s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn4s} . "'.");
if (($self->{perfdata}->threshold_validate(label => 'warn5min', value => $self->{warn5m})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn5m} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warn15min', value => $self->{warn64s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (15min) threshold '" . $self->{warn64s} . "'.");
if (($self->{perfdata}->threshold_validate(label => 'warn15min', value => $self->{warn15m})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (15min) threshold '" . $self->{warn15m} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'crit1min', value => $self->{crit1s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1s} . "'.");
if (($self->{perfdata}->threshold_validate(label => 'crit1min', value => $self->{crit1m})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1m} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'crit5min', value => $self->{crit4s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit4s} . "'.");
if (($self->{perfdata}->threshold_validate(label => 'crit5min', value => $self->{crit5m})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit5m} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'crit15min', value => $self->{crit64s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (15min) threshold '" . $self->{crit64s} . "'.");
if (($self->{perfdata}->threshold_validate(label => 'crit15min', value => $self->{crit15m})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (15min) threshold '" . $self->{crit15m} . "'.");
$self->{output}->option_exit();
}
}

View File

@ -52,13 +52,11 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
{
"exclude:s" => { name => 'exclude' },
"absent-problem:s" => { name => 'absent' },
"component:s" => { name => 'component', default => 'all' },
"no-component:s" => { name => 'no_component' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
$self->{components} = {};
return $self;
@ -76,13 +74,7 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
if (defined($self->{option_results}->{no_component})) {
if ($self->{option_results}->{no_component} ne '') {
$self->{no_components} = $self->{option_results}->{no_component};
} else {
$self->{no_components} = 'critical';
}
}
}
sub global {
@ -114,14 +106,15 @@ sub run {
$self->{output}->option_exit();
}
my $total_components = 0;
my $display_by_component = '';
my $display_by_component_append = '';
foreach my $comp (sort(keys %{$self->{components}})) {
# Skipping short msg when no components
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $self->{components}->{$comp}->{name};
next if ($self->{components}->{$comp}->{total} == 0);
$total_components += $self->{components}->{$comp}->{total};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $self->{components}->{$comp}->{name};
$display_by_component_append = ', ';
}
@ -132,46 +125,20 @@ sub run {
)
);
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
$self->{output}->output_add(severity => $self->{no_components},
short_msg => 'No components are checked.');
}
$self->{output}->display();
$self->{output}->exit();
}
sub check_exclude {
my ($self, %options) = @_;
my ($self, $section) = @_;
if (defined($options{instance})) {
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
$self->{components}->{$options{section}}->{skip}++;
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
return 1;
}
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$section(\s|,|$)/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $section section."));
return 1;
}
return 0;
}
sub absent_problem {
my ($self, %options) = @_;
if (defined($self->{option_results}->{absent}) &&
$self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) {
$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;
}
1;
__END__
@ -192,15 +159,6 @@ Can be: 'fan', 'psu', 'module'.
Exclude some parts (comma seperated list) (Example: --exclude=fans,modules)
Can also exclude specific instance: --exclude=fans#1#2#,modules#1#,psus
=item B<--absent-problem>
N/A for following equipment. Not needed.
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--warning>
Threshold warning in degree celsius.

View File

@ -52,37 +52,6 @@ Total Writes: 401613
Total Reads: 6653775
Prct Idle: 94.2
======================
Mode pour les disques
======================
La commande pour tous: getdisk -state -bytrd -bytwrt -hw -hr
Bus 1 Enclosure 7 Disk 13
State: Enabled
Kbytes Read: 311959566
Kbytes Written: 0
Hard Write Errors: 0
Hard Read Errors: 0
Bus 1 Enclosure 7 Disk 14
State: Hot Spare Ready
Kbytes Read: 1957049160
Kbytes Written: 0
Hard Write Errors: 0
Hard Read Errors: 0
La commande pour un seul: getdisk 1_7_14 -state -bytrd -bytwrt -hw -hr
Bus 1 Enclosure 7 Disk 14
State: Hot Spare Ready
Kbytes Read: 1957105480
Kbytes Written: 0
Hard Write Errors: 0
Hard Read Errors: 0
======================
Mode pour les raid group
======================

View File

@ -233,19 +233,19 @@ my navisphere manage
=item B<--navicli-path>
Specify navicli path (default: '/opt/Navisphere/bin')
Specify navicli path (default: 'navicli')
=item B<--navicli-command>
Specify navicli command (default: 'navicli').
Specify navicli command (default: '/opt/Navisphere/bin').
=item B<--naviseccli-path>
Specify naviseccli path (default: '/opt/Navisphere/bin')
Specify naviseccli path (default: 'naviseccli')
=item B<--naviseccli-command>
Specify naviseccli command (default: 'naviseccli').
Specify naviseccli command (default: '/opt/Navisphere/bin').
=item B<--sudo>

View File

@ -0,0 +1,399 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package storage::emc::clariion::mode::disk;
sub get_absolute {
my ($self, %options) = @_;
my $name = $options{instance} . '_' . $options{label};
my $value;
$self->{new_datas}->{$name} = $1;
$self->{old_datas}->{$name} = $self->{statefile_value}->get(name => $name);
return undef if (!defined($self->{old_datas}->{$name}));
# Reward... put to 0
if ($self->{old_datas}->{$name} > $self->{new_datas}->{$name}) {
$self->{old_datas}->{$name} = 0;
}
$value = ($self->{new_datas}->{$name} - $self->{old_datas}->{$name});
return ($value, $value);
}
sub get_bytes_per_seconds {
my ($self, %options) = @_;
my $name = $options{instance} . '_' . $options{label};
my $value;
$self->{new_datas}->{$name} = $1;
if (!defined($self->{old_datas}->{last_timestamp})) {
$self->{old_datas}->{last_timestamp} = $self->{statefile_value}->get(name => 'last_timestamp');
}
$self->{old_datas}->{$name} = $self->{statefile_value}->get(name => $name);
return undef if (!defined($self->{old_datas}->{last_timestamp}) || !defined($self->{old_datas}->{$name}));
# Reward... put to 0
if ($self->{old_datas}->{$name} > $self->{new_datas}->{$name}) {
$self->{old_datas}->{$name} = 0;
}
# At least one second
my $delta_time = $self->{new_datas}->{last_timestamp} - $self->{old_datas}->{last_timestamp};
if ($delta_time <= 0) {
$delta_time = 1;
}
$value = ($self->{new_datas}->{$name} - $self->{old_datas}->{$name}) / $delta_time;
my ($scale_value, $scale_unit) = $self->{perfdata}->change_bytes(value => $value);
return ($value, $scale_value . ' ' . $scale_unit);
}
sub get_utils {
my ($self, %options) = @_;
my $name = $options{instance} . '_' . $options{label};
my $value;
$self->{new_datas}->{$name . '_busy'} = $1;
$self->{new_datas}->{$name . '_idle'} = $2;
$self->{old_datas}->{$name . '_busy'} = $self->{statefile_value}->get(name => $name . '_busy');
$self->{old_datas}->{$name . '_idle'} = $self->{statefile_value}->get(name => $name . '_idle');
return undef if (!defined($self->{old_datas}->{$name . '_busy'}) || !defined($self->{old_datas}->{$name . '_idle'}));
# Reward... put to 0
if ($self->{old_datas}->{$name . '_busy'} > $self->{new_datas}->{$name . '_busy'}) {
$self->{old_datas}->{$name . '_busy'} = 0;
}
if ($self->{old_datas}->{$name . '_idle'} > $self->{new_datas}->{$name . '_idle'}) {
$self->{old_datas}->{$name . '_idle'} = 0;
}
my $total_ticks = ($self->{new_datas}->{$name . '_idle'} - $self->{old_datas}->{$name . '_idle'}) +
($self->{new_datas}->{$name . '_busy'} - $self->{old_datas}->{$name . '_busy'});
if ($total_ticks <= 0) {
return (0, 0);
}
$value = ($self->{new_datas}->{$name . '_busy'} - $self->{old_datas}->{$name . '_busy'}) * 100 / $total_ticks;
return ($value, $value);
}
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::statefile;
use centreon::plugins::misc;
my $maps_counters = {
hard_read_errors => { thresholds => {
warning_hard_read_errors => { label => 'warning-hard-read-errors', exit_value => 'warning' },
critical_hard_read_errors => { label => 'critical-hard-read-errors', exit_value => 'critical' },
},
matching => 'Hard Read Errors:\s+(\d+)', closure => \&get_absolute,
output_msg => 'Hard Read Errors : %d', perfdata => '%s',
unit => '',
},
hard_write_errors => { thresholds => {
warning_hard_write_errors => { label => 'warning-hard-write-errors', exit_value => 'warning' },
critical_hard_write_errors => { label => 'critical-hard-write-errors', exit_value => 'critical' },
},
matching => 'Hard Write Errors:\s+(\d+)', closure => \&get_absolute,
output_msg => 'Hard Write Errors : %d', perfdata => '%s',
unit => '',
},
write_io => { thresholds => {
warning_write_io => { label => 'warning-write-io', exit_value => 'warning' },
critical_write_io => { label => 'critical-write-io', exit_value => 'critical' },
},
matching => 'Kbytes Written:\s+(\d+)', closure => \&get_bytes_per_seconds,
output_msg => 'Write I/O : %s', perfdata => '%d',
unit => 'B',
},
read_io => { thresholds => {
warning_read_io => { label => 'warning-read-io', exit_value => 'warning' },
critical_read_io => { label => 'critical-read-io', exit_value => 'critical' },
},
matching => 'Kbytes Read:\s+(\d+)', closure => \&get_bytes_per_seconds,
output_msg => 'Read I/O : %s', perfdata => '%d',
unit => 'B',
},
utils => { thresholds => {
warning_utils => { label => 'warning-utils', exit_value => 'warning' },
critical_utils => { label => 'critical-utils', exit_value => 'critical' },
},
matching => 'Busy Ticks:\s+(\d+).*Idle Ticks:\s+(\d+)', closure => \&get_utils,
output_msg => 'Utils : %.2f %%', perfdata => '%.2f',
unit => '%',
},
};
my @states = (
['^enabled$' , 'OK'],
['^binding$' , 'OK'],
['^expanding$' , 'OK'],
['^ready$' , 'OK'],
['^unbound$' , 'OK'],
['^empty$' , 'OK'],
['^hot spare ready$' , 'OK'],
['^powering up$' , 'OK'],
['^equalizing$' , 'WARNING'],
['^formatting$' , 'WARNING'],
['^removed$' , 'WARNING'],
['^unformatted$' , 'WARNING'],
['^failed$' , 'CRITICAL'],
['^off$' , 'CRITICAL'],
['^empty$' , 'CRITICAL'],
['^unsupported$' , 'CRITICAL'],
['^.*$' , '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 =>
{
"threshold-overload:s@" => { name => 'threshold_overload' },
"filter-raidgroupid:s" => { name => 'filter_raidgroupid', },
"filter-disk:s" => { name => 'filter_disk', },
});
foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
$options{options}->add_options(arguments => {
$maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name },
});
}
}
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
foreach (keys %{$maps_counters}) {
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
$self->{output}->option_exit();
}
}
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
if ($val !~ /(.*?)=(.*)/) {
$self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($filter, $threshold) = ($1, $2);
if ($self->{output}->is_litteral_status(status => $threshold) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'.");
$self->{output}->option_exit();
}
$self->{overload_th}->{$filter} = $threshold;
}
$self->{statefile_value}->check_options(%options);
}
sub get_severity {
my ($self, %options) = @_;
my $status = 'unknown';
foreach my $entry (@states) {
if ($options{value} =~ /${$entry}[0]/i) {
$status = ${$entry}[1];
foreach my $filter (keys %{$self->{overload_th}}) {
if (${$entry}[0] =~ /$filter/i) {
$status = $self->{overload_th}->{$filter};
last;
}
}
last;
}
}
return $status;
}
sub run {
my ($self, %options) = @_;
my $clariion = $options{custom};
my $response = $clariion->execute_command(cmd => 'getdisk -state -bytrd -bytwrt -hw -hr -busyticks -idleticks -rg');
my ($total_num_disks, $skip_num_disks) = (0, 0);
$self->{new_datas} = {};
$self->{statefile_value}->read(statefile => "cache_clariion_" . $clariion->{hostname} . '_' . $self->{mode});
$self->{new_datas}->{last_timestamp} = time();
#Bus 1 Enclosure 7 Disk 13
#State: Enabled
#Kbytes Read: 1109878030
#Kbytes Written: 0
#Hard Write Errors: 0
#Hard Read Errors: 0
#Busy Ticks: 462350
#Idle Ticks: 388743630
#Raid Group ID: 0
while ($response =~ /^Bus\s+(\S+)\s+Enclosure\s+(\S+)\s+Disk\s+(\S+)(.*?)\n\n/msgi) {
my $disk_instance = "$1_$2_$3";
my $values = $4;
# First Filters
if (defined($self->{option_results}->{filter_disk}) && $self->{option_results}->{filter_disk} ne '' &&
$disk_instance !~ /$self->{option_results}->{filter_disk}/) {
$skip_num_disks++;
$self->{output}->output_add(long_msg => "Skipping disk '" . $disk_instance . "': no matching filter disk");
next;
}
if (defined($self->{option_results}->{filter_raidgroupid}) && $self->{option_results}->{filter_raidgroupid} ne '' &&
$values =~ /^Raid Group ID:\s+(\S+)/mi && $1 !~ /$self->{option_results}->{filter_raidgroupid}/) {
$skip_num_disks++;
$self->{output}->output_add(long_msg => "Skipping disk '" . $disk_instance . "': no matching filter raid group id");
next;
}
$total_num_disks++;
$values =~ /^State:\s+(.*?)(\n|$)/msi;
my $state = centreon::plugins::misc::trim($1);
my $exit = $self->get_severity(value => $state);
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Disk '%s' state is %s",
$disk_instance, $state));
# Don't check values if in critical/warning
next;
}
# Work on values. No check if in 'Hot Spare Ready' or 'Unbound'
next if ($state =~ /^(Hot Spare Ready|Unbound)$/i);
my ($short_msg, $long_msg) = ('', '');
my @exits;
foreach (keys %{$maps_counters}) {
next if ($values !~ /$maps_counters->{$_}->{matching}/msi);
my ($value_check, $value_output) = &{$maps_counters->{$_}->{closure}}($self,
instance => $disk_instance, label => $_);
next if (!defined($value_check));
my ($warning, $critical);
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
my $exit2 = $self->{perfdata}->threshold_check(value => $value_check, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]);
$long_msg .= ' ' . sprintf($maps_counters->{$_}->{output_msg}, $value_output);
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
$short_msg .= ' ' . sprintf($maps_counters->{$_}->{output_msg}, $value_output);
}
push @exits, $exit2;
$warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning');
$critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical');
}
$self->{output}->output_add(long_msg => "Disk '$disk_instance':$long_msg");
$self->{output}->perfdata_add(label => $_ . '_' . $disk_instance, unit => $maps_counters->{$_}->{unit},
value => sprintf($maps_counters->{$_}->{perfdata}, $value_check),
warning => $warning,
critical => $critical,
min => 0);
}
$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 => "Disk '$disk_instance':$short_msg"
);
}
}
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("All %s disks are ok.",
$total_num_disks . '/' . $skip_num_disks)
);
$self->{statefile_value}->write(data => $self->{new_datas});
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check the status of the physical disks.
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'read-errors', 'write-errors', 'read-io', 'write-io', 'utils'.
=item B<--critical-*>
Threshold critical.
Can be: 'read-errors', 'write-errors', 'read-io', 'write-io', 'utils'.
=item B<--threshold-overload>
Set to overload default threshold value.
Example: --threshold-overload='(enabled)=critical'
=item B<--filter-disk>
Filter Disk (regexp can be used).
Example: 1_7_14 ([BUS]_[ENCLOSURE]_[DISK]).
=item B<--filter-raidgroupid>
Filter Raid Group ID (regexp can be used).
Example: N/A or a number.
=back
=cut

View File

@ -198,7 +198,7 @@ Example: N/A, SATAII, Fibre Channel,...
Filter Raid types (regexp can be used).
Example: N/A, Hot Spare, RAID5,...
=item B<--filter-raidtype>
=item B<--filter-raidgroupid>
Filter Raid Group ID (regexp can be used).
Example: N/A or a number.

View File

@ -33,164 +33,42 @@
#
####################################################################################
package storage::emc::clariion::mode::sp;
use base qw(centreon::plugins::mode);
package storage::emc::clariion::mode::spcomponents::sp;
use strict;
use warnings;
use centreon::plugins::misc;
use storage::emc::clariion::mode::spcomponents::fan;
use storage::emc::clariion::mode::spcomponents::lcc;
use storage::emc::clariion::mode::spcomponents::psu;
use storage::emc::clariion::mode::spcomponents::memory;
use storage::emc::clariion::mode::spcomponents::cpu;
use storage::emc::clariion::mode::spcomponents::iomodule;
use storage::emc::clariion::mode::spcomponents::cable;
use storage::emc::clariion::mode::spcomponents::sp;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"exclude:s" => { name => 'exclude' },
"component:s" => { name => 'component', default => 'all' },
"no-component:s" => { name => 'no_component' },
});
my %conditions = (
1 => ['^(?!(Present|Valid)$)' => 'CRITICAL'],
);
$self->{components} = {};
$self->{no_components} = undef;
return $self;
}
sub check {
my ($self) = @_;
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
$self->{output}->output_add(long_msg => "Checking sp");
$self->{components}->{sp} = {name => 'sp', total => 0, skip => 0};
return if ($self->check_exclude(section => 'sp'));
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';
# SP A State: Present
while ($self->{response} =~ /^SP\s+(\S+)\s+State:\s+(.*)$/mgi) {
my $instance = $1;
my $state = $2;
next if ($self->check_exclude(section => 'sp', instance => $instance));
$self->{components}->{sp}->{total}++;
$self->{output}->output_add(long_msg => sprintf("sp '%s' state is %s.",
$instance, $state)
);
foreach (keys %conditions) {
if ($state =~ /${$conditions{$_}}[0]/i) {
$self->{output}->output_add(severity => ${$conditions{$_}}[1],
short_msg => sprintf("sp '%s' state is %s",
$instance, $state));
last;
}
}
}
}
sub component {
my ($self, %options) = @_;
if ($self->{option_results}->{component} eq 'all') {
storage::emc::clariion::mode::spcomponents::fan::check($self);
storage::emc::clariion::mode::spcomponents::lcc::check($self);
storage::emc::clariion::mode::spcomponents::psu::check($self);
storage::emc::clariion::mode::spcomponents::cable::check($self);
storage::emc::clariion::mode::spcomponents::iomodule::check($self);
storage::emc::clariion::mode::spcomponents::memory::check($self);
storage::emc::clariion::mode::spcomponents::cpu::check($self);
storage::emc::clariion::mode::spcomponents::sp::check($self);
} elsif ($self->{option_results}->{component} eq 'sp') {
storage::emc::clariion::mode::spcomponents::sp::check($self);
} elsif ($self->{option_results}->{component} eq 'fan') {
storage::emc::clariion::mode::spcomponents::fan::check($self);
} elsif ($self->{option_results}->{component} eq 'lcc') {
storage::emc::clariion::mode::spcomponents::lcc::check($self);
} elsif ($self->{option_results}->{component} eq 'psu') {
storage::emc::clariion::mode::spcomponents::psu::check($self);
} elsif ($self->{option_results}->{component} eq 'memory') {
storage::emc::clariion::mode::spcomponents::memory::check($self);
} elsif ($self->{option_results}->{component} eq 'cpu') {
storage::emc::clariion::mode::spcomponents::cpu::check($self);
} elsif ($self->{option_results}->{component} eq 'io') {
storage::emc::clariion::mode::spcomponents::iomodule::check($self);
} elsif ($self->{option_results}->{component} eq 'cable') {
storage::emc::clariion::mode::spcomponents::cable::check($self);
} else {
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
$self->{output}->option_exit();
}
my $total_components = 0;
my $display_by_component = '';
my $display_by_component_append = '';
foreach my $comp (sort(keys %{$self->{components}})) {
# Skipping short msg when no components
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $self->{components}->{$comp}->{name};
$display_by_component_append = ', ';
}
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("All %s components [%s] are ok.",
$total_components,
$display_by_component)
);
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
$self->{output}->output_add(severity => $self->{no_components},
short_msg => 'No components are checked.');
}
}
sub run {
my ($self, %options) = @_;
my $clariion = $options{custom};
$self->{response} = $clariion->execute_command(cmd => 'getcrus -all');
chomp $self->{response};
$self->component();
$self->{output}->display();
$self->{output}->exit();
}
sub check_exclude {
my ($self, %options) = @_;
if (defined($options{instance})) {
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
$self->{components}->{$options{section}}->{skip}++;
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
return 1;
}
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
return 1;
}
return 0;
}
1;
__END__
=head1 MODE
Check status of storage processor.
=over 8
=item B<--component>
Which component to check (Default: 'all').
Can be: 'cpu', 'psu', 'pc', 'fan', 'network', 'temperature', 'storage'.
=item B<--exclude>
Exclude some parts (comma seperated list) (Example: --exclude=fan,lcc)
Can also exclude specific instance: --exclude=fan#1.2#,lcc
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=back
=cut
1;

View File

@ -49,6 +49,7 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'cache' => 'storage::emc::clariion::mode::cache',
'disk' => 'storage::emc::clariion::mode::disk',
'sp' => 'storage::emc::clariion::mode::sp',
'faults' => 'storage::emc::clariion::mode::faults',
'list-luns' => 'storage::emc::clariion::mode::listluns',