From 66655a4c0b1e5f83188f074e1b477976c97dd2fa Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Tue, 9 Dec 2014 19:18:58 +0100 Subject: [PATCH] Refs #5353 Worked on datadomain plugin --- .../snmp/mode/components/temperature.pm | 2 +- .../storage/emc/DataDomain/lib/functions.pm | 46 +++ .../emc/DataDomain/mode/components/battery.pm | 101 +++++ .../emc/DataDomain/mode/components/disk.pm | 86 ++++ .../emc/DataDomain/mode/components/fan.pm | 66 ++-- .../emc/DataDomain/mode/components/psu.pm | 56 +-- .../DataDomain/mode/components/temperature.pm | 81 ++-- .../emc/DataDomain/mode/environment.pm | 147 ------- .../storage/emc/DataDomain/mode/filesystem.pm | 320 +++++++++++++++ .../storage/emc/DataDomain/mode/hardware.pm | 367 ++++++++++++++++++ .../emc/DataDomain/mode/nvrambattery.pm | 153 -------- .../storage/emc/DataDomain/plugin.pm | 4 +- .../storage/violin/3000/snmp/plugin.pm | 1 + 13 files changed, 1045 insertions(+), 385 deletions(-) create mode 100644 centreon-plugins/storage/emc/DataDomain/lib/functions.pm create mode 100644 centreon-plugins/storage/emc/DataDomain/mode/components/battery.pm create mode 100644 centreon-plugins/storage/emc/DataDomain/mode/components/disk.pm delete mode 100644 centreon-plugins/storage/emc/DataDomain/mode/environment.pm create mode 100644 centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm create mode 100644 centreon-plugins/storage/emc/DataDomain/mode/hardware.pm delete mode 100644 centreon-plugins/storage/emc/DataDomain/mode/nvrambattery.pm diff --git a/centreon-plugins/centreon/common/violin/snmp/mode/components/temperature.pm b/centreon-plugins/centreon/common/violin/snmp/mode/components/temperature.pm index 00ec7232b..a4d6dcef1 100644 --- a/centreon-plugins/centreon/common/violin/snmp/mode/components/temperature.pm +++ b/centreon-plugins/centreon/common/violin/snmp/mode/components/temperature.pm @@ -66,7 +66,7 @@ sub temperature { critical => $crit); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Power Supply '%s' is %s", $instance, $temperature)); + short_msg => sprintf("Temperature '%s' is %s degree centigrade", $instance, $temperature)); } } diff --git a/centreon-plugins/storage/emc/DataDomain/lib/functions.pm b/centreon-plugins/storage/emc/DataDomain/lib/functions.pm new file mode 100644 index 000000000..fd0f7213f --- /dev/null +++ b/centreon-plugins/storage/emc/DataDomain/lib/functions.pm @@ -0,0 +1,46 @@ +################################################################################ +# 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::emc::DataDomain::lib::functions; + +sub get_version { + my (%options) = @_; + + return $1 if (defined($options{value}) && $options{value} =~ /(\d+\.\d+\.\d+)/); + return undef; +} + +1; + \ No newline at end of file diff --git a/centreon-plugins/storage/emc/DataDomain/mode/components/battery.pm b/centreon-plugins/storage/emc/DataDomain/mode/components/battery.pm new file mode 100644 index 000000000..b552531af --- /dev/null +++ b/centreon-plugins/storage/emc/DataDomain/mode/components/battery.pm @@ -0,0 +1,101 @@ +################################################################################ +# 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::emc::DataDomain::mode::components::battery; + +use strict; +use warnings; +use centreon::plugins::misc; + +my %map_battery_status = (); +my ($oid_nvramBatteryStatus, $oid_nvramBatteryCharge); +my $oid_nvramBatteryEntry = '.1.3.6.1.4.1.19746.1.2.3.1.1'; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking nvram batteries"); + $self->{components}->{battery} = {name => 'nvram batteries', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'battery')); + + if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { + $oid_nvramBatteryStatus = '.1.3.6.1.4.1.19746.1.2.3.1.1.3'; + $oid_nvramBatteryCharge = '.1.3.6.1.4.1.19746.1.2.3.1.1.4'; + %map_battery_status = (0 => 'ok', 1 => 'disabled', 2 => 'discharged', 4 => 'softdisabled'); + } else { + $oid_nvramBatteryStatus = '.1.3.6.1.4.1.19746.1.2.3.1.1.2'; + $oid_nvramBatteryCharge = '.1.3.6.1.4.1.19746.1.2.3.1.1.3'; + %map_battery_status = (1 => 'ok', 2 => 'disabled', 3 => 'discharged', 4 => 'unknown', + 5 => 'softdisabled'); + } + + foreach my $oid (keys %{$self->{results}->{$oid_nvramBatteryEntry}}) { + next if ($oid !~ /^$oid_nvramBatteryStatus\.(.*)$/); + my $instance = $1; + my $batt_status = defined($map_battery_status{$self->{results}->{$oid_nvramBatteryEntry}->{$oid}}) ? + $map_battery_status{$self->{results}->{$oid_nvramBatteryEntry}->{$oid}} : 'unknown'; + my $batt_value = $self->{results}->{$oid_nvramBatteryEntry}->{$oid_nvramBatteryCharge . '.' . $instance}; + + next if ($self->check_exclude(section => 'battery', instance => $instance)); + next if ($batt_status =~ /disabled/i && + $self->absent_problem(section => 'battery', instance => $instance)); + + $self->{components}->{battery}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Nvram battery '%s' status is '%s'", + $instance, $batt_status)); + my $exit = $self->get_severity(section => 'battery', value => $batt_status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Nvram battery '%s' status is '%s'", $instance, $batt_status)); + } + + if (defined($batt_value) && $batt_value =~ /[0-9]/) { + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'battery', instance => $instance, value => $batt_value); + $self->{output}->output_add(long_msg => sprintf("Nvram battery '%s' charge is %s %%", $instance, $batt_value)); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Nvram battery '%s' charge is %s %%", $instance, $batt_value)); + } + $self->{output}->perfdata_add(label => 'nvram_battery_' . $instance, unit => '%', + value => $batt_value, + warning => $warn, + critical => $crit, + min => 0, max => 100 + ); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/emc/DataDomain/mode/components/disk.pm b/centreon-plugins/storage/emc/DataDomain/mode/components/disk.pm new file mode 100644 index 000000000..ff45efbbf --- /dev/null +++ b/centreon-plugins/storage/emc/DataDomain/mode/components/disk.pm @@ -0,0 +1,86 @@ +################################################################################ +# 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::emc::DataDomain::mode::components::disk; + +use strict; +use warnings; +use centreon::plugins::misc; + +my $oid_diskPropState; + +my %map_disk_status = ( + 1 => 'ok', + 2 => 'unknown', + 3 => 'absent', + 4 => 'failed', +); + +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')); + + my $oid_diskPropState; + if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { + $oid_diskPropState = '.1.3.6.1.4.1.19746.1.6.1.1.1.8'; + } else { + $oid_diskPropState = '.1.3.6.1.4.1.19746.1.6.1.1.1.7'; + } + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_diskPropState}})) { + $oid =~ /^$oid_diskPropState\.(.*)$/; + my $instance = $1; + my $disk_status = defined($map_disk_status{$self->{results}->{$oid_diskPropState}->{$oid}}) ? + $map_disk_status{$self->{results}->{$oid_diskPropState}->{$oid}} : 'unknown'; + + next if ($self->check_exclude(section => 'disk', instance => $instance)); + next if ($disk_status =~ /absent/i && + $self->absent_problem(section => 'disk', instance => $instance)); + + $self->{components}->{disk}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Disk '%s' status is '%s'", + $instance, $disk_status)); + my $exit = $self->get_severity(section => 'fan', value => $disk_status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Disk '%s' status is '%s'", $instance, $disk_status)); + } + } +} + +1; \ No newline at end of file diff --git a/centreon-plugins/storage/emc/DataDomain/mode/components/fan.pm b/centreon-plugins/storage/emc/DataDomain/mode/components/fan.pm index 902292b41..d2d6b0600 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/components/fan.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/components/fan.pm @@ -39,47 +39,57 @@ use strict; use warnings; use centreon::plugins::misc; -my %conditions = ( - 0 => ['not found', 'UNKNOWN'], - 1 => ['ok', 'OK'], - 2 => ['failed', 'CRITICAL'], +my %map_fan_status = ( + 0 => 'notfound', + 1 => 'ok', + 2 => 'failed', ); -my %level_map = ( +my %level_map = ( 0 => 'unknown', 1 => 'low', 2 => 'normal', 3 => 'high', -); +); + +my ($oid_fanDescription, $oid_fanLevel, $oid_fanStatus); +my $oid_fanPropertiesEntry = '.1.3.6.1.4.1.19746.1.1.3.1.1.1'; sub check { my ($self) = @_; - $self->{components}->{fans} = {name => 'fans', total => 0}; $self->{output}->output_add(long_msg => "Checking fans"); - return if ($self->check_exclude('fans')); + $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'fan')); - my $oid_fanPropertiesEntry = '.1.3.6.1.4.1.19746.1.1.3.1.1.1'; - my $oid_fanDescription = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.3'; - my $oid_fanLevel = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.4'; - my $oid_fanStatus = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.5'; - - my $result = $self->{snmp}->get_table(oid => $oid_fanPropertiesEntry); - return if (scalar(keys %$result) <= 0); + if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { + $oid_fanDescription = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.4'; + $oid_fanLevel = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.5'; + $oid_fanStatus = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.6'; + } else { + $oid_fanDescription = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.3'; + $oid_fanLevel = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.4'; + $oid_fanStatus = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.5'; + } - foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { - next if ($key !~ /^$oid_fanStatus\.(\d+)\.(\d+)$/); - my ($enclosure_id, $fan_index) = ($1, $2); - - my $fan_descr = centreon::plugins::misc::trim($result->{$oid_fanDescription . '.' . $enclosure_id . '.' . $fan_index}); - my $fan_level = $result->{$oid_fanLevel . '.' . $enclosure_id . '.' . $fan_index}; - my $fan_status = $result->{$oid_fanStatus . '.' . $enclosure_id . '.' . $fan_index}; + foreach my $oid (keys %{$self->{results}->{$oid_fanPropertiesEntry}}) { + next if ($oid !~ /^$oid_fanStatus\.(.*)$/); + my $instance = $1; + my $fan_descr = centreon::plugins::misc::trim($self->{results}->{$oid_fanPropertiesEntry}->{$oid_fanDescription . '.' . $instance}); + my $fan_status = defined($map_fan_status{$self->{results}->{$oid_fanPropertiesEntry}->{$oid}}) ? + $map_fan_status{$self->{results}->{$oid_fanPropertiesEntry}->{$oid}} : 'unknown'; + my $fan_level = $self->{results}->{$oid_fanPropertiesEntry}->{$oid_fanLevel . '.' . $instance}; - $self->{components}->{fans}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is %s [enclosure = %d, index = %d, level = %s].", - $fan_descr, ${$conditions{$fan_status}}[0], $enclosure_id, $fan_index, $level_map{$fan_level})); - if (!$self->{output}->is_status(litteral => 1, value => ${$conditions{$fan_status}}[1], compare => 'ok')) { - $self->{output}->output_add(severity => ${$conditions{$fan_status}}[1], - short_msg => sprintf("Fan '%s' status is %s", $fan_descr, ${$conditions{$fan_status}}[0])); + next if ($self->check_exclude(section => 'fan', instance => $instance)); + next if ($fan_status =~ /notfound/i && + $self->absent_problem(section => 'fan', instance => $instance)); + + $self->{components}->{fan}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s, level = %s]", + $fan_descr, $fan_status, $instance, $level_map{$fan_level})); + my $exit = $self->get_severity(section => 'fan', value => $fan_status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fan '%s' status is '%s'", $fan_descr, $fan_status)); } } } diff --git a/centreon-plugins/storage/emc/DataDomain/mode/components/psu.pm b/centreon-plugins/storage/emc/DataDomain/mode/components/psu.pm index a7aa34828..5b54778d8 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/components/psu.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/components/psu.pm @@ -38,37 +38,47 @@ package storage::emc::DataDomain::mode::components::psu; use strict; use warnings; -my %conditions = ( - 1 => ['ok', 'OK'], - 2 => ['unknown', 'UNKNOWN'], - 3 => ['fail', 'CRITICAL'], -); +my %map_psu_status = (); +my ($oid_powerModuleDescription, $oid_powerModuleStatus); +my $oid_powerModuleEntry = '.1.3.6.1.4.1.19746.1.1.1.1.1.1'; sub check { my ($self) = @_; - $self->{components}->{psus} = {name => 'power supplies', total => 0}; $self->{output}->output_add(long_msg => "Checking power supplies"); - return if ($self->check_exclude('psu')); + $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'psu')); - my $oid_powerModuleEntry = '.1.3.6.1.4.1.19746.1.1.1.1.1.1'; - my $oid_powerModuleStatus = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.3'; - - my $result = $self->{snmp}->get_table(oid => $oid_powerModuleEntry); - return if (scalar(keys %$result) <= 0); + if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { + $oid_powerModuleDescription = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.3'; + $oid_powerModuleStatus = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.4'; + %map_psu_status = (0 => 'absent', 1 => 'ok', 2 => 'failed', 3 => 'faulty', 4 => 'acnone', + 99 => 'unknown'); + } else { + $oid_powerModuleDescription = ''; # none + $oid_powerModuleStatus = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.4'; + %map_psu_status = (1 => 'ok', 2 => 'unknown', 3 => 'failed'); + } - foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { - next if ($key !~ /^$oid_powerModuleStatus\.(\d+)\.(\d+)$/); - my ($enclosure_id, $module_index) = ($1, $2); - - my $psu_status = $result->{$oid_powerModuleStatus . '.' . $enclosure_id . '.' . $module_index}; + foreach my $oid (keys %{$self->{results}->{$oid_powerModuleEntry}}) { + next if ($oid !~ /^$oid_powerModuleStatus\.(.*)$/); + my $instance = $1; + my $psu_descr = defined($self->{results}->{$oid_powerModuleEntry}->{$oid_powerModuleDescription . '.' . $instance}) ? + centreon::plugins::misc::trim($self->{results}->{$oid_powerModuleEntry}->{$oid_powerModuleDescription . '.' . $instance}) : 'unknown'; + my $psu_status = defined($map_psu_status{$self->{results}->{$oid_powerModuleEntry}->{$oid}}) ? + $map_psu_status{$self->{results}->{$oid_powerModuleEntry}->{$oid}} : 'unknown'; - $self->{components}->{psus}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Power Supply '%s' status is %s.", - $enclosure_id . '/' . $module_index, ${$conditions{$psu_status}}[0])); - if (!$self->{output}->is_status(litteral => 1, value => ${$conditions{$psu_status}}[1], compare => 'ok')) { - $self->{output}->output_add(severity => ${$conditions{$psu_status}}[1], - short_msg => sprintf("Power Supply '%s' status is %s", $enclosure_id . '/' . $module_index, ${$conditions{$psu_status}}[0])); + next if ($self->check_exclude(section => 'psu', instance => $instance)); + next if ($psu_status =~ /absent/i && + $self->absent_problem(section => 'psu', instance => $instance)); + + $self->{components}->{psu}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Power Supply '%s' status is '%s' [description = %s]", + $instance, $psu_status, $instance)); + my $exit = $self->get_severity(section => 'psu', value => $psu_status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power Supply '%s' status is '%s'", $instance, $psu_status)); } } } diff --git a/centreon-plugins/storage/emc/DataDomain/mode/components/temperature.pm b/centreon-plugins/storage/emc/DataDomain/mode/components/temperature.pm index aea8dacd6..698844e39 100644 --- a/centreon-plugins/storage/emc/DataDomain/mode/components/temperature.pm +++ b/centreon-plugins/storage/emc/DataDomain/mode/components/temperature.pm @@ -39,46 +39,65 @@ use strict; use warnings; use centreon::plugins::misc; -my %conditions = ( - 0 => ['absent', 'CRITICAL'], - 1 => ['ok', 'OK'], - 2 => ['not found', 'UNKNOWN'], -); +my %map_temp_status = (); +my ($oid_tempSensorDescription, $oid_tempSensorCurrentValue, $oid_tempSensorStatus); +my $oid_temperatureSensorEntry = '.1.3.6.1.4.1.19746.1.1.2.1.1.1'; sub check { my ($self) = @_; - $self->{components}->{temperatures} = {name => 'temperatures', total => 0}; $self->{output}->output_add(long_msg => "Checking temperatures"); - return if ($self->check_exclude('temperatures')); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'temperature')); - my $oid_temperatureSensorEntry = '.1.3.6.1.4.1.19746.1.1.2.1.1.1'; - my $oid_tempSensorDescription = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.3'; - my $oid_tempSensorCurrentValue = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.4'; - my $oid_tempSensorStatus = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.5'; - - my $result = $self->{snmp}->get_table(oid => $oid_temperatureSensorEntry); - return if (scalar(keys %$result) <= 0); + if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { + $oid_tempSensorDescription = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.4'; + $oid_tempSensorCurrentValue = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.5'; + $oid_tempSensorStatus = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.6'; + %map_temp_status = (0 => 'failed', 1 => 'ok', 2 => 'notfound', 3 => 'overheatWarning', + 4 => 'overheatCritical'); + } else { + $oid_tempSensorDescription = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.3'; + $oid_tempSensorCurrentValue = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.4'; + $oid_tempSensorStatus = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.5'; + %map_temp_status = (0 => 'absent', 1 => 'ok', 2 => 'notfound'); + } - foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { - next if ($key !~ /^$oid_tempSensorCurrentValue\.(\d+)\.(\d+)$/); - my ($enclosure_id, $sensor_index) = ($1, $2); - - my $temp_descr = centreon::plugins::misc::trim($result->{$oid_tempSensorDescription . '.' . $enclosure_id . '.' . $sensor_index}); - my $temp_value = $result->{$oid_tempSensorCurrentValue . '.' . $enclosure_id . '.' . $sensor_index}; - my $temp_status = $result->{$oid_tempSensorStatus . '.' . $enclosure_id . '.' . $sensor_index}; + foreach my $oid (keys %{$self->{results}->{$oid_temperatureSensorEntry}}) { + next if ($oid !~ /^$oid_tempSensorStatus\.(.*)$/); + my $instance = $1; + my $temp_descr = defined($self->{results}->{$oid_temperatureSensorEntry}->{$oid_tempSensorDescription . '.' . $instance}) ? + centreon::plugins::misc::trim($self->{results}->{$oid_temperatureSensorEntry}->{$oid_tempSensorDescription . '.' . $instance}) : 'unknown'; + my $temp_status = defined($map_temp_status{$self->{results}->{$oid_temperatureSensorEntry}->{$oid}}) ? + $map_temp_status{$self->{results}->{$oid_temperatureSensorEntry}->{$oid}} : 'unknown'; + my $temp_value = $self->{results}->{$oid_temperatureSensorEntry}->{$oid_tempSensorCurrentValue . '.' . $instance}; - $self->{components}->{temperatures}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is %s [enclosure = %d, sensor = %d, current_value = %s].", - $temp_descr, ${$conditions{$temp_status}}[0], $enclosure_id, $sensor_index, $temp_value)); - if (!$self->{output}->is_status(litteral => 1, value => ${$conditions{$temp_status}}[1], compare => 'ok')) { - $self->{output}->output_add(severity => ${$conditions{$temp_status}}[1], - short_msg => sprintf("Temperature '%s' status is %s", $temp_descr, ${$conditions{$temp_status}}[0])); - } + next if ($self->check_exclude(section => 'temperature', instance => $instance)); + next if ($temp_status =~ /absent|notfound/i && + $self->absent_problem(section => 'temperature', instance => $instance)); - $self->{output}->perfdata_add(label => 'temp_' . $enclosure_id . '_' . $sensor_index, unit => 'C', - value => $temp_value, - ); + $self->{components}->{temperature}->{total}++; + $self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is '%s' [instance = %s]", + $temp_descr, $temp_status, $instance)); + my $exit = $self->get_severity(section => 'temperature', value => $temp_status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' status is '%s'", $temp_descr, $temp_status)); + } + + if (defined($temp_value) && $temp_value =~ /[0-9]/) { + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temp_value); + $self->{output}->output_add(long_msg => sprintf("Temperature '%s' is %s degree centigrade", $temp_descr, $temp_value)); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' is %s degree centigrade", $temp_descr, $temp_value)); + } + $self->{output}->perfdata_add(label => 'temp_' . $instance, unit => 'C', + value => $temp_value, + warning => $warn, + critical => $crit, + ); + } } } diff --git a/centreon-plugins/storage/emc/DataDomain/mode/environment.pm b/centreon-plugins/storage/emc/DataDomain/mode/environment.pm deleted file mode 100644 index 7451ed33e..000000000 --- a/centreon-plugins/storage/emc/DataDomain/mode/environment.pm +++ /dev/null @@ -1,147 +0,0 @@ -################################################################################ -# 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::emc::DataDomain::mode::environment; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -use storage::emc::DataDomain::mode::components::psu; -use storage::emc::DataDomain::mode::components::temperature; -use storage::emc::DataDomain::mode::components::fan; - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => 'all' }, - }); - $self->{components} = {}; - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); -} - -sub global { - my ($self, %options) = @_; - - storage::emc::DataDomain::mode::components::psu::check($self); - storage::emc::DataDomain::mode::components::temperature::check($self); - storage::emc::DataDomain::mode::components::fan::check($self); -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - if ($self->{option_results}->{component} eq 'all') { - $self->global(); - } elsif ($self->{option_results}->{component} eq 'psu') { - storage::emc::DataDomain::mode::components::psu::check($self); - } elsif ($self->{option_results}->{component} eq 'temperature') { - storage::emc::DataDomain::mode::components::temperature::check($self); - } elsif ($self->{option_results}->{component} eq 'fan') { - storage::emc::DataDomain::mode::components::fan::check($self); - } else { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - - my $total_components = 0; - my $display_by_component = ''; - my $display_by_component_append = ''; - foreach my $comp (sort(keys %{$self->{components}})) { - # Skipping short msg when no components - next if ($self->{components}->{$comp}->{total} == 0); - $total_components += $self->{components}->{$comp}->{total}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components [%s] are ok.", - $total_components, - $display_by_component - ) - ); - - $self->{output}->display(); - $self->{output}->exit(); -} - -sub check_exclude { - my ($self, $section) = @_; - - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$section(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $section section.")); - return 1; - } - return 0; -} - -1; - -__END__ - -=head1 MODE - -Check environments (Fans, Temperatures, Power Supplies) (DATA-DOMAIN-MIB). - -=over 8 - -=item B<--component> - -Which component to check (Default: 'all'). -Can be: 'fan', 'temperature', 'psu'. - -=item B<--exclude> - -Exclude some parts (comma seperated list) (Example: --exclude=temperatures,fans). - -=back - -=cut - \ No newline at end of file diff --git a/centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm b/centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm new file mode 100644 index 000000000..91a35bbe4 --- /dev/null +++ b/centreon-plugins/storage/emc/DataDomain/mode/filesystem.pm @@ -0,0 +1,320 @@ +################################################################################ +# 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::emc::DataDomain::mode::filesystem; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use storage::emc::DataDomain::lib::functions; +use centreon::plugins::values; + +my $oid_fileSystemSpaceEntry = '.1.3.6.1.4.1.19746.1.3.2.1.1'; +my $oid_sysDescr = '.1.3.6.1.2.1.1.1'; # 'Data Domain OS 5.4.1.1-411752' +my ($oid_fileSystemResourceName, $oid_fileSystemSpaceUsed, $oid_fileSystemSpaceAvail); + +my $maps_counters = { + usage => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'free' }, { name => 'used' }, { name => 'display' }, + ], + closure_custom_calc => \&custom_used_calc, + closure_custom_output => \&custom_used_output, + threshold_use => 'used_prct', + output_error_template => '%s', + perfdatas => [ + { value => 'used', label => 'used', template => '%d', + unit => 'B', min => 0, max => 'total', threshold_total => 'total', + label_extra_instance => 1, instance_use => 'display' }, + ], + } + }, +}; + +sub custom_used_calc { + my ($self, %options) = @_; + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_free'} + $options{new_datas}->{$self->{instance} . '_used'}; + $self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'}; + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; + $self->{result_values}->{free_prct} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{used_prct} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + return 0; +} + +sub custom_used_output { + my ($self, %options) = @_; + + my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); + + return sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_value . " " . $total_unit, + $used_value . " " . $used_unit, $self->{result_values}->{used_prct}, + $free_value . " " . $free_unit, $self->{result_values}->{free_prct}); +} + +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 => + { + "name" => { name => 'use_name' }, + "filesystem:s" => { name => 'filesystem' }, + "regexp" => { name => 'use_regexp' }, + "regexp-isensitive" => { name => 'use_regexpi' }, + }); + + $self->{filesystem_id_selected} = {}; + + foreach (keys %{$maps_counters}) { + $options{options}->add_options(arguments => { + 'warning-' . $_ . ':s' => { name => 'warning-' . $_ }, + 'critical-' . $_ . ':s' => { name => 'critical-' . $_ }, + }); + my $class = $maps_counters->{$_}->{class}; + $maps_counters->{$_}->{obj} = $class->new(statefile => $self->{statefile_value}, + output => $self->{output}, perfdata => $self->{perfdata}, + label => $_); + $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->{filesystem_id_selected}}) == 1) { + $multiple = 0; + } + + if ($multiple == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'All filesystems are ok.'); + } + + foreach my $id (sort keys %{$self->{filesystem_id_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->{filesystem_id_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 => "Filesystem '" . $self->{filesystem_id_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 => "Filesystem '" . $self->{filesystem_id_selected}->{$id}->{display} . "' $short_msg" + ); + } + + if ($multiple == 0) { + $self->{output}->output_add(short_msg => "Filesystem '" . $self->{filesystem_id_selected}->{$id}->{display} . "' $long_msg"); + } + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub add_result { + my ($self, %options) = @_; + + $self->{filesystem_id_selected}->{$options{instance}} = {}; + $self->{filesystem_id_selected}->{$options{instance}}->{display} = $self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemResourceName . '.' . $options{instance}}; + $self->{filesystem_id_selected}->{$options{instance}}->{free} = int($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemSpaceAvail . '.' . $options{instance}} * 1024 * 1024 * 1024); + $self->{filesystem_id_selected}->{$options{instance}}->{used} = int($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemSpaceUsed . '.' . $options{instance}} * 1024 * 1024 * 1024); +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ + { oid => $oid_sysDescr }, + { oid => $oid_fileSystemSpaceEntry }, + ], + , nothing_quit => 1); + if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $self->{results}->{$oid_sysDescr}->{$oid_sysDescr . '.0'}))) { + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => 'Cannot get DataDomain OS version.'); + $self->{output}->display(); + $self->{output}->exit(); + } + if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { + $oid_fileSystemResourceName = '.1.3.6.1.4.1.19746.1.3.2.1.1.3'; + $oid_fileSystemSpaceUsed = '.1.3.6.1.4.1.19746.1.3.2.1.1.5'; + $oid_fileSystemSpaceAvail = '.1.3.6.1.4.1.19746.1.3.2.1.1.6'; + } else { + $oid_fileSystemResourceName = '.1.3.6.1.4.1.19746.1.3.2.1.1.2'; + $oid_fileSystemSpaceUsed = '.1.3.6.1.4.1.19746.1.3.2.1.1.4'; + $oid_fileSystemSpaceAvail = '.1.3.6.1.4.1.19746.1.3.2.1.1.5'; + } + + if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{filesystem})) { + if (!defined($self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemResourceName . '.' . $self->{option_results}->{filesystem}})) { + $self->{output}->add_option_msg(short_msg => "No filesystem found for id '" . $self->{option_results}->{filesystem} . "'."); + $self->{output}->option_exit(); + } + $self->add_result(instance => $self->{option_results}->{filesystem}); + } else { + foreach my $oid (keys %{$self->{results}->{$oid_fileSystemSpaceEntry}}) { + next if ($oid !~ /^$oid_fileSystemResourceName\.(\d+)$/); + my $instance = $1; + my $filter_name = $self->{results}->{$oid_fileSystemSpaceEntry}->{$oid_fileSystemResourceName . '.' . $instance}; + if (!defined($self->{option_results}->{filesystem})) { + $self->add_result(instance => $instance); + next; + } + if (defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{filesystem}/i) { + $self->add_result(instance => $instance); + } + if (defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{filesystem}/) { + $self->add_result(instance => $instance); + } + if (!defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name eq $self->{option_results}->{filesystem}) { + $self->add_result(instance => $instance); + } + } + } + + if (scalar(keys %{$self->{filesystem_id_selected}}) <= 0 && !defined($options{disco})) { + if (defined($self->{option_results}->{device})) { + $self->{output}->add_option_msg(short_msg => "No filesystem found '" . $self->{option_results}->{filesystem} . "'."); + } else { + $self->{output}->add_option_msg(short_msg => "No filesystem found."); + } + $self->{output}->option_exit(); + } +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => ['name', 'deviceid']); +} + +sub disco_show { + my ($self, %options) = @_; + + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + $self->manage_selection(disco => 1); + foreach (sort keys %{$self->{filesystem_id_selected}}) { + $self->{output}->add_disco_entry(name => $self->{filesystem_id_selected}->{$_}->{display}, + deviceid => $_); + } +} + + +1; + +__END__ + +=head1 MODE + +Check filesystem usages. + +=over 8 + +=item B<--warning-usage> + +Threshold warning in percent. + +=item B<--critical-usage> + +Threshold critical in percent + +=item B<--filesystem> + +Set the filesystem (number expected) ex: 1, 2,... (empty means 'check all filesystems'). + +=item B<--name> + +Allows to use filesystem name with option --filesystem instead of devoce oid index. + +=item B<--regexp> + +Allows to use regexp to filter filesystems (with option --name). + +=item B<--regexp-isensitive> + +Allows to use regexp non case-sensitive to filter filesystems (with option --name). + +=back + +=cut diff --git a/centreon-plugins/storage/emc/DataDomain/mode/hardware.pm b/centreon-plugins/storage/emc/DataDomain/mode/hardware.pm new file mode 100644 index 000000000..97ed9b2af --- /dev/null +++ b/centreon-plugins/storage/emc/DataDomain/mode/hardware.pm @@ -0,0 +1,367 @@ +################################################################################ +# 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::emc::DataDomain::mode::hardware; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use storage::emc::DataDomain::lib::functions; +use storage::emc::DataDomain::mode::components::temperature; +use storage::emc::DataDomain::mode::components::psu; +use storage::emc::DataDomain::mode::components::fan; +use storage::emc::DataDomain::mode::components::disk; +use storage::emc::DataDomain::mode::components::battery; + +my $oid_sysDescr = '.1.3.6.1.2.1.1.1'; # 'Data Domain OS 5.4.1.1-411752' +my $oid_powerModuleEntry = '.1.3.6.1.4.1.19746.1.1.1.1.1.1'; +my $oid_temperatureSensorEntry = '.1.3.6.1.4.1.19746.1.1.2.1.1.1'; +my $oid_fanPropertiesEntry = '.1.3.6.1.4.1.19746.1.1.3.1.1.1'; +my $oid_nvramBatteryEntry = '.1.3.6.1.4.1.19746.1.2.3.1.1'; + +my $thresholds = { + fan => [ + ['notfound', 'OK'], + ['ok', 'OK'], + ['failed', 'CRITICAL'], + ], + temperature => [ + ['failed', 'CRITICAL'], + ['ok', 'OK'], + ['notfound', 'OK'], + ['absent', 'OK'], + ['overheatWarning', 'WARNING'], + ['overheatCritical', 'CRITICAL'], + ], + psu => [ + ['absent', 'OK'], + ['ok', 'OK'], + ['failed', 'CRITICAL'], + ['faulty', 'WARNING'], + ['acnone', 'WARNING'], + ['unknown', 'UNKNOWN'], + ], + disk => [ + ['ok', 'OK'], + ['unknown', 'UNKNOWN'], + ['absent', 'OK'], + ['failed', 'CRITICAL'], + ], + battery => [ + ['ok', 'OK'], + ['disabled', 'OK'], + ['discharged', 'WARNING'], + ['softdisabled', 'OK'], + ['UNKNOWN', 'UNKNOWN'], + ], +}; + +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' }, + "absent-problem:s" => { name => 'absent' }, + "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 !~ /(battery|temperature)/) { + $self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: battery or temperature)."); + $self->{output}->option_exit(); + } + my $position = 0; + if (defined($self->{numeric_threshold}->{$section})) { + $position = scalar(@{$self->{numeric_threshold}->{$section}}); + } + if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'."); + $self->{output}->option_exit(); + } + $self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section})); + push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp }; + } + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->{results_leef} = $self->{snmp}->get_leef(oids => [ $oid_sysDescr . '.0' ]); + if (!($self->{os_version} = storage::emc::DataDomain::lib::functions::get_version(value => $self->{results_leef}->{$oid_sysDescr . '.0'}))) { + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => 'Cannot get DataDomain OS version.'); + $self->{output}->display(); + $self->{output}->exit(); + } + + my $oid_diskPropState; + if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { + $oid_diskPropState = '.1.3.6.1.4.1.19746.1.6.1.1.1.8'; + } else { + $oid_diskPropState = '.1.3.6.1.4.1.19746.1.6.1.1.1.7'; + } + + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ + { oid => $oid_powerModuleEntry }, + { oid => $oid_temperatureSensorEntry }, + { oid => $oid_fanPropertiesEntry }, + { oid => $oid_diskPropState }, + { oid => $oid_nvramBatteryEntry }, + ]); + + + $self->{output}->output_add(long_msg => 'DataDomain OS version: ' . $self->{os_version} . '.'); + if ($self->{option_results}->{component} eq 'all') { + storage::emc::DataDomain::mode::components::psu::check($self); + storage::emc::DataDomain::mode::components::fan::check($self); + storage::emc::DataDomain::mode::components::disk::check($self); + storage::emc::DataDomain::mode::components::temperature::check($self); + storage::emc::DataDomain::mode::components::battery::check($self); + } elsif ($self->{option_results}->{component} eq 'fan') { + storage::emc::DataDomain::mode::components::fan::check($self); + } elsif ($self->{option_results}->{component} eq 'psu') { + storage::emc::DataDomain::mode::components::psu::check($self); + } elsif ($self->{option_results}->{component} eq 'disk') { + storage::emc::DataDomain::mode::components::disk::check($self); + } elsif ($self->{option_results}->{component} eq 'temperature') { + storage::emc::DataDomain::mode::components::temperature::check($self); + } elsif ($self->{option_results}->{component} eq 'battery') { + storage::emc::DataDomain::mode::components::battery::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}; + 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 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; +} + +sub get_severity_numeric { + my ($self, %options) = @_; + my $status = 'OK'; # default + my $thresholds = { warning => undef, critical => undef }; + + 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}); + + } + } + $status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0); + } + + return ($status, $thresholds->{warning}, $thresholds->{critical}); +} + +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 components (Fans, Power Supplies, Temperatures, Disks, Nvram Batteries). + +=over 8 + +=item B<--component> + +Which component to check (Default: 'all'). +Can be: 'psu', 'fan', 'disk', 'temperature', 'battery'. + +=item B<--exclude> + +Exclude some parts (comma seperated list) (Example: --exclude=psu) +Can also exclude specific instance: --exclude='psu#3.3#' + +=item B<--absent-problem> + +Return an error if an entity is not 'present' (default is skipping) (comma seperated list) +Can be specific or global: --absent-problem=fan#1.1# + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='fan,CRITICAL,^(?!(ok)$)' + +=item B<--warning> + +Set warning threshold for temperatures (syntax: regexp,treshold) +Example: --warning='.*,20' + +=item B<--critical> + +Set critical threshold for temperatures and battery charge (syntax: type,regexp,treshold) +Example: --critical='temperature,1.1,25' --critical='battery,.*,20:' + +=back + +=cut + diff --git a/centreon-plugins/storage/emc/DataDomain/mode/nvrambattery.pm b/centreon-plugins/storage/emc/DataDomain/mode/nvrambattery.pm deleted file mode 100644 index 7eae94745..000000000 --- a/centreon-plugins/storage/emc/DataDomain/mode/nvrambattery.pm +++ /dev/null @@ -1,153 +0,0 @@ -################################################################################ -# 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::emc::DataDomain::mode::nvrambattery; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -my %conditions = ( - 1 => ['ok', 'OK'], - 2 => ['disabled', 'OK'], - 3 => ['discharged', 'WARNING'], - 4 => ['unknown', 'UNKNOWN'], - 5 => ['soft disabled', 'OK'], -); - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (5sec) threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (5sec) threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { - my ($self, %options) = @_; - # $options{snmp} = snmp object - $self->{snmp} = $options{snmp}; - - my $oid_nvramBatteryEntry = '.1.3.6.1.4.1.19746.1.2.3.1.1'; - my $oid_nvramBatteryStatus = '.1.3.6.1.4.1.19746.1.2.3.1.1.2'; - my $oid_nvramBatteryCharge = '.1.3.6.1.4.1.19746.1.2.3.1.1.3'; - my $result = $self->{snmp}->get_table(oid => $oid_nvramBatteryEntry, nothing_quit => 1); - - $self->{output}->output_add(severity => 'OK', - short_msg => 'All nvram batteries are ok.'); - - foreach my $oid (keys %$result) { - next if ($oid !~ /^$oid_nvramBatteryStatus/); - $oid =~ /\.([0-9]+)$/; - my $instance = $1; - - my $status = $result->{$oid_nvramBatteryStatus . '.' . $instance}; - my $charge = $result->{$oid_nvramBatteryCharge . '.' . $instance}; - - $self->{output}->output_add(long_msg => sprintf("nvram battery '%s' status is %s.", - $instance, ${$conditions{$status}}[0])); - if (!$self->{output}->is_status(litteral => 1, value => ${$conditions{$status}}[1], compare => 'ok')) { - $self->{output}->output_add(severity => ${$conditions{$status}}[1], - short_msg => sprintf("nvram battery '%s' status is %s", $instance, ${$conditions{$status}}[0])); - } - - # Check only if ok - if ($status == 1) { - my $exit = $self->{perfdata}->threshold_check(value => $charge, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(long_msg => sprintf("nvram battery '%s' charge is %s %%", $instance, - $charge)); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("nvram battery '%s' charge is %s %%", $instance, - $charge)); - } - - $self->{output}->perfdata_add(label => 'nvram_battery_' . $instance, unit => '%', - value => $charge, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0, max => 100); - } - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check nvram Batteries status and charge percentage (DATA-DOMAIN-MIB). - -=over 8 - -=item B<--warning> - -Threshold warning in percent (for charge). - -=item B<--critical> - -Threshold critical in percent (for charge). - -=back - -=cut - \ No newline at end of file diff --git a/centreon-plugins/storage/emc/DataDomain/plugin.pm b/centreon-plugins/storage/emc/DataDomain/plugin.pm index 857a969f0..751357415 100644 --- a/centreon-plugins/storage/emc/DataDomain/plugin.pm +++ b/centreon-plugins/storage/emc/DataDomain/plugin.pm @@ -47,8 +47,8 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'environment' => 'storage::emc::DataDomain::mode::environment', - 'nvram-battery' => 'storage::emc::DataDomain::mode::nvrambattery', + 'hardware' => 'storage::emc::DataDomain::mode::hardware', + 'filesystem-usage' => 'storage::emc::DataDomain::mode::filesystem', ); return $self; diff --git a/centreon-plugins/storage/violin/3000/snmp/plugin.pm b/centreon-plugins/storage/violin/3000/snmp/plugin.pm index d34546ed0..4051f4a9f 100644 --- a/centreon-plugins/storage/violin/3000/snmp/plugin.pm +++ b/centreon-plugins/storage/violin/3000/snmp/plugin.pm @@ -60,5 +60,6 @@ __END__ =head1 PLUGIN DESCRIPTION Check Violin 3000 series in SNMP. +Please use plugin SNMP Linux for system checks ('cpu', 'memory', 'traffic',...). =cut