diff --git a/network/redback/snmp/mode/disk.pm b/network/redback/snmp/mode/disk.pm index bfeb9df61..db87ed23e 100644 --- a/network/redback/snmp/mode/disk.pm +++ b/network/redback/snmp/mode/disk.pm @@ -229,7 +229,7 @@ sub manage_selection { } $self->{disk_selected}->{$instance} = { display => $result->{rbnSRStorageDescr}, - used => $result->{rbnSRStorageUtilization}, total => $result->{rbnSRStorageSize} * 1024}; + used => $result->{rbnSRStorageUtilization}, total => $result->{rbnSRStorageSize} * 1024}; } if (scalar(keys %{$self->{disk_selected}}) <= 0) { diff --git a/storage/dell/equallogic/snmp/mode/arraystats.pm b/storage/dell/equallogic/snmp/mode/arraystats.pm new file mode 100644 index 000000000..3cf863ac7 --- /dev/null +++ b/storage/dell/equallogic/snmp/mode/arraystats.pm @@ -0,0 +1,381 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::snmp::mode::arraystats; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; +use centreon::plugins::statefile; + +my $maps_counters = { + '000_connections' => { set => { + key_values => [ { name => 'eqlMemberNumberOfConnections' }, { name => 'display' } ], + output_template => 'iSCSI connections : %s', + perfdatas => [ + { label => 'connections', value => 'eqlMemberNumberOfConnections_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + '001_ext-connections' => { set => { + key_values => [ { name => 'eqlMemberNumberOfExtConnections' }, { name => 'display' } ], + output_template => 'External iSCSI connections : %s', + perfdatas => [ + { label => 'ext_connections', value => 'eqlMemberNumberOfExtConnections_absolute', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + '002_global-read-avg-latency' => { set => { + key_values => [ { name => 'eqlMemberReadAvgLatency' }, { name => 'display' } ], + output_template => 'Global read average latency : %s ms', + perfdatas => [ + { label => 'global_read_avg_latency', value => 'eqlMemberReadAvgLatency_absolute', template => '%s', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + '003_global-write-avg-latency' => { set => { + key_values => [ { name => 'eqlMemberWriteAvgLatency' }, { name => 'display' } ], + output_template => 'Global write average latency : %s ms', + perfdatas => [ + { label => 'global_write_avg_latency', value => 'eqlMemberWriteAvgLatency_absolute', template => '%s', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + '005_read-avg-latency' => { set => { + key_values => [ { name => 'eqlMemberReadLatency', diff => 1 }, { name => 'eqlMemberReadOpCount', diff => 1 }, { name => 'display' } ], + output_template => 'Read average latency : %.2f ms', threshold_use => 'read_avg_latency', output_use => 'read_avg_latency', + closure_custom_calc => \&custom_read_avg_latency_calc, + perfdatas => [ + { label => 'read_avg_latency', value => 'read_avg_latency', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + '006_write-avg-latency' => { set => { + key_values => [ { name => 'eqlMemberWriteLatency', diff => 1 }, { name => 'eqlMemberWriteOpCount', diff => 1 }, { name => 'display' } ], + output_template => 'Write average latency : %.2f ms', threshold_use => 'write_avg_latency', output_use => 'write_avg_latency', + closure_custom_calc => \&custom_write_avg_latency_calc, + perfdatas => [ + { label => 'write_avg_latency', value => 'write_avg_latency', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + '007_read-iops' => { set => { + key_values => [ { name => 'eqlMemberReadOpCount', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => 'Read IOPs : %.2f', + perfdatas => [ + { label => 'read_iops', template => '%.2f', value => 'eqlMemberReadOpCount_per_second', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + '008_write-iops' => { set => { + key_values => [ { name => 'eqlMemberWriteOpCount', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => 'Write IOPs : %.2f', + perfdatas => [ + { label => 'write_iops', template => '%.2f', value => 'eqlMemberWriteOpCount_per_second', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + + '010_traffic-in' => { set => { + key_values => [ { name => 'eqlMemberRxData', diff => 1 }, { name => 'display' } ], + per_second => 1, output_change_bytes => 2, + output_template => 'Traffic In : %s %s/s', + perfdatas => [ + { label => 'traffic_in', value => 'eqlMemberRxData_per_second', template => '%s', + unit => 'b/s', min => 0, cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + '011_traffic-out' => { set => { + key_values => [ { name => 'eqlMemberTxData', diff => 1 }, { name => 'display' } ], + per_second => 1, output_change_bytes => 2, + output_template => 'Traffic Out : %s %s/s', + perfdatas => [ + { label => 'traffic_out', value => 'eqlMemberTxData_per_second', template => '%s', + unit => 'b/s', min => 0, cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, +}; + +sub custom_write_avg_latency_calc { + my ($self, %options) = @_; + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + my $diff_op = $options{new_datas}->{$self->{instance} . '_eqlMemberWriteOpCount'} - $options{old_datas}->{$self->{instance} . '_eqlMemberWriteOpCount'}; + my $diff_latency = $options{new_datas}->{$self->{instance} . '_eqlMemberWriteLatency'} - $options{old_datas}->{$self->{instance} . '_eqlMemberWriteLatency'}; + if ($diff_op == 0) { + $self->{result_values}->{write_avg_latency} = 0; + } else { + $self->{result_values}->{write_avg_latency} = $diff_latency / $diff_op; + } + + return 0; +} + +sub custom_read_avg_latency_calc { + my ($self, %options) = @_; + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + my $diff_op = $options{new_datas}->{$self->{instance} . '_eqlMemberReadOpCount'} - $options{old_datas}->{$self->{instance} . '_eqlMemberReadOpCount'}; + my $diff_latency = $options{new_datas}->{$self->{instance} . '_eqlMemberReadLatency'} - $options{old_datas}->{$self->{instance} . '_eqlMemberReadLatency'}; + if ($diff_op == 0) { + $self->{result_values}->{read_avg_latency} = 0; + } else { + $self->{result_values}->{read_avg_latency} = $diff_latency / $diff_op; + } + 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' }, + }); + $self->{statefile_value} = centreon::plugins::statefile->new(%options); + + foreach (keys %{$maps_counters}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$_}->{threshold}) || $maps_counters->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + $maps_counters->{$_}->{obj} = centreon::plugins::values->new(statefile => $self->{statefile_value}, + output => $self->{output}, perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}}); + } + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach (keys %{$maps_counters}) { + $maps_counters->{$_}->{obj}->init(option_results => $self->{option_results}); + } + + $self->{statefile_value}->check_options(%options); +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + $self->{hostname} = $self->{snmp}->get_hostname(); + $self->{snmp_port} = $self->{snmp}->get_port(); + + $self->manage_selection(); + + my $multiple = 1; + if (scalar(keys %{$self->{member_selected}}) == 1) { + $multiple = 0; + } + + if ($multiple == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'All array statistics are ok'); + } + + $self->{new_datas} = {}; + $self->{statefile_value}->read(statefile => "dell_equallogic_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); + $self->{new_datas}->{last_timestamp} = time(); + + foreach my $id (sort keys %{$self->{member_selected}}) { + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits; + foreach (sort keys %{$maps_counters}) { + $maps_counters->{$_}->{obj}->set(instance => $id); + + my ($value_check) = $maps_counters->{$_}->{obj}->execute(new_datas => $self->{new_datas}, + values => $self->{member_selected}->{$id}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $maps_counters->{$_}->{obj}->threshold_check(); + push @exits, $exit2; + + my $output = $maps_counters->{$_}->{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 = ', '; + } + + $maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple); + } + + $self->{output}->output_add(long_msg => "'" . $self->{member_selected}->{$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 => "'" . $self->{member_selected}->{$id}->{display} . "' $short_msg" + ); + } + + if ($multiple == 0) { + $self->{output}->output_add(short_msg => "'" . $self->{member_selected}->{$id}->{display} . "' $long_msg"); + } + } + + $self->{statefile_value}->write(data => $self->{new_datas}); + $self->{output}->display(); + $self->{output}->exit(); +} + +my $mapping = { + eqlMemberNumberOfConnections => { oid => '.1.3.6.1.4.1.12740.2.1.12.1.1' }, + eqlMemberReadLatency => { oid => '.1.3.6.1.4.1.12740.2.1.12.1.2' }, + eqlMemberWriteLatency => { oid => '.1.3.6.1.4.1.12740.2.1.12.1.3' }, + eqlMemberReadAvgLatency => { oid => '.1.3.6.1.4.1.12740.2.1.12.1.4' }, + eqlMemberWriteAvgLatency => { oid => '.1.3.6.1.4.1.12740.2.1.12.1.5' }, + eqlMemberReadOpCount => { oid => '.1.3.6.1.4.1.12740.2.1.12.1.6' }, + eqlMemberWriteOpCount => { oid => '.1.3.6.1.4.1.12740.2.1.12.1.7' }, + eqlMemberTxData => { oid => '.1.3.6.1.4.1.12740.2.1.12.1.8' }, + eqlMemberRxData => { oid => '.1.3.6.1.4.1.12740.2.1.12.1.9' }, + eqlMemberNumberOfExtConnections => { oid => '.1.3.6.1.4.1.12740.2.1.12.1.10' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_eqlMemberName = '.1.3.6.1.4.1.12740.2.1.1.1.9'; + my $oid_eqlMemberConnEntry = '.1.3.6.1.4.1.12740.2.1.12.1'; + + $self->{member_selected} = {}; + #$self->{results} = $self->{snmp}->get_multiple_table(oids => [ + # { oid => $oid_eqlMemberName }, + # { oid => $oid_eqlMemberConnEntry }, + # ], + # nothing_quit => 1); + + $self->{results}->{$oid_eqlMemberName} = { + '.1.3.6.1.4.1.12740.2.1.1.1.9.1.1832149271' => "EQL4k2", + '.1.3.6.1.4.1.12740.2.1.1.1.9.1.1956449702' => "EQL4k1" + }; + $self->{results}->{$oid_eqlMemberConnEntry} = { + '.1.3.6.1.4.1.12740.2.1.12.1.1.1.1832149271' => 30, + '.1.3.6.1.4.1.12740.2.1.12.1.2.1.1832149271' => 135418282, + '.1.3.6.1.4.1.12740.2.1.12.1.3.1.1832149271' => 11543981, + '.1.3.6.1.4.1.12740.2.1.12.1.4.1.1832149271' => 7, + '.1.3.6.1.4.1.12740.2.1.12.1.5.1.1832149271' => 1, + # '.1.3.6.1.4.1.12740.2.1.12.1.6.1.1832149271' => 20019257, + '.1.3.6.1.4.1.12740.2.1.12.1.7.1.1832149271' => 8584670, + '.1.3.6.1.4.1.12740.2.1.12.1.8.1.1832149271' => 504457911808, + '.1.3.6.1.4.1.12740.2.1.12.1.9.1.1832149271' => 364591348224, + '.1.3.6.1.4.1.12740.2.1.12.1.10.1.1832149271' => 30, + }; + + foreach my $oid (keys %{$self->{results}->{$oid_eqlMemberConnEntry}}) { + next if ($oid !~ /^$mapping->{eqlMemberNumberOfConnections}->{oid}\.(\d+\.\d+)/); + my $member_instance = $1; + next if (!defined($self->{results}->{$oid_eqlMemberName}->{$oid_eqlMemberName . '.' . $member_instance})); + my $member_name = $self->{results}->{$oid_eqlMemberName}->{$oid_eqlMemberName . '.' . $member_instance}; + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberConnEntry}, instance => $member_instance); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $member_name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $member_name . "': no matching filter."); + next; + } + + $self->{member_selected}->{$member_name} = { display => $member_name, + %{$result} + }; + $self->{member_selected}->{$member_name}->{eqlMemberTxData} *= 8 if (defined($self->{member_selected}->{$member_name}->{eqlMemberTxData})); + $self->{member_selected}->{$member_name}->{eqlMemberRxData} *= 8 if (defined($self->{member_selected}->{$member_name}->{eqlMemberRxData})); + } + + if (scalar(keys %{$self->{member_selected}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No entry found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check global array statistics. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'connections', 'ext-connections', 'global-read-avg-latency' (ms), 'global-write-avg-latency' (ms), +'read-avg-latency' (ms), 'write-avg-latency' (ms), 'read-iops' (iops), 'write-iops (iops), 'traffic-in' (b/s), 'traffic-out' (b/s). + +=item B<--critical-*> + +Threshold critical. +Can be: 'connections', 'ext-connections', 'global-read-avg-latency' (ms), 'global-write-avg-latency' (ms), +'read-avg-latency' (ms), 'write-avg-latency' (ms), 'read-iops' (iops), 'write-iops (iops), 'traffic-in' (b/s), 'traffic-out' (b/s). + +=item B<--filter-name> + +Filter disk name (can be a regexp). + +=back + +=cut diff --git a/storage/dell/equallogic/snmp/mode/components/disk.pm b/storage/dell/equallogic/snmp/mode/components/disk.pm new file mode 100644 index 000000000..e835cb6e5 --- /dev/null +++ b/storage/dell/equallogic/snmp/mode/components/disk.pm @@ -0,0 +1,94 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::snmp::mode::components::disk; + +use strict; +use warnings; + +my %map_disk_status = ( + 1 => 'on-line', + 2 => 'spare', + 3 => 'failed', + 4 => 'off-line', + 5 => 'alt-sig', + 6 => 'too-small', + 7 => 'history-of-failures', + 8 => 'unsupported-version', + 9 => 'unhealthy', + 10 => 'replacement', +); + +# In MIB 'eqldisk.mib' +my $mapping = { + eqlDiskStatus => { oid => '.1.3.6.1.4.1.12740.3.1.1.1.8', map => \%map_disk_status }, +}; +my $oid_eqlDiskStatus = '.1.3.6.1.4.1.12740.3.1.1.1.8'; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $oid_eqlDiskStatus }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking disks"); + $self->{components}->{disk} = {name => 'disks', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'disk')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlDiskStatus}})) { + next if ($oid !~ /^$mapping->{eqlDiskStatus}->{oid}\.(\d+\.\d+)\.(.*)$/); + my ($member_instance, $instance) = ($1, $2); + my $member_name = $self->get_member_name(instance => $member_instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlDiskStatus}, instance => $member_instance . '.' . $instance); + + next if ($self->check_exclude(section => 'disk', instance => $instance)); + $self->{components}->{disk}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Disk '%s/%s' status is %s [instance: %s].", + $member_name, $instance, $result->{eqlDiskStatus}, $instance + )); + my $exit = $self->get_severity(section => 'disk', value => $result->{eqlDiskStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Disk '%s/%s' status is %s", + $member_name, $instance, $result->{eqlDiskStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/storage/dell/equallogic/snmp/mode/components/fan.pm b/storage/dell/equallogic/snmp/mode/components/fan.pm new file mode 100644 index 000000000..4fe8f8145 --- /dev/null +++ b/storage/dell/equallogic/snmp/mode/components/fan.pm @@ -0,0 +1,116 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::snmp::mode::components::fan; + +use strict; +use warnings; + +my %map_fan_status = ( + 0 => 'unknown', + 1 => 'normal', + 2 => 'warning', + 3 => 'critical', +); + +# In MIB 'eqlcontroller.mib' +my $mapping = { + eqlMemberHealthDetailsFanName => { oid => '.1.3.6.1.4.1.12740.2.1.7.1.2' }, + eqlMemberHealthDetailsFanValue => { oid => '.1.3.6.1.4.1.12740.2.1.7.1.3' }, + eqlMemberHealthDetailsFanCurrentState => { oid => '.1.3.6.1.4.1.12740.2.1.7.1.4', map => \%map_fan_status }, + eqlMemberHealthDetailsFanHighCriticalThreshold => { oid => '.1.3.6.1.4.1.12740.2.1.7.1.5' }, + eqlMemberHealthDetailsFanHighWarningThreshold => { oid => '.1.3.6.1.4.1.12740.2.1.7.1.6' }, + eqlMemberHealthDetailsFanLowCriticalThreshold => { oid => '.1.3.6.1.4.1.12740.2.1.7.1.7' }, + eqlMemberHealthDetailsFanLowWarningThreshold => { oid => '.1.3.6.1.4.1.12740.2.1.7.1.8' }, +}; +my $oid_eqlMemberHealthDetailsFanEntry = '.1.3.6.1.4.1.12740.2.1.7.1'; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $oid_eqlMemberHealthDetailsFanEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fans"); + $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'fan')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlMemberHealthDetailsFanEntry}})) { + next if ($oid !~ /^$mapping->{eqlMemberHealthDetailsFanCurrentState}->{oid}\.(\d+\.\d+)\.(.*)$/); + my ($member_instance, $instance) = ($1, $2); + my $member_name = $self->get_member_name(instance => $member_instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberHealthDetailsFanEntry}, instance => $member_instance . '.' . $instance); + + next if ($self->check_exclude(section => 'fan', instance => $instance)); + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Fan '%s/%s' status is %s [instance: %s].", + $member_name, $result->{eqlMemberHealthDetailsFanName}, $result->{eqlMemberHealthDetailsFanCurrentState}, + $instance + )); + my $exit = $self->get_severity(section => 'fan', value => $result->{eqlMemberHealthDetailsFanCurrentState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan '%s/%s' status is %s", + $member_name, $result->{eqlMemberHealthDetailsFanName}, $result->{eqlMemberHealthDetailsFanCurrentState})); + } + + if (defined($result->{eqlMemberHealthDetailsFanValue})) { + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{eqlMemberHealthDetailsFanValue}); + if ($checked == 0) { + my $warn_th = $result->{eqlMemberHealthDetailsFanLowWarningThreshold} . ':' . $result->{eqlMemberHealthDetailsFanHighWarningThreshold}; + my $crit_th = $result->{eqlMemberHealthDetailsFanLowCriticalThreshold} . ':' . $result->{eqlMemberHealthDetailsFanHighCriticalThreshold}; + $self->{perfdata}->threshold_validate(label => 'warning-fan-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-fan-instance-' . $instance, value => $crit_th); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-fan-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-fan-instance-' . $instance); + } + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Fan '%s/%s' speed is %s rpm", $member_name, $result->{eqlMemberHealthDetailsFanName}, $result->{eqlMemberHealthDetailsFanValue})); + } + $self->{output}->perfdata_add(label => "fan_" . $member_name . "_" . $instance, unit => 'rpm', + value => $result->{eqlMemberHealthDetailsFanValue}, + warning => $warn, + critical => $crit, + min => 0); + } + } +} + +1; \ No newline at end of file diff --git a/storage/dell/equallogic/snmp/mode/components/health.pm b/storage/dell/equallogic/snmp/mode/components/health.pm new file mode 100644 index 000000000..b6e8b51d5 --- /dev/null +++ b/storage/dell/equallogic/snmp/mode/components/health.pm @@ -0,0 +1,89 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::snmp::mode::components::health; + +use strict; +use warnings; + +my %map_health_status = ( + 0 => 'unknown', + 1 => 'normal', + 2 => 'warning', + 3 => 'critical', +); + +# In MIB 'eqlcontroller.mib' +my $mapping = { + eqlMemberHealthStatus => { oid => '.1.3.6.1.4.1.12740.2.1.5.1.1', map => \%map_health_status }, +}; +my $oid_eqlMemberHealthStatus = '.1.3.6.1.4.1.12740.2.1.5.1.1'; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $oid_eqlMemberHealthStatus }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking health"); + $self->{components}->{health} = {name => 'health', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'health')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlMemberHealthStatus}})) { + next if ($oid !~ /^$mapping->{eqlMemberHealthStatus}->{oid}\.(\d+\.\d+)$/); + my ($member_instance) = ($1); + my $member_name = $self->get_member_name(instance => $member_instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberHealthStatus}, instance => $member_instance); + + next if ($self->check_exclude(section => 'health', instance => $member_instance)); + $self->{components}->{health}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Health '%s' status is %s [instance: %s].", + $member_name, $result->{eqlMemberHealthStatus}, + $member_name + )); + my $exit = $self->get_severity(section => 'health', value => $result->{eqlMemberHealthStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Health '%s' status is %s", + $member_name, $result->{eqlMemberHealthStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/storage/dell/equallogic/snmp/mode/components/psu.pm b/storage/dell/equallogic/snmp/mode/components/psu.pm new file mode 100644 index 000000000..d74f60400 --- /dev/null +++ b/storage/dell/equallogic/snmp/mode/components/psu.pm @@ -0,0 +1,103 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::snmp::mode::components::psu; + +use strict; +use warnings; + +my %map_psu_status = ( + 1 => 'on-and-operating', + 2 => 'no-ac-power', + 3 => 'failed-or-no-data', +); +my %map_psufan_status = ( + 0 => 'not-applicable', + 1 => 'fan-is-operational', + 2 => 'fan-not-operational', +); + +# In MIB 'eqlcontroller.mib' +my $mapping = { + eqlMemberHealthDetailsPowerSupplyName => { oid => '.1.3.6.1.4.1.12740.2.1.8.1.2' }, + eqlMemberHealthDetailsPowerSupplyCurrentState => { oid => '.1.3.6.1.4.1.12740.2.1.8.1.3', map => \%map_psu_status }, + eqlMemberHealthDetailsPowerSupplyFanStatus => { oid => '.1.3.6.1.4.1.12740.2.1.8.1.4', map => \%map_psufan_status }, +}; +my $oid_eqlMemberHealthDetailsPowerSupplyEntry = '.1.3.6.1.4.1.12740.2.1.8.1'; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $oid_eqlMemberHealthDetailsPowerSupplyEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supplies"); + $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'psu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlMemberHealthDetailsPowerSupplyEntry}})) { + next if ($oid !~ /^$mapping->{eqlMemberHealthDetailsPowerSupplyCurrentState}->{oid}\.(\d+\.\d+)\.(.*)$/); + my ($member_instance, $instance) = ($1, $2); + my $member_name = $self->get_member_name(instance => $member_instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberHealthDetailsPowerSupplyEntry}, instance => $member_instance . '.' . $instance); + + next if ($self->check_exclude(section => 'psu', instance => $instance)); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Power supply '%s/%s' status is %s [instance: %s] [fan status: %s].", + $member_name, $result->{eqlMemberHealthDetailsPowerSupplyName}, $result->{eqlMemberHealthDetailsPowerSupplyCurrentState}, + $instance, $result->{eqlMemberHealthDetailsPowerSupplyFanStatus} + )); + my $exit = $self->get_severity(section => 'psu', value => $result->{eqlMemberHealthDetailsPowerSupplyCurrentState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power supply '%s/%s' status is %s", + $member_name, $result->{eqlMemberHealthDetailsPowerSupplyName}, $result->{eqlMemberHealthDetailsPowerSupplyCurrentState})); + } + + next if ($self->check_exclude(section => 'psu.fan', instance => $instance)); + $exit = $self->get_severity(section => 'psu.fan', value => $result->{eqlMemberHealthDetailsPowerSupplyFanStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power supply '%s/%s' fan status is %s", + $member_name, $result->{eqlMemberHealthDetailsPowerSupplyName}, $result->{eqlMemberHealthDetailsPowerSupplyFanStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/storage/dell/equallogic/snmp/mode/components/raid.pm b/storage/dell/equallogic/snmp/mode/components/raid.pm new file mode 100644 index 000000000..1fc6fcb8f --- /dev/null +++ b/storage/dell/equallogic/snmp/mode/components/raid.pm @@ -0,0 +1,92 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::snmp::mode::components::raid; + +use strict; +use warnings; + +my %map_raid_status = ( + 1 => 'ok', + 2 => 'degraded', + 3 => 'verifying', + 4 => 'reconstructing', + 5 => 'failed', + 6 => 'catastrophicLoss', + 7 => 'expanding', + 8 => 'mirroring', +); + +# In MIB 'eqlcontroller.mib' +my $mapping = { + eqlMemberRaidStatus => { oid => '.1.3.6.1.4.1.12740.2.1.13.1.1', map => \%map_raid_status }, +}; +my $oid_eqlMemberRAIDEntry = '.1.3.6.1.4.1.12740.2.1.13.1'; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $oid_eqlMemberRAIDEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking raids"); + $self->{components}->{raid} = {name => 'raids', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'raid')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlMemberRAIDEntry}})) { + next if ($oid !~ /^$mapping->{eqlMemberRaidStatus}->{oid}\.(\d+\.\d+)$/); + my ($member_instance) = ($1); + my $member_name = $self->get_member_name(instance => $member_instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberRAIDEntry}, instance => $member_instance); + + next if ($self->check_exclude(section => 'raid', instance => $member_instance)); + $self->{components}->{raid}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Raid '%s' status is %s [instance: %s].", + $member_name, $result->{eqlMemberRaidStatus}, $member_name + )); + my $exit = $self->get_severity(section => 'raid', value => $result->{eqlMemberRaidStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Raid '%s' status is %s", + $member_name, $result->{eqlMemberRaidStatus})); + } + } +} + +1; \ No newline at end of file diff --git a/storage/dell/equallogic/snmp/mode/components/temperature.pm b/storage/dell/equallogic/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..85d0710fd --- /dev/null +++ b/storage/dell/equallogic/snmp/mode/components/temperature.pm @@ -0,0 +1,115 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::snmp::mode::components::temperature; + +use strict; +use warnings; + +my %map_temperature_status = ( + 0 => 'unknown', + 1 => 'normal', + 2 => 'warning', + 3 => 'critical', +); + +# In MIB 'eqlcontroller.mib' +my $mapping = { + eqlMemberHealthDetailsTemperatureName => { oid => '.1.3.6.1.4.1.12740.2.1.6.1.2' }, + eqlMemberHealthDetailsTemperatureValue => { oid => '.1.3.6.1.4.1.12740.2.1.6.1.3' }, + eqlMemberHealthDetailsTemperatureCurrentState => { oid => '.1.3.6.1.4.1.12740.2.1.6.1.4', map => \%map_temperature_status }, + eqlMemberHealthDetailsTemperatureHighCriticalThreshold => { oid => '.1.3.6.1.4.1.12740.2.1.6.1.5' }, + eqlMemberHealthDetailsTemperatureHighWarningThreshold => { oid => '.1.3.6.1.4.1.12740.2.1.6.1.6' }, + eqlMemberHealthDetailsTemperatureLowCriticalThreshold => { oid => '.1.3.6.1.4.1.12740.2.1.6.1.7' }, + eqlMemberHealthDetailsTemperatureLowWarningThreshold => { oid => '.1.3.6.1.4.1.12740.2.1.6.1.8' }, +}; +my $oid_eqlMemberHealthDetailsTemperatureEntry = '.1.3.6.1.4.1.12740.2.1.6.1'; + +sub load { + my (%options) = @_; + + push @{$options{request}}, { oid => $oid_eqlMemberHealthDetailsTemperatureEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlMemberHealthDetailsTemperatureEntry}})) { + next if ($oid !~ /^$mapping->{eqlMemberHealthDetailsTemperatureCurrentState}->{oid}\.(\d+\.\d+)\.(.*)$/); + my ($member_instance, $instance) = ($1, $2); + my $member_name = $self->get_member_name(instance => $member_instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberHealthDetailsTemperatureEntry}, instance => $member_instance . '.' . $instance); + + next if ($self->check_exclude(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("Temperature '%s/%s' status is %s [instance: %s].", + $member_name, $result->{eqlMemberHealthDetailsTemperatureName}, $result->{eqlMemberHealthDetailsTemperatureCurrentState}, + $instance + )); + my $exit = $self->get_severity(section => 'temperature', value => $result->{eqlMemberHealthDetailsTemperatureCurrentState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s/%s' status is %s", + $member_name, $result->{eqlMemberHealthDetailsTemperatureName}, $result->{eqlMemberHealthDetailsTemperatureCurrentState})); + } + + if (defined($result->{eqlMemberHealthDetailsTemperatureValue})) { + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{eqlMemberHealthDetailsTemperatureValue}); + if ($checked == 0) { + my $warn_th = $result->{eqlMemberHealthDetailsTemperatureLowWarningThreshold} . ':' . $result->{eqlMemberHealthDetailsTemperatureHighWarningThreshold}; + my $crit_th = $result->{eqlMemberHealthDetailsTemperatureLowCriticalThreshold} . ':' . $result->{eqlMemberHealthDetailsTemperatureHighCriticalThreshold}; + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); + } + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit2, + short_msg => sprintf("Temperature '%s/%s' is %s degree centigrade", $member_name, $result->{eqlMemberHealthDetailsTemperatureName}, $result->{eqlMemberHealthDetailsTemperatureValue})); + } + $self->{output}->perfdata_add(label => "temp_" . $member_name . "_" . $instance, unit => 'C', + value => $result->{eqlMemberHealthDetailsTemperatureValue}, + warning => $warn, + critical => $crit); + } + } +} + +1; \ No newline at end of file diff --git a/storage/dell/equallogic/snmp/mode/diskusage.pm b/storage/dell/equallogic/snmp/mode/diskusage.pm new file mode 100644 index 000000000..51abbd251 --- /dev/null +++ b/storage/dell/equallogic/snmp/mode/diskusage.pm @@ -0,0 +1,292 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::snmp::mode::diskusage; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; + +my $maps_counters = { + '000_used' => { 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, + } + }, + '001_snapshot' => { set => { + key_values => [ { name => 'snap' }, { name => 'display' } ], + output_change_bytes => 1, + output_template => 'Snapshot usage : %s %s', + perfdatas => [ + { label => 'snapshost', value => 'snap_absolute', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + '002_replication' => { set => { + key_values => [ { name => 'repl' }, { name => 'display' } ], + output_change_bytes => 1, + output_template => 'Replication usage : %s %s', + perfdatas => [ + { label => 'replication', value => 'repl_absolute', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, +}; + +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 (keys %{$maps_counters}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$_}->{threshold}) || $maps_counters->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + $maps_counters->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}}); + } + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach (keys %{$maps_counters}) { + $maps_counters->{$_}->{obj}->init(option_results => $self->{option_results}); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->manage_selection(); + + my $multiple = 1; + if (scalar(keys %{$self->{member_selected}}) == 1) { + $multiple = 0; + } + + if ($multiple == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'All disk usages are ok'); + } + + foreach my $id (sort keys %{$self->{member_selected}}) { + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits; + foreach (sort keys %{$maps_counters}) { + $maps_counters->{$_}->{obj}->set(instance => $id); + + my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{member_selected}->{$id}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $maps_counters->{$_}->{obj}->threshold_check(); + push @exits, $exit2; + + my $output = $maps_counters->{$_}->{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 = ', '; + } + + $maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple); + } + + $self->{output}->output_add(long_msg => "Disk '" . $self->{member_selected}->{$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 => "Disk '" . $self->{member_selected}->{$id}->{display} . "' $short_msg" + ); + } + + if ($multiple == 0) { + $self->{output}->output_add(short_msg => "Disk '" . $self->{member_selected}->{$id}->{display} . "' $long_msg"); + } + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +my $mapping = { + eqlMemberTotalStorage => { oid => '.1.3.6.1.4.1.12740.2.1.10.1.1' }, # MB + eqlMemberUsedStorage => { oid => '.1.3.6.1.4.1.12740.2.1.10.1.2' }, # MB + eqlMemberSnapStorage => { oid => '.1.3.6.1.4.1.12740.2.1.10.1.3' }, # MB + eqlMemberReplStorage => { oid => '.1.3.6.1.4.1.12740.2.1.10.1.4' }, # MB +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_eqlMemberName = '.1.3.6.1.4.1.12740.2.1.1.1.9'; + my $oid_eqlMemberStorageEntry = '.1.3.6.1.4.1.12740.2.1.10.1'; + + $self->{member_selected} = {}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ + { oid => $oid_eqlMemberName }, + { oid => $oid_eqlMemberStorageEntry }, + ], + nothing_quit => 1); + foreach my $oid (keys %{$self->{results}->{$oid_eqlMemberStorageEntry}}) { + next if ($oid !~ /^$mapping->{eqlMemberTotalStorage}->{oid}\.(\d+\.\d+)/); + my $member_instance = $1; + next if (!defined($self->{results}->{$oid_eqlMemberName}->{$oid_eqlMemberName . '.' . $member_instance})); + my $member_name = $self->{results}->{$oid_eqlMemberName}->{$oid_eqlMemberName . '.' . $member_instance}; + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberStorageEntry}, instance => $member_instance); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $member_name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $member_name . "': no matching filter."); + next; + } + + $self->{member_selected}->{$member_name} = { display => $member_name, + total => $result->{eqlMemberTotalStorage} * 1024 * 1024, + used => $result->{eqlMemberUsedStorage} * 1024 * 1024, + snap => $result->{eqlMemberSnapStorage} * 1024 * 1024, + repl => $result->{eqlMemberReplStorage} * 1024 * 1024 + }; + } + + if (scalar(keys %{$self->{member_selected}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No entry found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check disk usages. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'used' (%), 'snapshot' (B), 'replication' (B). + +=item B<--critical-*> + +Threshold critical. +Can be: 'used' (%), 'snapshot' (B), 'replication' (B). + +=item B<--filter-name> + +Filter disk name (can be a regexp). + +=back + +=cut diff --git a/storage/dell/equallogic/snmp/mode/hardware.pm b/storage/dell/equallogic/snmp/mode/hardware.pm new file mode 100644 index 000000000..b5d86a84a --- /dev/null +++ b/storage/dell/equallogic/snmp/mode/hardware.pm @@ -0,0 +1,341 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::snmp::mode::hardware; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $thresholds = { + fan => [ + ['unknown', 'UNKNOWN'], + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ], + temperature => [ + ['unknown', 'UNKNOWN'], + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ], + health => [ + ['unknown', 'UNKNOWN'], + ['normal', 'OK'], + ['warning', 'WARNING'], + ['critical', 'CRITICAL'], + ], + psu => [ + ['on-and-operating', 'OK'], + ['no-ac-power', 'CRITICAL'], + ['failed-or-no-data', 'CRITICAL'], + ], + 'psu.fan' => [ + ['not-applicable', 'OK'], + ['fan-is-operational', 'OK'], + ['fan-not-operational', 'CRITICAL'], + ], + raid => [ + ['ok', 'OK'], + ['degraded', 'WARNING'], + ['verifying', 'OK'], + ['reconstructing', 'WARNING'], + ['failed', 'CRITICAL'], + ['catastrophicLoss', 'CRITICAL'], + ['expanding', 'OK'], + ['mirroring', 'OK'], + ], + disk => [ + ['on-line', 'OK'], + ['spare', 'OK'], + ['failed', 'CRITICAL'], + ['off-line', 'WARNING'], + ['alt-sig', 'WARNING'], + ['too-small', 'WARNING'], + ['history-of-failures', 'WARNING'], + ['unsupported-version', 'CRITICAL'], + ['unhealthy', 'CRITICAL'], + ['replacement', 'CRITICAL'], + ], +}; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "exclude:s" => { name => 'exclude' }, + "component:s" => { name => 'component', default => '.*' }, + "no-component:s" => { name => 'no_component' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + "warning:s@" => { name => 'warning' }, + "critical:s@" => { name => 'critical' }, + }); + + $self->{components} = {}; + $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->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + if ($val !~ /^(.*?),(.*?),(.*)$/) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $status, $filter) = ($1, $2, $3); + if ($self->{output}->is_litteral_status(status => $status) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); + $self->{output}->option_exit(); + } + $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); + push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; + } + + $self->{numeric_threshold} = {}; + foreach my $option (('warning', 'critical')) { + foreach my $val (@{$self->{option_results}->{$option}}) { + if ($val !~ /^(.*?),(.*?),(.*)$/) { + $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $regexp, $value) = ($1, $2, $3); + if ($section !~ /(temperature|fan)/) { + $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature or fan)."); + $self->{output}->option_exit(); + } + my $position = 0; + if (defined($self->{numeric_threshold}->{$section})) { + $position = scalar(@{$self->{numeric_threshold}->{$section}}); + } + if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); + $self->{output}->option_exit(); + } + $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); + push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; + } + } +} + +my $oid_eqlMemberName = '.1.3.6.1.4.1.12740.2.1.1.1.9'; + +sub get_member_name { + my ($self, %options) = @_; + + my $name = defined($self->{results}->{$oid_eqlMemberName}->{$oid_eqlMemberName . '.' . $options{instance}}) ? + $self->{results}->{$oid_eqlMemberName}->{$oid_eqlMemberName . '.' . $options{instance}} : 'unknown'; + return $name; +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $snmp_request = [ { oid => $oid_eqlMemberName } ]; + my @components = ('fan', 'psu', 'temperature', 'raid', 'disk', 'health'); + foreach (@components) { + if (/$self->{option_results}->{component}/) { + my $mod_name = "storage::dell::equallogic::snmp::mode::components::$_"; + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name, + error_msg => "Cannot load module '$mod_name'."); + my $func = $mod_name->can('load'); + $func->(request => $snmp_request); + } + } + + if (scalar(@{$snmp_request}) == 1) { + $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); + $self->{output}->option_exit(); + } + $self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request); + + foreach (@components) { + if (/$self->{option_results}->{component}/) { + my $mod_name = "storage::dell::equallogic::snmp::mode::components::$_"; + my $func = $mod_name->can('check'); + $func->($self); + } + } + + my $total_components = 0; + my $display_by_component = ''; + my $display_by_component_append = ''; + foreach my $comp (sort(keys %{$self->{components}})) { + # Skipping short msg when no components + next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); + $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; + my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; + $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name}; + $display_by_component_append = ', '; + } + + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("All %s components are ok [%s].", + $total_components, + $display_by_component) + ); + + if (defined($self->{option_results}->{no_component}) && $total_components == 0) { + $self->{output}->output_add(severity => $self->{no_components}, + short_msg => 'No components are checked.'); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub check_exclude { + my ($self, %options) = @_; + + if (defined($options{instance})) { + if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { + $self->{components}->{$options{section}}->{skip}++; + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); + return 1; + } + } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + return 1; + } + return 0; +} + +sub get_severity_numeric { + my ($self, %options) = @_; + my $status = 'OK'; # default + my $thresholds = { warning => undef, critical => undef }; + my $checked = 0; + + if (defined($self->{numeric_threshold}->{$options{section}})) { + my $exits = []; + foreach (@{$self->{numeric_threshold}->{$options{section}}}) { + if ($options{instance} =~ /$_->{regexp}/) { + push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]); + $thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label}); + $checked = 1; + } + } + $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); + } + + return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked); +} + +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + if (defined($self->{overload_th}->{$options{section}})) { + foreach (@{$self->{overload_th}->{$options{section}}}) { + if ($options{value} =~ /$_->{filter}/i) { + $status = $_->{status}; + return $status; + } + } + } + foreach (@{$thresholds->{$options{section}}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + +1; + +__END__ + +=head1 MODE + +Check Hardware (Power Supplies, Fans, Temperatures, Raids, Disks, Health). + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'fan', 'psu', 'temperature', 'raid', 'disk', 'health'. + +=item B<--exclude> + +Exclude some parts (comma seperated list) (Example: --exclude=fan) +Can also exclude specific instance: --exclude=fan#1#,psu#3# + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='fan,CRITICAL,^(?!(normal)$)' + +=item B<--warning> + +Set warning threshold for temperatures (syntax: type,regexp,treshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold for temperatures (syntax: type,regexp,treshold) +Example: --critical='temperature,.*,40' + +=back + +=cut \ No newline at end of file diff --git a/storage/dell/equallogic/snmp/mode/poolusage.pm b/storage/dell/equallogic/snmp/mode/poolusage.pm new file mode 100644 index 000000000..a24736c0a --- /dev/null +++ b/storage/dell/equallogic/snmp/mode/poolusage.pm @@ -0,0 +1,278 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::snmp::mode::poolusage; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; + +my $maps_counters = { + '000_used' => { 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 (keys %{$maps_counters}) { + my ($id, $name) = split /_/; + if (!defined($maps_counters->{$_}->{threshold}) || $maps_counters->{$_}->{threshold} != 0) { + $options{options}->add_options(arguments => { + 'warning-' . $name . ':s' => { name => 'warning-' . $name }, + 'critical-' . $name . ':s' => { name => 'critical-' . $name }, + }); + } + $maps_counters->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata}, + label => $name); + $maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}}); + } + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach (keys %{$maps_counters}) { + $maps_counters->{$_}->{obj}->init(option_results => $self->{option_results}); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->manage_selection(); + + my $multiple = 1; + if (scalar(keys %{$self->{pool_selected}}) == 1) { + $multiple = 0; + } + + if ($multiple == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'All Pool usages are ok'); + } + + foreach my $id (sort keys %{$self->{pool_selected}}) { + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits; + foreach (sort keys %{$maps_counters}) { + $maps_counters->{$_}->{obj}->set(instance => $id); + + my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{pool_selected}->{$id}); + + if ($value_check != 0) { + $long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $maps_counters->{$_}->{obj}->threshold_check(); + push @exits, $exit2; + + my $output = $maps_counters->{$_}->{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 = ', '; + } + + $maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple); + } + + $self->{output}->output_add(long_msg => "Pool '" . $self->{pool_selected}->{$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 => "Pool '" . $self->{pool_selected}->{$id}->{display} . "' $short_msg" + ); + } + + if ($multiple == 0) { + $self->{output}->output_add(short_msg => "Pool '" . $self->{pool_selected}->{$id}->{display} . "' $long_msg"); + } + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +my $mapping = { + eqlStoragePoolStatsSpace => { oid => '.1.3.6.1.4.1.12740.16.1.2.1.1' }, # MB + eqlStoragePoolStatsSpaceUsed => { oid => '.1.3.6.1.4.1.12740.16.1.2.1.2' }, # MB +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_eqlStoragePoolName = '.1.3.6.1.4.1.12740.16.1.1.1.3'; + my $oid_eqlStoragePoolStatsEntry = '.1.3.6.1.4.1.12740.16.1.2.1'; + + if ($self->{snmp}->is_snmpv1()) { + $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); + $self->{output}->option_exit(); + } + + $self->{pool_selected} = {}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ + { oid => $oid_eqlStoragePoolName }, + { oid => $oid_eqlStoragePoolStatsEntry, start => $mapping->{eqlStoragePoolStatsSpace}->{oid}, end => $mapping->{eqlStoragePoolStatsSpaceUsed}->{oid}}, + ], + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}->{$oid_eqlStoragePoolStatsEntry}}) { + next if ($oid !~ /^$mapping->{eqlStoragePoolStatsSpace}->{oid}\.(\d+\.\d+)/); + my $pool_instance = $1; + next if (!defined($self->{results}->{$oid_eqlStoragePoolName}->{$oid_eqlStoragePoolName . '.' . $pool_instance})); + my $pool_name = $self->{results}->{$oid_eqlStoragePoolName}->{$oid_eqlStoragePoolName . '.' . $pool_instance}; + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlStoragePoolStatsEntry}, instance => $pool_instance); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $pool_name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $pool_name . "': no matching filter."); + next; + } + if ($result->{eqlStoragePoolStatsSpace} == 0) { + $self->{output}->output_add(long_msg => "Skipping '" . $pool_name . "': total size is 0."); + next; + } + + $self->{pool_selected}->{$pool_name} = { display => $pool_name, + total => $result->{eqlStoragePoolStatsSpace} * 1024 * 1024, + used => $result->{eqlStoragePoolStatsSpaceUsed} * 1024 * 1024, + }; + } + + if (scalar(keys %{$self->{pool_selected}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No entry found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check pool usages. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'used' (%). + +=item B<--critical-*> + +Threshold critical. +Can be: 'used' (%). + +=item B<--filter-name> + +Filter disk name (can be a regexp). + +=back + +=cut diff --git a/storage/dell/equallogic/snmp/plugin.pm b/storage/dell/equallogic/snmp/plugin.pm new file mode 100644 index 000000000..3b4248570 --- /dev/null +++ b/storage/dell/equallogic/snmp/plugin.pm @@ -0,0 +1,69 @@ +################################################################################ +# 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 . +# +# 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 +# +#################################################################################### + +package storage::dell::equallogic::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}} = ( + 'array-stats' => 'storage::dell::equallogic::snmp::mode::arraystats', + 'disk-usage' => 'storage::dell::equallogic::snmp::mode::diskusage', + 'hardware' => 'storage::dell::equallogic::snmp::mode::hardware', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'pool-usage' => 'storage::dell::equallogic::snmp::mode::poolusage', + 'traffic' => 'snmp_standard::mode::traffic', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Dell EqualLogic in SNMP. + +=cut