From de81b0084db4a8c3369e1fb1495cacceceb6c518 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Tue, 16 Sep 2014 11:05:18 +0200 Subject: [PATCH 1/5] Fix #5673 --- hardware/{ups => epdu}/eaton/mode/group.pm | 2 +- hardware/{ups => epdu}/eaton/mode/outlet.pm | 2 +- hardware/{ups => epdu}/eaton/plugin.pm | 6 +- hardware/ups/powerware/mode/alarms.pm | 214 ++++++++++++++++++++ hardware/ups/powerware/mode/environment.pm | 206 +++++++++++++++++++ hardware/ups/powerware/mode/inputlines.pm | 7 +- hardware/ups/powerware/mode/outputlines.pm | 9 +- hardware/ups/powerware/mode/outputsource.pm | 92 +++++++-- 8 files changed, 504 insertions(+), 34 deletions(-) rename hardware/{ups => epdu}/eaton/mode/group.pm (99%) rename hardware/{ups => epdu}/eaton/mode/outlet.pm (99%) rename hardware/{ups => epdu}/eaton/plugin.pm (91%) create mode 100644 hardware/ups/powerware/mode/alarms.pm create mode 100644 hardware/ups/powerware/mode/environment.pm diff --git a/hardware/ups/eaton/mode/group.pm b/hardware/epdu/eaton/mode/group.pm similarity index 99% rename from hardware/ups/eaton/mode/group.pm rename to hardware/epdu/eaton/mode/group.pm index fa0a4f8e7..c56619c67 100644 --- a/hardware/ups/eaton/mode/group.pm +++ b/hardware/epdu/eaton/mode/group.pm @@ -33,7 +33,7 @@ # #################################################################################### -package hardware::ups::eaton::mode::group; +package hardware::epdu::eaton::mode::group; use base qw(centreon::plugins::mode); diff --git a/hardware/ups/eaton/mode/outlet.pm b/hardware/epdu/eaton/mode/outlet.pm similarity index 99% rename from hardware/ups/eaton/mode/outlet.pm rename to hardware/epdu/eaton/mode/outlet.pm index a6ce14343..3534950cd 100644 --- a/hardware/ups/eaton/mode/outlet.pm +++ b/hardware/epdu/eaton/mode/outlet.pm @@ -33,7 +33,7 @@ # #################################################################################### -package hardware::ups::eaton::mode::outlet; +package hardware::epdu::eaton::mode::outlet; use base qw(centreon::plugins::mode); diff --git a/hardware/ups/eaton/plugin.pm b/hardware/epdu/eaton/plugin.pm similarity index 91% rename from hardware/ups/eaton/plugin.pm rename to hardware/epdu/eaton/plugin.pm index 6f65effe4..e7dea7609 100644 --- a/hardware/ups/eaton/plugin.pm +++ b/hardware/epdu/eaton/plugin.pm @@ -33,7 +33,7 @@ # #################################################################################### -package hardware::ups::eaton::plugin; +package hardware::epdu::eaton::plugin; use strict; use warnings; @@ -47,8 +47,8 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'group' => 'hardware::ups::eaton::mode::group', - 'outlet' => 'hardware::ups::eaton::mode::outlet', + 'group' => 'hardware::epdu::eaton::mode::group', + 'outlet' => 'hardware::epdu::eaton::mode::outlet', ); return $self; diff --git a/hardware/ups/powerware/mode/alarms.pm b/hardware/ups/powerware/mode/alarms.pm new file mode 100644 index 000000000..272ce46ad --- /dev/null +++ b/hardware/ups/powerware/mode/alarms.pm @@ -0,0 +1,214 @@ +################################################################################ +# 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 hardware::ups::powerware::mode::alarms; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::plugins::statefile; + +my %alarm_type_map = ( + '.1.3.6.1.4.1.534.1.7.3' => 'OnBattery', + '.1.3.6.1.4.1.534.1.7.4' => 'LowBattery', + '.1.3.6.1.4.1.534.1.7.5' => 'UtilityPowerRestored', + '.1.3.6.1.4.1.534.1.7.6' => 'ReturnFromLowBattery', + '.1.3.6.1.4.1.534.1.7.7' => 'OutputOverload', + '.1.3.6.1.4.1.534.1.7.8' => 'InternalFailure', + '.1.3.6.1.4.1.534.1.7.9' => 'BatteryDischarged', + '.1.3.6.1.4.1.534.1.7.10' => 'InverterFailure', + '.1.3.6.1.4.1.534.1.7.11' => 'OnBypass', + '.1.3.6.1.4.1.534.1.7.12' => 'BypassNotAvailable', + '.1.3.6.1.4.1.534.1.7.13' => 'OutputOff', + '.1.3.6.1.4.1.534.1.7.14' => 'InputFailure', + '.1.3.6.1.4.1.534.1.7.15' => 'BuildingAlarm', + '.1.3.6.1.4.1.534.1.7.16' => 'ShutdownImminent', + '.1.3.6.1.4.1.534.1.7.17' => 'OnInverter', + '.1.3.6.1.4.1.534.1.7.20' => 'BreakerOpen', + '.1.3.6.1.4.1.534.1.7.21' => 'AlarmEntryAdded', + '.1.3.6.1.4.1.534.1.7.22' => 'AlarmEntryRemoved', + '.1.3.6.1.4.1.534.1.7.23' => 'AlarmBatteryBad', + '.1.3.6.1.4.1.534.1.7.24' => 'OutputOffAsRequested', + '.1.3.6.1.4.1.534.1.7.25' => 'DiagnosticTestFailed', + '.1.3.6.1.4.1.534.1.7.26' => 'CommunicationsLost', + '.1.3.6.1.4.1.534.1.7.27' => 'UpsShutdownPending', + '.1.3.6.1.4.1.534.1.7.28' => 'AlarmTestInProgress', + '.1.3.6.1.4.1.534.1.7.29' => 'AmbientTempBad', + '.1.3.6.1.4.1.534.1.7.30' => 'LossOfRedundancy', + '.1.3.6.1.4.1.534.1.7.31' => 'AlarmTempBad', + '.1.3.6.1.4.1.534.1.7.32' => 'AlarmChargerFailed', + '.1.3.6.1.4.1.534.1.7.33' => 'AlarmFanFailure', + '.1.3.6.1.4.1.534.1.7.34' => 'AlarmFuseFailure', + '.1.3.6.1.4.1.534.1.7.35' => 'PowerSwitchBad', + '.1.3.6.1.4.1.534.1.7.36' => 'ModuleFailure', + '.1.3.6.1.4.1.534.1.7.37' => 'OnAlternatePowerSource', + '.1.3.6.1.4.1.534.1.7.38' => 'AltPowerNotAvailable', + '.1.3.6.1.4.1.534.1.7.39' => 'NoticeCondition', + '.1.3.6.1.4.1.534.1.7.40' => 'RemoteTempBad', + '.1.3.6.1.4.1.534.1.7.41' => 'RemoteHumidityBad', + '.1.3.6.1.4.1.534.1.7.42' => 'AlarmOutputBad', + '.1.3.6.1.4.1.534.1.7.43' => 'AlarmAwaitingPower', + '.1.3.6.1.4.1.534.1.7.44' => 'OnMaintenanceBypass', +); + +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-type:s" => { name => 'filter_type', + default => '^(?!(UtilityPowerRestored|NoticeCondition|ReturnFromLowBattery|AlarmEntryAdded|AlarmEntryRemoved))' }, + "memory" => { name => 'memory' }, + "warning" => { name => 'warning' }, + }); + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->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(); + my $datas = {}; + my $last_time; + my $exit = defined($self->{option_results}->{warning}) ? 'WARNING' : 'CRITICAL'; + my ($num_alarms_checked, $num_errors) = (0, 0); + + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->read(statefile => "cache_ups_powerware_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); + $self->{output}->output_add(severity => 'OK', + short_msg => "No new problems detected."); + $last_time = $self->{statefile_cache}->get(name => 'last_time'); + } else { + $self->{output}->output_add(severity => 'OK', + short_msg => "No problems detected."); + } + + my $oid_xupsAlarmEntry = '.1.3.6.1.4.1.534.1.7.2.1'; + my $oid_xupsAlarmDescr = '.1.3.6.1.4.1.534.1.7.2.1.2'; + my $oid_xupsAlarmTime = '.1.3.6.1.4.1.534.1.7.2.1.3'; + + my $result = $self->{snmp}->get_table(oid => $oid_xupsAlarmEntry); + + foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { + next if ($key !~ /^$oid_xupsAlarmDescr\.(\d+)$/); + my $instance = $1; + + my $type = $alarm_type_map{$result->{$key}}; + my $time = $result->{$oid_xupsAlarmTime . '.' . $instance}; + + if (defined($self->{option_results}->{memory})) { + $datas->{$instance . '_type'} = $type; + $datas->{$instance . '_time'} = $time; + my $compare_type = $self->{statefile_cache}->get(name => $instance . '_type'); + my $compare_time = $self->{statefile_cache}->get(name => $instance . '_time'); + next if (defined($compare_type) && defined($compare_time) && $type eq $compare_type && $time eq $compare_time); + } + + $num_alarms_checked++; + + next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && $type !~ /$self->{option_results}->{filter_type}/); + + my ($days, $hours, $minutes, $seconds) = ($time / 100 / 86400, $time / 100 % 86400 / 3600, $time / 100 % 86400 % 3600 / 60, $time / 100 % 86400 % 3600 % 60); + $num_errors++; + $self->{output}->output_add(long_msg => sprintf("%d day(s), %d:%d:%d : %s", + $days, $hours, $minutes, $seconds, + $type + ) + ); + + + } + + $self->{output}->output_add(long_msg => sprintf("Number of message checked: %s", $num_alarms_checked)); + if ($num_errors != 0) { + # Message problem + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("%d problem detected (use verbose for more details)", $num_errors) + ); + } + + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->write(data => $datas); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check alarms (XUPS-MIB). + +=over 8 + +=item B<--warning> + +Use warning return instead 'critical'. + +=item B<--memory> + +Only check new alarms. + +=item B<--filter-type> + +Filter on type. (can be a regexp) +Default: ^(?!(UtilityPowerRestored|NoticeCondition|ReturnFromLowBattery|AlarmEntryAdded|AlarmEntryRemoved)) + +=back + +=cut + \ No newline at end of file diff --git a/hardware/ups/powerware/mode/environment.pm b/hardware/ups/powerware/mode/environment.pm new file mode 100644 index 000000000..ed263d1e0 --- /dev/null +++ b/hardware/ups/powerware/mode/environment.pm @@ -0,0 +1,206 @@ +################################################################################ +# 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 hardware::ups::powerware::mode::environment; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; + +my $maps_counters = { + temperature => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'temperature', no_value => 0, }, + ], + output_template => 'Ambiant Temperature: %.2f C', output_error_template => 'Ambiant Temperature: %s', + perfdatas => [ + { value => 'temperature_absolute', label => 'temperature', template => '%.2f', + unit => 'C' }, + ], + } + }, + humidity => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'humidity', no_value => 0 }, + ], + output_template => 'Humidity: %.2f %%', output_error_template => 'Humidity: %s', + perfdatas => [ + { value => 'humidity_absolute', label => 'humidity', template => '%.2f', + unit => '%', min => 0, max => 100 }, + ], + } + }, +}; + +my $oid_xupsEnvironment = '.1.3.6.1.4.1.534.1.6'; +my $oid_xupsEnvAmbientTemp = '.1.3.6.1.4.1.534.1.6.1.0'; # in degree centigrade +my $oid_xupsEnvAmbientLowerLimit = '.1.3.6.1.4.1.534.1.6.2.0'; +my $oid_xupsEnvAmbientUpperLimit = '.1.3.6.1.4.1.534.1.6.3.0'; +my $oid_xupsEnvAmbientHumidity = '.1.3.6.1.4.1.534.1.6.4.0'; # in % + +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 => + { + }); + + $self->{instance_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(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 manage_counters { + my ($self, %options) = @_; + + foreach (sort keys %{$options{maps_counters}}) { + $options{maps_counters}->{$_}->{obj}->set(instance => $options{instance}); + + my ($value_check) = $options{maps_counters}->{$_}->{obj}->execute(values => $self->{instance_selected}->{$options{instance}}); + + # We don't want to display no value + next if ($value_check == -10); + if ($value_check != 0) { + next; + } + my $exit = $options{maps_counters}->{$_}->{obj}->threshold_check(); + + my $output = $options{maps_counters}->{$_}->{obj}->output(); + + $self->{output}->output_add(severity => $exit, + short_msg => $output + ); + + $options{maps_counters}->{$_}->{obj}->perfdata(); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->manage_selection(); + + $self->manage_counters(instance => 'ambiant', maps_counters => $maps_counters); + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub manage_selection { + my ($self, %options) = @_; + my $values_ok = 0; + $self->{instance_selected}->{ambiant} = {}; + + $self->{results} = $self->{snmp}->get_table(oid => $oid_xupsEnvironment, + nothing_quit => 1); + + if (defined($self->{results}->{$oid_xupsEnvAmbientTemp}) && $self->{results}->{$oid_xupsEnvAmbientTemp} ne '' && + $self->{results}->{$oid_xupsEnvAmbientTemp} != 0) { + $self->{instance_selected}->{ambiant}->{temperature} = $self->{results}->{$oid_xupsEnvAmbientTemp}; + $values_ok++; + } + if (defined($self->{results}->{$oid_xupsEnvAmbientHumidity}) && $self->{results}->{$oid_xupsEnvAmbientHumidity} ne '' && + $self->{results}->{$oid_xupsEnvAmbientHumidity} != 0) { + $self->{instance_selected}->{ambiant}->{humidity} = $self->{results}->{$oid_xupsEnvAmbientHumidity}; + $values_ok++; + } + + if (!defined($self->{option_results}->{'critical-temperature'}) || $self->{option_results}->{'critical-temperature'} eq '') { + my $crit_val = ''; + $crit_val = $self->{results}->{$oid_xupsEnvAmbientLowerLimit} . ':' if (defined($self->{results}->{$oid_xupsEnvAmbientLowerLimit}) && + $self->{results}->{$oid_xupsEnvAmbientLowerLimit} ne ''); + $crit_val .= $self->{results}->{$oid_xupsEnvAmbientUpperLimit} if (defined($self->{results}->{$oid_xupsEnvAmbientUpperLimit}) && + $self->{results}->{$oid_xupsEnvAmbientUpperLimit} ne '' && $self->{results}->{$oid_xupsEnvAmbientUpperLimit} ne 0); + $self->{perfdata}->threshold_validate(label => 'critical-temperature', value => $crit_val); + } + + if ($values_ok == 0) { + $self->{output}->add_option_msg(short_msg => "Cannot get temperature and humidity values."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check environment (temperature and humidity) (XUPS-MIB). + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'temperature', 'humidity'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'temperature', 'humidity'. + +=back + +=cut diff --git a/hardware/ups/powerware/mode/inputlines.pm b/hardware/ups/powerware/mode/inputlines.pm index 2acab94d4..52b079e6c 100644 --- a/hardware/ups/powerware/mode/inputlines.pm +++ b/hardware/ups/powerware/mode/inputlines.pm @@ -39,7 +39,6 @@ use base qw(centreon::plugins::mode); use strict; use warnings; - use centreon::plugins::values; my $maps_counters = { @@ -257,9 +256,7 @@ sub manage_selection { } if (scalar(keys %{$self->{instance_selected}}) <= 0) { - if (defined($self->{option_results}->{name})) { - $self->{output}->add_option_msg(short_msg => "No input lines found."); - } + $self->{output}->add_option_msg(short_msg => "No input lines found."); $self->{output}->option_exit(); } } @@ -270,7 +267,7 @@ __END__ =head1 MODE -Check Input lines metrics (frequence, voltage, current and true power). +Check Input lines metrics (frequence, voltage, current and true power) (XUPS-MIB). =over 8 diff --git a/hardware/ups/powerware/mode/outputlines.pm b/hardware/ups/powerware/mode/outputlines.pm index f8a3430b7..af01ea82e 100644 --- a/hardware/ups/powerware/mode/outputlines.pm +++ b/hardware/ups/powerware/mode/outputlines.pm @@ -39,7 +39,6 @@ use base qw(centreon::plugins::mode); use strict; use warnings; - use centreon::plugins::values; my $maps_counters = { @@ -99,7 +98,7 @@ my $maps_counters2 = { key_values => [ { name => 'load', no_value => -1 }, ], - output_template => 'Load: %.2f %', output_error_template => 'Load: %s', + output_template => 'Load: %.2f %%', output_error_template => 'Load: %s', perfdatas => [ { value => 'load_absolute', label => 'load', template => '%.2f', unit => '%', min => 0 }, @@ -271,9 +270,7 @@ sub manage_selection { } if (scalar(keys %{$self->{instance_selected}}) <= 0) { - if (defined($self->{option_results}->{name})) { - $self->{output}->add_option_msg(short_msg => "No output lines found."); - } + $self->{output}->add_option_msg(short_msg => "No output lines found."); $self->{output}->option_exit(); } } @@ -284,7 +281,7 @@ __END__ =head1 MODE -Check Output lines metrics (load, voltage, current and true power). +Check Output lines metrics (load, voltage, current and true power) (XUPS-MIB). =over 8 diff --git a/hardware/ups/powerware/mode/outputsource.pm b/hardware/ups/powerware/mode/outputsource.pm index 486460fd2..18d2127cb 100644 --- a/hardware/ups/powerware/mode/outputsource.pm +++ b/hardware/ups/powerware/mode/outputsource.pm @@ -33,21 +33,34 @@ # #################################################################################### -package hardware::ups::standard::rfc1628::mode::outputsource; +package hardware::ups::powerware::mode::outputsource; use base qw(centreon::plugins::mode); use strict; use warnings; -my %outputsource_status = ( - 1 => ['other', 'UNKNOWN'], - 2 => ['none', 'CRITICAL'], - 3 => ['normal', 'OK'], - 4 => ['bypass', 'WARNING'], - 5 => ['battery', 'WARNING'], - 6 => ['booster', 'WARNING'], - 7 => ['reducer', 'WARNING'], +my $oid_xupsOutputSource = '.1.3.6.1.4.1.534.1.4.5.0'; + +my $thresholds = { + osource => [ + ['normal', 'OK'], + ['.*', 'CRITICAL'], + ], +}; + +my %map_osource_status = ( + 1 => 'other', + 2 => 'none', + 3 => 'normal', + 4 => 'bypass', + 5 => 'battery', + 6 => 'booster', + 7 => 'reducer', + 8 => 'parallelCapacity', + 9 => 'parallelRedundant', + 10 => 'highEfficiencyMode', + 11 => 'maintenanceBypass', ); sub new { @@ -57,7 +70,8 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { + { + "threshold-overload:s@" => { name => 'threshold_overload' }, }); return $self; @@ -66,6 +80,21 @@ sub new { sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); + + $self->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + if ($val !~ /^(.*?),(.*)$/) { + $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $status, $filter) = ('osource', $1, $2); + if ($self->{output}->is_litteral_status(status => $status) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong treshold-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}; + } } sub run { @@ -73,28 +102,55 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; - my $oid_upsOutputSource = '.1.3.6.1.2.1.33.1.4.1.0'; - - my $result = $self->{snmp}->get_leef(oids => [$oid_upsOutputSource], nothing_quit => 1); - my $status = $result->{'.1.3.6.1.2.1.33.1.4.1.0'}; - - $self->{output}->output_add(severity => ${$outputsource_status{$status}}[1], - short_msg => sprintf("Output source status is %s", ${$outputsource_status{$status}}[0])); + my $result = $self->{snmp}->get_leef(oids => [$oid_xupsOutputSource], nothing_quit => 1); + my $exit = $self->get_severity(section => 'osource', value => $map_osource_status{$result->{$oid_xupsOutputSource}}); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Output source status is %s", + $map_osource_status{$result->{$oid_xupsOutputSource}})); $self->{output}->display(); $self->{output}->exit(); } + +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 output source status. +Check output source status (XUPS-MIB). =over 8 +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='WARNING,bypass|booster' + =back =cut From 0146000b738f6114b98e026941eabadd39d58204 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Tue, 16 Sep 2014 16:32:49 +0200 Subject: [PATCH 2/5] Fix #5587 --- hardware/ups/mge/mode/alarms.pm | 214 +++++++++++ hardware/ups/mge/mode/batterystatus.pm | 172 +++++++++ hardware/ups/mge/mode/environment.pm | 194 ++++++++++ hardware/ups/mge/mode/inputlines.pm | 291 +++++++++++++++ hardware/ups/mge/mode/outputlines.pm | 337 ++++++++++++++++++ hardware/ups/mge/mode/outputsource.pm | 115 ++++++ hardware/ups/mge/plugin.pm | 68 ++++ .../ups/standard/rfc1628/mode/outputlines.pm | 2 +- 8 files changed, 1392 insertions(+), 1 deletion(-) create mode 100644 hardware/ups/mge/mode/alarms.pm create mode 100644 hardware/ups/mge/mode/batterystatus.pm create mode 100644 hardware/ups/mge/mode/environment.pm create mode 100644 hardware/ups/mge/mode/inputlines.pm create mode 100644 hardware/ups/mge/mode/outputlines.pm create mode 100644 hardware/ups/mge/mode/outputsource.pm create mode 100644 hardware/ups/mge/plugin.pm diff --git a/hardware/ups/mge/mode/alarms.pm b/hardware/ups/mge/mode/alarms.pm new file mode 100644 index 000000000..272ce46ad --- /dev/null +++ b/hardware/ups/mge/mode/alarms.pm @@ -0,0 +1,214 @@ +################################################################################ +# 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 hardware::ups::powerware::mode::alarms; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::plugins::statefile; + +my %alarm_type_map = ( + '.1.3.6.1.4.1.534.1.7.3' => 'OnBattery', + '.1.3.6.1.4.1.534.1.7.4' => 'LowBattery', + '.1.3.6.1.4.1.534.1.7.5' => 'UtilityPowerRestored', + '.1.3.6.1.4.1.534.1.7.6' => 'ReturnFromLowBattery', + '.1.3.6.1.4.1.534.1.7.7' => 'OutputOverload', + '.1.3.6.1.4.1.534.1.7.8' => 'InternalFailure', + '.1.3.6.1.4.1.534.1.7.9' => 'BatteryDischarged', + '.1.3.6.1.4.1.534.1.7.10' => 'InverterFailure', + '.1.3.6.1.4.1.534.1.7.11' => 'OnBypass', + '.1.3.6.1.4.1.534.1.7.12' => 'BypassNotAvailable', + '.1.3.6.1.4.1.534.1.7.13' => 'OutputOff', + '.1.3.6.1.4.1.534.1.7.14' => 'InputFailure', + '.1.3.6.1.4.1.534.1.7.15' => 'BuildingAlarm', + '.1.3.6.1.4.1.534.1.7.16' => 'ShutdownImminent', + '.1.3.6.1.4.1.534.1.7.17' => 'OnInverter', + '.1.3.6.1.4.1.534.1.7.20' => 'BreakerOpen', + '.1.3.6.1.4.1.534.1.7.21' => 'AlarmEntryAdded', + '.1.3.6.1.4.1.534.1.7.22' => 'AlarmEntryRemoved', + '.1.3.6.1.4.1.534.1.7.23' => 'AlarmBatteryBad', + '.1.3.6.1.4.1.534.1.7.24' => 'OutputOffAsRequested', + '.1.3.6.1.4.1.534.1.7.25' => 'DiagnosticTestFailed', + '.1.3.6.1.4.1.534.1.7.26' => 'CommunicationsLost', + '.1.3.6.1.4.1.534.1.7.27' => 'UpsShutdownPending', + '.1.3.6.1.4.1.534.1.7.28' => 'AlarmTestInProgress', + '.1.3.6.1.4.1.534.1.7.29' => 'AmbientTempBad', + '.1.3.6.1.4.1.534.1.7.30' => 'LossOfRedundancy', + '.1.3.6.1.4.1.534.1.7.31' => 'AlarmTempBad', + '.1.3.6.1.4.1.534.1.7.32' => 'AlarmChargerFailed', + '.1.3.6.1.4.1.534.1.7.33' => 'AlarmFanFailure', + '.1.3.6.1.4.1.534.1.7.34' => 'AlarmFuseFailure', + '.1.3.6.1.4.1.534.1.7.35' => 'PowerSwitchBad', + '.1.3.6.1.4.1.534.1.7.36' => 'ModuleFailure', + '.1.3.6.1.4.1.534.1.7.37' => 'OnAlternatePowerSource', + '.1.3.6.1.4.1.534.1.7.38' => 'AltPowerNotAvailable', + '.1.3.6.1.4.1.534.1.7.39' => 'NoticeCondition', + '.1.3.6.1.4.1.534.1.7.40' => 'RemoteTempBad', + '.1.3.6.1.4.1.534.1.7.41' => 'RemoteHumidityBad', + '.1.3.6.1.4.1.534.1.7.42' => 'AlarmOutputBad', + '.1.3.6.1.4.1.534.1.7.43' => 'AlarmAwaitingPower', + '.1.3.6.1.4.1.534.1.7.44' => 'OnMaintenanceBypass', +); + +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-type:s" => { name => 'filter_type', + default => '^(?!(UtilityPowerRestored|NoticeCondition|ReturnFromLowBattery|AlarmEntryAdded|AlarmEntryRemoved))' }, + "memory" => { name => 'memory' }, + "warning" => { name => 'warning' }, + }); + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->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(); + my $datas = {}; + my $last_time; + my $exit = defined($self->{option_results}->{warning}) ? 'WARNING' : 'CRITICAL'; + my ($num_alarms_checked, $num_errors) = (0, 0); + + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->read(statefile => "cache_ups_powerware_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); + $self->{output}->output_add(severity => 'OK', + short_msg => "No new problems detected."); + $last_time = $self->{statefile_cache}->get(name => 'last_time'); + } else { + $self->{output}->output_add(severity => 'OK', + short_msg => "No problems detected."); + } + + my $oid_xupsAlarmEntry = '.1.3.6.1.4.1.534.1.7.2.1'; + my $oid_xupsAlarmDescr = '.1.3.6.1.4.1.534.1.7.2.1.2'; + my $oid_xupsAlarmTime = '.1.3.6.1.4.1.534.1.7.2.1.3'; + + my $result = $self->{snmp}->get_table(oid => $oid_xupsAlarmEntry); + + foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { + next if ($key !~ /^$oid_xupsAlarmDescr\.(\d+)$/); + my $instance = $1; + + my $type = $alarm_type_map{$result->{$key}}; + my $time = $result->{$oid_xupsAlarmTime . '.' . $instance}; + + if (defined($self->{option_results}->{memory})) { + $datas->{$instance . '_type'} = $type; + $datas->{$instance . '_time'} = $time; + my $compare_type = $self->{statefile_cache}->get(name => $instance . '_type'); + my $compare_time = $self->{statefile_cache}->get(name => $instance . '_time'); + next if (defined($compare_type) && defined($compare_time) && $type eq $compare_type && $time eq $compare_time); + } + + $num_alarms_checked++; + + next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && $type !~ /$self->{option_results}->{filter_type}/); + + my ($days, $hours, $minutes, $seconds) = ($time / 100 / 86400, $time / 100 % 86400 / 3600, $time / 100 % 86400 % 3600 / 60, $time / 100 % 86400 % 3600 % 60); + $num_errors++; + $self->{output}->output_add(long_msg => sprintf("%d day(s), %d:%d:%d : %s", + $days, $hours, $minutes, $seconds, + $type + ) + ); + + + } + + $self->{output}->output_add(long_msg => sprintf("Number of message checked: %s", $num_alarms_checked)); + if ($num_errors != 0) { + # Message problem + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("%d problem detected (use verbose for more details)", $num_errors) + ); + } + + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->write(data => $datas); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check alarms (XUPS-MIB). + +=over 8 + +=item B<--warning> + +Use warning return instead 'critical'. + +=item B<--memory> + +Only check new alarms. + +=item B<--filter-type> + +Filter on type. (can be a regexp) +Default: ^(?!(UtilityPowerRestored|NoticeCondition|ReturnFromLowBattery|AlarmEntryAdded|AlarmEntryRemoved)) + +=back + +=cut + \ No newline at end of file diff --git a/hardware/ups/mge/mode/batterystatus.pm b/hardware/ups/mge/mode/batterystatus.pm new file mode 100644 index 000000000..3235ac6fd --- /dev/null +++ b/hardware/ups/mge/mode/batterystatus.pm @@ -0,0 +1,172 @@ +################################################################################ +# 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 hardware::ups::mge::mode::batterystatus; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my %map_battery_status = ( + '.1.3.6.1.4.1.705.1.5.9.0' => 'BatteryFaultBattery', + '.1.3.6.1.4.1.705.1.5.10.0' => 'BatteryNoBattery', + '.1.3.6.1.4.1.705.1.5.11.0' => 'BatteryReplacement', + '.1.3.6.1.4.1.705.1.5.12.0' => 'BatteryUnavailableBattery', + '.1.3.6.1.4.1.705.1.5.13.0' => 'BatteryNotHighCharge', + '.1.3.6.1.4.1.705.1.5.14.0' => 'BatteryLowBattery', + '.1.3.6.1.4.1.705.1.5.15.0' => 'BatteryChargerFault', + '.1.3.6.1.4.1.705.1.5.16.0' => 'BatteryLowCondition', + '.1.3.6.1.4.1.705.1.5.17.0' => 'BatteryLowRecharge', +); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning', }, + "critical:s" => { name => 'critical', }, + "filter-status:s" => { name => 'filter_status', }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $oid_upsmgBattery = '.1.3.6.1.4.1.705.1.5'; + my $oid_upsmgBatteryRemainingTime = '.1.3.6.1.4.1.705.1.5.1.0'; # in seconds + my $oid_upsmgBatteryLevel = '.1.3.6.1.4.1.705.1.5.2.0'; + my $oid_upsmgBatteryVoltage = '.1.3.6.1.4.1.705.1.5.5.0'; # in dV + my $oid_upsmgBatteryCurrent = '.1.3.6.1.4.1.705.1.5.6.0'; # in dA + my $oid_upsmgBatteryTemperature = '.1.3.6.1.4.1.705.1.5.7.0'; # in degrees Centigrade + + my $result = $self->{snmp}->get_table(oid => $oid_upsmgBattery, nothing_quit => 1); + + my $current = defined($result->{$oid_upsmgBatteryCurrent}) ? $result->{$oid_upsmgBatteryCurrent} * 0.1 : 0; + my $voltage = defined($result->{$oid_upsmgBatteryVoltage}) ? $result->{$oid_upsmgBatteryVoltage} * 0.1 : 0; + my $min_remain = defined($result->{$oid_upsmgBatteryRemainingTime}) ? int($result->{$oid_upsmgBatteryRemainingTime} / 60) : 'unknown'; + my $charge_remain = defined($result->{$oid_upsmgBatteryLevel}) ? $result->{$oid_upsmgBatteryLevel} : 'unknown'; + my $temp = defined($result->{$oid_upsmgBatteryTemperature}) ? $result->{$oid_upsmgBatteryTemperature} : 0; + + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("Battery status is ok")); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %map_battery_status)) { + next if (defined($self->{option_results}->{filter_status}) && $self->{option_results}->{filter_status} ne '' && $map_battery_status{$oid} =~ /$self->{option_results}->{filter_status}/); + if (defined($result->{$oid}) && $result->{$oid} == 1) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Battery status is '%s'", $map_battery_status{$oid})); + } + } + + my $exit_code = 'ok'; + if ($charge_remain ne 'unknown') { + $exit_code = $self->{perfdata}->threshold_check(value => $charge_remain, + threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->perfdata_add(label => 'load', unit => '%', + value => $charge_remain, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0, max => 100); + } + $self->{output}->output_add(severity => $exit_code, + short_msg => sprintf("Charge remaining: %s%% (%s minutes remaining)", $charge_remain, $min_remain)); + + if ($current != 0) { + $self->{output}->perfdata_add(label => 'current', unit => 'A', + value => $current, + ); + } + if ($voltage != 0) { + $self->{output}->perfdata_add(label => 'voltage', unit => 'V', + value => $voltage, + ); + } + if ($temp != 0) { + $self->{output}->perfdata_add(label => 'temp', unit => 'C', + value => $temp, + ); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check Battery Status and battery charge remaining. + +=over 8 + +=item B<--warning> + +Threshold warning in percent of charge remaining. + +=item B<--critical> + +Threshold critical in percent of charge remaining. + +=item B<--filter-status> + +Filter on status. (can be a regexp) + +=back + +=cut diff --git a/hardware/ups/mge/mode/environment.pm b/hardware/ups/mge/mode/environment.pm new file mode 100644 index 000000000..71ab21f99 --- /dev/null +++ b/hardware/ups/mge/mode/environment.pm @@ -0,0 +1,194 @@ +################################################################################ +# 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 hardware::ups::mge::mode::environment; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; + +my $maps_counters = { + temperature => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'temperature', no_value => 0, }, + ], + output_template => 'Ambiant Temperature: %.2f C', output_error_template => 'Ambiant Temperature: %s', + perfdatas => [ + { value => 'temperature_absolute', label => 'temperature', template => '%.2f', + unit => 'C' }, + ], + } + }, + humidity => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'humidity', no_value => 0 }, + ], + output_template => 'Humidity: %.2f %%', output_error_template => 'Humidity: %s', + perfdatas => [ + { value => 'humidity_absolute', label => 'humidity', template => '%.2f', + unit => '%', min => 0, max => 100 }, + ], + } + }, +}; + +my $oid_upsmgEnvironAmbientTemp = '.1.3.6.1.4.1.705.1.8.1.0'; # in degree centigrade +my $oid_upsmgEnvironAmbientHumidity = '.1.3.6.1.4.1.705.1.8.2.0'; # in % + +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 => + { + }); + + $self->{instance_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(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 manage_counters { + my ($self, %options) = @_; + + foreach (sort keys %{$options{maps_counters}}) { + $options{maps_counters}->{$_}->{obj}->set(instance => $options{instance}); + + my ($value_check) = $options{maps_counters}->{$_}->{obj}->execute(values => $self->{instance_selected}->{$options{instance}}); + + # We don't want to display no value + next if ($value_check == -10); + if ($value_check != 0) { + next; + } + my $exit = $options{maps_counters}->{$_}->{obj}->threshold_check(); + + my $output = $options{maps_counters}->{$_}->{obj}->output(); + + $self->{output}->output_add(severity => $exit, + short_msg => $output + ); + + $options{maps_counters}->{$_}->{obj}->perfdata(); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->manage_selection(); + + $self->manage_counters(instance => 'ambiant', maps_counters => $maps_counters); + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub manage_selection { + my ($self, %options) = @_; + my $values_ok = 0; + $self->{instance_selected}->{ambiant} = {}; + + $self->{results} = $self->{snmp}->get_leef(oids => [$oid_upsmgEnvironAmbientTemp, $oid_upsmgEnvironAmbientHumidity], + nothing_quit => 1); + + if (defined($self->{results}->{$oid_upsmgEnvironAmbientTemp}) && $self->{results}->{$oid_upsmgEnvironAmbientTemp} ne '' && + $self->{results}->{$oid_upsmgEnvironAmbientTemp} != 0) { + $self->{instance_selected}->{ambiant}->{temperature} = $self->{results}->{$oid_upsmgEnvironAmbientTemp}; + $values_ok++; + } + if (defined($self->{results}->{$oid_upsmgEnvironAmbientHumidity}) && $self->{results}->{$oid_upsmgEnvironAmbientHumidity} ne '' && + $self->{results}->{$oid_upsmgEnvironAmbientHumidity} != 0) { + $self->{instance_selected}->{ambiant}->{humidity} = $self->{results}->{$oid_upsmgEnvironAmbientHumidity}; + $values_ok++; + } + + if ($values_ok == 0) { + $self->{output}->add_option_msg(short_msg => "Cannot get temperature and humidity values."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check environment (temperature and humidity). + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'temperature', 'humidity'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'temperature', 'humidity'. + +=back + +=cut diff --git a/hardware/ups/mge/mode/inputlines.pm b/hardware/ups/mge/mode/inputlines.pm new file mode 100644 index 000000000..33c075b14 --- /dev/null +++ b/hardware/ups/mge/mode/inputlines.pm @@ -0,0 +1,291 @@ +################################################################################ +# 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 hardware::ups::mge::mode::inputlines; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; + +my %map_input_status = ( + 1 => 'no', + 2 => 'outoftolvolt', + 3 => 'outoftolfreq', + 4 => 'utilityoff', +); + +my $maps_counters = { + voltage => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'voltage', no_value => 0, }, + ], + output_template => 'Voltage: %.2f V', output_error_template => 'Voltage: %s', + perfdatas => [ + { value => 'voltage_absolute', label => 'voltage', template => '%.2f', + unit => 'V', min => 0, label_extra_instance => 1 }, + ], + } + }, + current => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'current', no_value => 0 }, + ], + output_template => 'Current: %.2f A', output_error_template => 'Current: %s', + perfdatas => [ + { value => 'current_absolute', label => 'current', template => '%.2f', + unit => 'A', min => 0, label_extra_instance => 1 }, + ], + } + }, + frequence => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'frequence', no_value => 0, }, + ], + output_template => 'Frequence: %.2f Hz', output_error_template => 'Frequence: %s', + perfdatas => [ + { value => 'frequence_absolute', label => 'frequence', template => '%.2f', + unit => 'Hz', min => 0 }, + ], + } + }, +}; + +my $oid_upsmgInputPhaseNumEntry = '.1.3.6.1.4.1.705.1.6.1'; +my $oid_mginputVoltageEntry = '.1.3.6.1.4.1.705.1.6.2.1.2'; # in dV +my $oid_mginputFrequencyEntry = '.1.3.6.1.4.1.705.1.6.2.1.3'; # in dHz +my $oid_mginputCurrentEntry = '.1.3.6.1.4.1.705.1.6.2.1.6'; # in dA +my $oid_upsmgInputBadStatusEntry = '.1.3.6.1.4.1.705.1.6.3'; +my $oid_upsmgInputLineFailCauseEntry = '.1.3.6.1.4.1.705.1.6.4'; + +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 => + { + }); + + $self->{instance_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(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 manage_counters { + my ($self, %options) = @_; + + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits; + foreach (sort keys %{$options{maps_counters}}) { + $options{maps_counters}->{$_}->{obj}->set(instance => $options{instance}); + + my ($value_check) = $options{maps_counters}->{$_}->{obj}->execute(values => $self->{instance_selected}->{$options{instance}}); + + # We don't want to display no value + next if ($value_check == -10); + if ($value_check != 0) { + $long_msg .= $long_msg_append . $options{maps_counters}->{$_}->{obj}->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $options{maps_counters}->{$_}->{obj}->threshold_check(); + push @exits, $exit2; + + my $output = $options{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 = ', '; + } + + $options{maps_counters}->{$_}->{obj}->perfdata(extra_instance => $self->{multiple}); + } + + $self->{output}->output_add(long_msg => $options{label} . " " . $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 => $options{label} . " " . $short_msg + ); + } + + if ($self->{multiple} == 0) { + $self->{output}->output_add(short_msg => $options{label} . " " . $long_msg); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->manage_selection(); + + $self->{output}->output_add(severity => 'OK', + short_msg => 'Input Line(s) status is ok'); + if (defined($self->{results}->{$oid_upsmgInputBadStatusEntry}->{$oid_upsmgInputBadStatusEntry . '.0'}) && + $self->{results}->{$oid_upsmgInputBadStatusEntry}->{$oid_upsmgInputBadStatusEntry . '.0'} == 1) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Input Line(s) status is '%s'", + $map_input_status{$self->{results}->{$oid_upsmgInputLineFailCauseEntry}->{$oid_upsmgInputLineFailCauseEntry . '.0'}})); + } + + $self->{multiple} = 1; + if (scalar(keys %{$self->{instance_selected}}) == 1) { + $self->{multiple} = 0; + } + + if ($self->{multiple} == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'Input Lines are ok'); + } + + foreach my $id (sort keys %{$self->{instance_selected}}) { + $self->manage_counters(instance => $id, maps_counters => $maps_counters, label => "Input Line '" . $id . "'"); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub add_result { + my ($self, %options) = @_; + + $self->{instance_selected}->{$options{instance}} = {} if (!defined($self->{instance_selected}->{$options{instance}})); + $self->{instance_selected}->{$options{instance}}->{$options{name}} = $self->{results}->{$options{oid}}->{$options{oid} . '.' . $options{instance2}} * 0.1; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ + { oid => $oid_upsmgInputPhaseNumEntry }, + { oid => $oid_mginputVoltageEntry }, + { oid => $oid_mginputFrequencyEntry }, + { oid => $oid_mginputCurrentEntry }, + { oid => $oid_upsmgInputBadStatusEntry }, + { oid => $oid_upsmgInputLineFailCauseEntry }, + ], + , nothing_quit => 1); + + if (!defined($self->{results}->{$oid_upsmgInputPhaseNumEntry}->{$oid_upsmgInputPhaseNumEntry . '.0'}) || + $self->{results}->{$oid_upsmgInputPhaseNumEntry}->{$oid_upsmgInputPhaseNumEntry . '.0'} == 0) { + $self->{output}->add_option_msg(short_msg => "No input lines found."); + $self->{output}->option_exit(); + } + + my %instances = (); + # can be 'xxx.1' or 'xxx.1.0' (cannot respect MIB :) + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_mginputVoltageEntry}})) { + $oid =~ /^$oid_mginputVoltageEntry\.((\d+).*)/; + if (scalar(keys %instances) < $self->{results}->{$oid_upsmgInputPhaseNumEntry}->{$oid_upsmgInputPhaseNumEntry . '.0'}) { + $instances{$2} = 1; + $self->add_result(instance => $2, instance2 => $1, name => 'voltage', oid => $oid_mginputVoltageEntry); + } + } + %instances = (); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_mginputCurrentEntry}})) { + $oid =~ /^$oid_mginputCurrentEntry\.((\d+).*)/; + if (scalar(keys %instances) < $self->{results}->{$oid_upsmgInputPhaseNumEntry}->{$oid_upsmgInputPhaseNumEntry . '.0'}) { + $instances{$2} = 1; + $self->add_result(instance => $2, instance2 => $1, name => 'current', oid => $oid_mginputCurrentEntry); + } + } + %instances = (); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_mginputFrequencyEntry}})) { + $oid =~ /^$oid_mginputFrequencyEntry\.((\d+).*)/; + if (scalar(keys %instances) < $self->{results}->{$oid_upsmgInputPhaseNumEntry}->{$oid_upsmgInputPhaseNumEntry . '.0'}) { + $instances{$2} = 1; + $self->add_result(instance => $2, instance2 => $1, name => 'frequence', oid => $oid_mginputFrequencyEntry); + } + } + + if (scalar(keys %{$self->{instance_selected}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No input lines found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check Input lines metrics (frequence, voltage, current). + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'frequence', 'voltage', 'current'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'frequence', 'voltage', 'current'. + +=back + +=cut diff --git a/hardware/ups/mge/mode/outputlines.pm b/hardware/ups/mge/mode/outputlines.pm new file mode 100644 index 000000000..bfc83c074 --- /dev/null +++ b/hardware/ups/mge/mode/outputlines.pm @@ -0,0 +1,337 @@ +################################################################################ +# 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 hardware::ups::mge::mode::outputlines; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::values; + +my $maps_counters = { + voltage => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'voltage', no_value => 0 }, + ], + output_template => 'Voltage: %.2f V', output_error_template => 'Voltage: %s', + perfdatas => [ + { value => 'voltage_absolute', label => 'voltage', template => '%.2f', + unit => 'V', min => 0, label_extra_instance => 1 }, + ], + } + }, + current => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'current', no_value => 0 }, + ], + output_template => 'Current: %.2f A', output_error_template => 'Current: %s', + perfdatas => [ + { value => 'current_absolute', label => 'current', template => '%.2f', + unit => 'A', min => 0, label_extra_instance => 1 }, + ], + } + }, + frequence => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'frequence', no_value => 0 }, + ], + output_template => 'Frequence: %.2f Hz', output_error_template => 'Frequence: %s', + perfdatas => [ + { value => 'frequence_absolute', label => 'frequence', template => '%.2f', + unit => 'Hz', min => 0 }, + ], + } + }, + load => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'load', no_value => -1 }, + ], + output_template => 'Load: %.2f %%', output_error_template => 'Load: %s', + perfdatas => [ + { value => 'load_absolute', label => 'load', template => '%.2f', + unit => '%', min => 0 }, + ], + } + }, +}; + +my $maps_counters2 = { + 'stdev-3phases' => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'stdev' }, + ], + output_template => 'Load Standard Deviation : %.2f', output_error_template => 'Load Standard Deviation : %s', + perfdatas => [ + { value => 'stdev_absolute', label => 'stdev', template => '%.2f', + min => 0 }, + ], + } + }, +}; + +my $oid_upsmgOutputPhaseNumEntry = '.1.3.6.1.4.1.705.1.7.1'; +my $oid_mgoutputVoltageEntry = '.1.3.6.1.4.1.705.1.7.2.1.2'; # in dV +my $oid_mgoutputFrequencyEntry = '.1.3.6.1.4.1.705.1.7.2.1.3'; # in dHz +my $oid_mgoutputCurrentEntry = '.1.3.6.1.4.1.705.1.7.2.1.5'; # in dA +my $oid_mgoutputLoadPerPhaseEntry = '.1.3.6.1.4.1.705.1.7.2.1.4'; # in % + +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 => + { + }); + + $self->{instance_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(output => $self->{output}, perfdata => $self->{perfdata}, + label => $_); + $maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}}); + } + foreach (keys %{$maps_counters2}) { + $options{options}->add_options(arguments => { + 'warning-' . $_ . ':s' => { name => 'warning-' . $_ }, + 'critical-' . $_ . ':s' => { name => 'critical-' . $_ }, + }); + my $class = $maps_counters2->{$_}->{class}; + $maps_counters2->{$_}->{obj} = $class->new(output => $self->{output}, perfdata => $self->{perfdata}, + label => $_); + $maps_counters2->{$_}->{obj}->set(%{$maps_counters2->{$_}->{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}); + } + foreach (keys %{$maps_counters2}) { + $maps_counters2->{$_}->{obj}->init(option_results => $self->{option_results}); + } +} + +sub manage_counters { + my ($self, %options) = @_; + + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits; + foreach (sort keys %{$options{maps_counters}}) { + $options{maps_counters}->{$_}->{obj}->set(instance => $options{instance}); + + my ($value_check) = $options{maps_counters}->{$_}->{obj}->execute(values => $self->{instance_selected}->{$options{instance}}); + + # We don't want to display no value + next if ($value_check == -10); + if ($value_check != 0) { + $long_msg .= $long_msg_append . $options{maps_counters}->{$_}->{obj}->output_error(); + $long_msg_append = ', '; + next; + } + my $exit2 = $options{maps_counters}->{$_}->{obj}->threshold_check(); + push @exits, $exit2; + + my $output = $options{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 = ', '; + } + + $options{maps_counters}->{$_}->{obj}->perfdata(extra_instance => $self->{multiple}); + } + + $self->{output}->output_add(long_msg => $options{label} . " " . $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 => $options{label} . " " . $short_msg + ); + } + + if ($self->{multiple} == 0) { + $self->{output}->output_add(short_msg => $options{label} . " " . $long_msg); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->manage_selection(); + + $self->{multiple} = 1; + if (scalar(keys %{$self->{instance_selected}}) == 1) { + $self->{multiple} = 0; + } + + if ($self->{multiple} == 1) { + $self->{output}->output_add(severity => 'OK', + short_msg => 'Output Lines are ok.'); + } + + foreach my $id (sort keys %{$self->{instance_selected}}) { + $self->manage_counters(instance => $id, maps_counters => $maps_counters, label => "Output Line '" . $id . "'"); + } + + if ($self->{results}->{$oid_upsmgOutputPhaseNumEntry}->{$oid_upsmgOutputPhaseNumEntry . '.0'} > 1) { + $self->{instance_selected}->{lines} = { stdev => $self->{stdev} }; + $self->manage_counters(instance => 'lines', maps_counters => $maps_counters2, label => "Output Lines"); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +sub add_result { + my ($self, %options) = @_; + + $self->{instance_selected}->{$options{instance}} = {} if (!defined($self->{instance_selected}->{$options{instance}})); + $self->{instance_selected}->{$options{instance}}->{$options{name}} = $self->{results}->{$options{oid}}->{$options{oid} . '.' . $options{instance2}} * $options{multiple}; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ + { oid => $oid_upsmgOutputPhaseNumEntry }, + { oid => $oid_mgoutputVoltageEntry }, + { oid => $oid_mgoutputFrequencyEntry }, + { oid => $oid_mgoutputCurrentEntry }, + { oid => $oid_mgoutputLoadPerPhaseEntry }, + ], + , nothing_quit => 1); + + if (!defined($self->{results}->{$oid_upsmgOutputPhaseNumEntry}->{$oid_upsmgOutputPhaseNumEntry . '.0'}) || + $self->{results}->{$oid_upsmgOutputPhaseNumEntry}->{$oid_upsmgOutputPhaseNumEntry . '.0'} == 0) { + $self->{output}->add_option_msg(short_msg => "No output lines found."); + $self->{output}->option_exit(); + } + + my %instances = (); + # can be 'xxx.1' or 'xxx.1.0' (cannot respect MIB :) + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_mgoutputVoltageEntry}})) { + $oid =~ /^$oid_mgoutputVoltageEntry\.((\d+).*)/; + if (scalar(keys %instances) < $self->{results}->{$oid_upsmgOutputPhaseNumEntry}->{$oid_upsmgOutputPhaseNumEntry . '.0'}) { + $instances{$2} = 1; + $self->add_result(instance => $2, instance2 => $1, name => 'voltage', oid => $oid_mgoutputVoltageEntry, multiple => 0.1); + } + } + %instances = (); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_mgoutputCurrentEntry}})) { + $oid =~ /^$oid_mgoutputCurrentEntry\.((\d+).*)/; + if (scalar(keys %instances) < $self->{results}->{$oid_upsmgOutputPhaseNumEntry}->{$oid_upsmgOutputPhaseNumEntry . '.0'}) { + $instances{$2} = 1; + $self->add_result(instance => $2, instance2 => $1, name => 'current', oid => $oid_mgoutputCurrentEntry, multiple => 0.1); + } + } + %instances = (); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_mgoutputFrequencyEntry}})) { + $oid =~ /^$oid_mgoutputFrequencyEntry\.((\d+).*)/; + if (scalar(keys %instances) < $self->{results}->{$oid_upsmgOutputPhaseNumEntry}->{$oid_upsmgOutputPhaseNumEntry . '.0'}) { + $instances{$2} = 1; + $self->add_result(instance => $2, instance2 => $1, name => 'frequence', oid => $oid_mgoutputFrequencyEntry, multiple => 0.1); + } + } + + %instances = (); + # Calculate stdev + my $total = 0; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_mgoutputLoadPerPhaseEntry}})) { + $oid =~ /^$oid_mgoutputLoadPerPhaseEntry\.((\d+).*)/; + if (scalar(keys %instances) < $self->{results}->{$oid_upsmgOutputPhaseNumEntry}->{$oid_upsmgOutputPhaseNumEntry . '.0'}) { + $instances{$2} = $self->{results}->{$oid_mgoutputLoadPerPhaseEntry}->{$oid}; + $self->add_result(instance => $2, instance2 => $1, name => 'load', oid => $oid_mgoutputLoadPerPhaseEntry, multiple => 1); + $total += $self->{results}->{$oid_mgoutputLoadPerPhaseEntry}->{$oid}; + } + } + + my $mean = $total / $self->{results}->{$oid_upsmgOutputPhaseNumEntry}->{$oid_upsmgOutputPhaseNumEntry . '.0'}; + $total = 0; + foreach (keys %instances) { + $total += ($mean - $instances{$_}) ** 2; + } + $self->{stdev} = sqrt($total / $self->{results}->{$oid_upsmgOutputPhaseNumEntry}->{$oid_upsmgOutputPhaseNumEntry . '.0'}); + + if (scalar(keys %{$self->{instance_selected}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No output lines found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check Output lines metrics (load, voltage, current). + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'load', 'voltage', 'current', 'frequence', 'stdev-3phases'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'load', 'voltage', 'current', 'frequence', 'stdev-3phases'. + +=back + +=cut diff --git a/hardware/ups/mge/mode/outputsource.pm b/hardware/ups/mge/mode/outputsource.pm new file mode 100644 index 000000000..85f819449 --- /dev/null +++ b/hardware/ups/mge/mode/outputsource.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 hardware::ups::mge::mode::outputsource; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $oid_upsmgOutput = '.1.3.6.1.4.1.705.1.7'; +my $oid_upsmgOutputOnBatteryEntry = '.1.3.6.1.4.1.705.1.7.3'; + +my %map_output_status = ( + '.1.3.6.1.4.1.705.1.7.3.0' => 'OutputOnBattery', + '.1.3.6.1.4.1.705.1.7.4.0' => 'OutputOnByPass', + '.1.3.6.1.4.1.705.1.7.5.0' => 'OutputUnavailableByPass', + '.1.3.6.1.4.1.705.1.7.6.0' => 'OutputNoByPass', + '.1.3.6.1.4.1.705.1.7.7.0' => 'OutputUtilityOff', + '.1.3.6.1.4.1.705.1.7.8.0' => 'OutputOnBoost', + '.1.3.6.1.4.1.705.1.7.9.0' => 'OutputInverterOff', + '.1.3.6.1.4.1.705.1.7.10.0' => 'OutputOverLoad', + '.1.3.6.1.4.1.705.1.7.11.0' => 'OutputOverTemp', + '.1.3.6.1.4.1.705.1.7.12.0' => 'OutputOnBuck', +); + +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-status:s" => { name => 'filter_status', default => '^OutputInverterOff'}, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + my $result = $self->{snmp}->get_table(oid => $oid_upsmgOutput, start => $oid_upsmgOutputOnBatteryEntry, nothing_quit => 1); + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("Output status is ok")); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %map_output_status)) { + next if (defined($self->{option_results}->{filter_status}) && $self->{option_results}->{filter_status} ne '' && $map_output_status{$oid} =~ /$self->{option_results}->{filter_status}/); + if (defined($result->{$oid}) && $result->{$oid} == 1) { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Output status is '%s'", $map_output_status{$oid})); + } + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check output source status. + +=over 8 + +=item B<--filter-status> + +Filter on status. (can be a regexp) +Default: ^OutputInverterOff + +=back + +=cut diff --git a/hardware/ups/mge/plugin.pm b/hardware/ups/mge/plugin.pm new file mode 100644 index 000000000..b0a3119de --- /dev/null +++ b/hardware/ups/mge/plugin.pm @@ -0,0 +1,68 @@ +################################################################################ +# 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 : Stéphane Duret +# +#################################################################################### + +package hardware::ups::mge::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + # $options->{options} = options object + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'environment' => 'hardware::ups::mge::mode::environment', + 'input-lines' => 'hardware::ups::mge::mode::inputlines', + 'output-lines' => 'hardware::ups::mge::mode::outputlines', + 'output-source' => 'hardware::ups::mge::mode::outputsource', + 'battery-status' => 'hardware::ups::mge::mode::batterystatus', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check UPS MerlinGerin in SNMP. + +=cut diff --git a/hardware/ups/standard/rfc1628/mode/outputlines.pm b/hardware/ups/standard/rfc1628/mode/outputlines.pm index 4c261306d..c1b647587 100644 --- a/hardware/ups/standard/rfc1628/mode/outputlines.pm +++ b/hardware/ups/standard/rfc1628/mode/outputlines.pm @@ -164,7 +164,7 @@ sub stdev { $total = 0; foreach my $instance (keys %{$self->{instances_done}}) { next if ($self->{counters_value}->{$instance}->{load} == -1); # Not present - $total = ($mean - $self->{counters_value}->{$instance}->{load}) ** 2; + $total += ($mean - $self->{counters_value}->{$instance}->{load}) ** 2; } my $stdev = sqrt($total / $num_present); From c1fca792c5594777eabeb7dac769618b9097c477 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Wed, 17 Sep 2014 11:12:38 +0200 Subject: [PATCH 3/5] Fix #5818 --- os/linux/local/mode/paging.pm | 304 ++++++++++++++++++++++++++++++++++ os/linux/local/plugin.pm | 1 + 2 files changed, 305 insertions(+) create mode 100644 os/linux/local/mode/paging.pm diff --git a/os/linux/local/mode/paging.pm b/os/linux/local/mode/paging.pm new file mode 100644 index 000000000..7567162be --- /dev/null +++ b/os/linux/local/mode/paging.pm @@ -0,0 +1,304 @@ +################################################################################ +# 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 os::linux::local::mode::paging; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::statefile; +use centreon::plugins::values; + +my $maps_counters = { + pgpgin => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'pgpgin', diff => 1 }, + ], + output_template => 'pgpgin : %s %s/s', per_second => 1, output_change_bytes => 1, + perfdatas => [ + { value => 'pgpgin_per_second', label => 'pgpgin', template => '%d', + unit => 'B/s', min => 0 }, + ], + } + }, + pgpgout => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'pgpgout', diff => 1 }, + ], + output_template => 'pgpgout : %s %s/s', per_second => 1, output_change_bytes => 1, + perfdatas => [ + { value => 'pgpgout_per_second', label => 'pgpgout', template => '%d', + unit => 'B/s', min => 0 }, + ], + } + }, + pswpin => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'pswpin', diff => 1 }, + ], + output_template => 'pswpin : %s %s/s', per_second => 1, output_change_bytes => 1, + perfdatas => [ + { value => 'pswpin_per_second', label => 'pswpin', template => '%d', + unit => 'B/s', min => 0 }, + ], + } + }, + pswpout => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'pswpout', diff => 1 }, + ], + output_template => 'pswpout : %s %s/s', per_second => 1, output_change_bytes => 1, + perfdatas => [ + { value => 'pswpout_per_second', label => 'pswpout', template => '%d', + unit => 'B/s', min => 0 }, + ], + } + }, + pgfault => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'pgfault', diff => 1 }, + ], + output_template => 'pgfault : %s %s/s', per_second => 1, output_change_bytes => 1, + perfdatas => [ + { value => 'pgfault_per_second', label => 'pgfault', template => '%d', + unit => 'B/s', min => 0 }, + ], + } + }, + pgmajfault => { class => 'centreon::plugins::values', obj => undef, + set => { + key_values => [ + { name => 'pgmajfault', diff => 1 }, + ], + output_template => 'pgmajfault : %s %s/s', per_second => 1, output_change_bytes => 1, + perfdatas => [ + { value => 'pgmajfault_per_second', label => 'pgmajfault', template => '%d', + unit => 'B/s', min => 0 }, + ], + } + }, +}; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "hostname:s" => { name => 'hostname' }, + "remote" => { name => 'remote' }, + "ssh-option:s@" => { name => 'ssh_option' }, + "ssh-path:s" => { name => 'ssh_path' }, + "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "sudo" => { name => 'sudo' }, + "command:s" => { name => 'command', default => 'cat' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '/proc/vmstat 2>&1' }, + }); + + $self->{statefile_value} = centreon::plugins::statefile->new(%options); + + 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}); + } + + $self->{statefile_value}->check_options(%options); + $self->{hostname} = $self->{option_results}->{hostname}; + if (!defined($self->{hostname})) { + $self->{hostname} = 'me'; + } +} + +sub run { + my ($self, %options) = @_; + + $self->{stdout} = centreon::plugins::misc::execute(output => $self->{output}, + options => $self->{option_results}, + sudo => $self->{option_results}->{sudo}, + command => $self->{option_results}->{command}, + command_path => $self->{option_results}->{command_path}, + command_options => $self->{option_results}->{command_options}); + $self->manage_selection(); + + $self->{new_datas} = {}; + $self->{statefile_value}->read(statefile => "cache_linux_local_" . $self->{hostname} . '_' . $self->{mode}); + $self->{new_datas}->{last_timestamp} = time(); + + my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); + my @exits; + foreach (sort keys %{$maps_counters}) { + $maps_counters->{$_}->{obj}->set(instance => 'paging'); + + my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{paging}, + new_datas => $self->{new_datas}); + + 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(); + } + + 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 => "Paging $short_msg" + ); + } else { + $self->{output}->output_add(short_msg => "Paging $long_msg"); + } + + $self->{statefile_value}->write(data => $self->{new_datas}); + $self->{output}->display(); + $self->{output}->exit(); +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{paging} = {}; + $self->{paging}->{pgpgin} = $self->{stdout} =~ /^pgpgin.*?(\d+)/msi ? $1 * 1024 : undef; + $self->{paging}->{pgpgout} = $self->{stdout} =~ /^pgpgout.*?(\d+)/msi ? $1 * 1024 : undef; + $self->{paging}->{pswpin} = $self->{stdout} =~ /^pswpin.*?(\d+)/msi ? $1 * 1024 : undef; + $self->{paging}->{pswpout} = $self->{stdout} =~ /^pswpout.*?(\d+)/msi ? $1 * 1024: undef; + $self->{paging}->{pgfault} = $self->{stdout} =~ /^pgfault.*?(\d+)/msi ? $1 * 1024: undef; + $self->{paging}->{pgmajfault} = $self->{stdout} =~ /^pgmajfault.*?(\d+)/msi ? $1 * 1014: undef; +} + +1; + +__END__ + +=head1 MODE + +Check paging informations. + +=over 8 + +=item B<--remote> + +Execute command remotely in 'ssh'. + +=item B<--hostname> + +Hostname to query (need --remote). + +=item B<--ssh-option> + +Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). + +=item B<--ssh-path> + +Specify ssh command path (default: none) + +=item B<--ssh-command> + +Specify ssh command (default: 'ssh'). Useful to use 'plink'. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information (Default: 'cat'). +Can be changed if you have output in a file. + +=item B<--command-path> + +Command path (Default: none). + +=item B<--command-options> + +Command options (Default: '/proc/vmstat 2>&1'). + +=item B<--warning-*> + +Threshold warning. +Can be: 'pgpgin', 'pgpgout', 'pswpin', 'pswpout', 'pgfault', 'pgmajfault'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'pgpgin', 'pgpgout', 'pswpin', 'pswpout', 'pgfault', 'pgmajfault'. + +=back + +=cut diff --git a/os/linux/local/plugin.pm b/os/linux/local/plugin.pm index c6484799c..a66614693 100644 --- a/os/linux/local/plugin.pm +++ b/os/linux/local/plugin.pm @@ -61,6 +61,7 @@ sub new { 'list-storages' => 'os::linux::local::mode::liststorages', 'memory' => 'os::linux::local::mode::memory', 'packet-errors' => 'os::linux::local::mode::packeterrors', + 'paging' => 'os::linux::local::mode::paging', 'process' => 'os::linux::local::mode::process', 'storage' => 'os::linux::local::mode::storage', 'swap' => 'os::linux::local::mode::swap', From e63ca9f690f1199c9347f9e93ad05fbf8eec4ce8 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Wed, 17 Sep 2014 16:39:29 +0200 Subject: [PATCH 4/5] + Change alteon directory (in radware) --- network/{ => radware}/alteon/5224/plugin.pm | 8 ++++---- network/{ => radware}/alteon/common/mode/cpu.pm | 2 +- network/{ => radware}/alteon/common/mode/hardware.pm | 2 +- network/{ => radware}/alteon/common/mode/memory.pm | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) rename network/{ => radware}/alteon/5224/plugin.pm (88%) rename network/{ => radware}/alteon/common/mode/cpu.pm (99%) rename network/{ => radware}/alteon/common/mode/hardware.pm (99%) rename network/{ => radware}/alteon/common/mode/memory.pm (98%) diff --git a/network/alteon/5224/plugin.pm b/network/radware/alteon/5224/plugin.pm similarity index 88% rename from network/alteon/5224/plugin.pm rename to network/radware/alteon/5224/plugin.pm index 03dc16f9c..63433512d 100644 --- a/network/alteon/5224/plugin.pm +++ b/network/radware/alteon/5224/plugin.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::alteon::5224::plugin; +package network::radware::alteon::5224::plugin; use strict; use warnings; @@ -47,9 +47,9 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'cpu' => 'network::alteon::common::mode::cpu', - 'hardware' => 'network::alteon::common::mode::hardware', - 'memory' => 'network::alteon::common::mode::memory', + 'cpu' => 'network::radware::alteon::common::mode::cpu', + 'hardware' => 'network::radware::alteon::common::mode::hardware', + 'memory' => 'network::radware::alteon::common::mode::memory', ); return $self; diff --git a/network/alteon/common/mode/cpu.pm b/network/radware/alteon/common/mode/cpu.pm similarity index 99% rename from network/alteon/common/mode/cpu.pm rename to network/radware/alteon/common/mode/cpu.pm index 3e87f66c6..f0b0b01f2 100644 --- a/network/alteon/common/mode/cpu.pm +++ b/network/radware/alteon/common/mode/cpu.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::alteon::common::mode::cpu; +package network::radware::alteon::common::mode::cpu; use base qw(centreon::plugins::mode); diff --git a/network/alteon/common/mode/hardware.pm b/network/radware/alteon/common/mode/hardware.pm similarity index 99% rename from network/alteon/common/mode/hardware.pm rename to network/radware/alteon/common/mode/hardware.pm index 0908ca5cf..1b3f98086 100644 --- a/network/alteon/common/mode/hardware.pm +++ b/network/radware/alteon/common/mode/hardware.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::alteon::common::mode::hardware; +package network::radware::alteon::common::mode::hardware; use base qw(centreon::plugins::mode); diff --git a/network/alteon/common/mode/memory.pm b/network/radware/alteon/common/mode/memory.pm similarity index 98% rename from network/alteon/common/mode/memory.pm rename to network/radware/alteon/common/mode/memory.pm index 9452a05d5..b5adb471d 100644 --- a/network/alteon/common/mode/memory.pm +++ b/network/radware/alteon/common/mode/memory.pm @@ -33,7 +33,7 @@ # #################################################################################### -package network::alteon::common::mode::memory; +package network::radware::alteon::common::mode::memory; use base qw(centreon::plugins::mode); From 3bd72cc0ea32c119354a250431ea6295542b055c Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Thu, 18 Sep 2014 15:40:06 +0200 Subject: [PATCH 5/5] Refs #5425 Put in special for common now (like that we can do for vnx ;) --- .../common/emc/navisphere/custom}/custom.pm | 10 ++-- .../common/emc/navisphere}/mode/cache.pm | 2 +- .../common/emc/navisphere}/mode/controller.pm | 2 +- .../common/emc/navisphere}/mode/disk.pm | 2 +- .../common/emc/navisphere}/mode/faults.pm | 2 +- .../common/emc/navisphere}/mode/hbastate.pm | 2 +- .../common/emc/navisphere}/mode/listluns.pm | 2 +- .../common/emc/navisphere}/mode/portstate.pm | 2 +- .../common/emc/navisphere}/mode/sp.pm | 56 +++++++++---------- .../navisphere}/mode/spcomponents/battery.pm | 0 .../navisphere}/mode/spcomponents/cable.pm | 0 .../emc/navisphere}/mode/spcomponents/cpu.pm | 0 .../emc/navisphere}/mode/spcomponents/fan.pm | 0 .../navisphere}/mode/spcomponents/iomodule.pm | 0 .../emc/navisphere}/mode/spcomponents/lcc.pm | 0 .../navisphere}/mode/spcomponents/memory.pm | 0 .../emc/navisphere}/mode/spcomponents/psu.pm | 0 .../emc/navisphere}/mode/spcomponents/sp.pm | 0 .../common/emc/navisphere}/mode/spinfo.pm | 2 +- storage/emc/clariion/plugin.pm | 20 +++---- 20 files changed, 51 insertions(+), 51 deletions(-) rename {storage/emc/clariion => centreon/common/emc/navisphere/custom}/custom.pm (98%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/cache.pm (99%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/controller.pm (99%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/disk.pm (99%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/faults.pm (98%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/hbastate.pm (99%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/listluns.pm (99%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/portstate.pm (98%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/sp.pm (76%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/spcomponents/battery.pm (100%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/spcomponents/cable.pm (100%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/spcomponents/cpu.pm (100%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/spcomponents/fan.pm (100%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/spcomponents/iomodule.pm (100%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/spcomponents/lcc.pm (100%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/spcomponents/memory.pm (100%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/spcomponents/psu.pm (100%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/spcomponents/sp.pm (100%) rename {storage/emc/clariion => centreon/common/emc/navisphere}/mode/spinfo.pm (98%) diff --git a/storage/emc/clariion/custom.pm b/centreon/common/emc/navisphere/custom/custom.pm similarity index 98% rename from storage/emc/clariion/custom.pm rename to centreon/common/emc/navisphere/custom/custom.pm index 5201e59a8..9d8814a24 100644 --- a/storage/emc/clariion/custom.pm +++ b/centreon/common/emc/navisphere/custom/custom.pm @@ -33,7 +33,7 @@ # #################################################################################### -package storage::emc::clariion::custom; +package centreon::common::emc::navisphere::custom::custom; use strict; use warnings; @@ -74,7 +74,7 @@ sub new { "timeout:s@" => { name => 'timeout' }, }); } - $options{options}->add_help(package => __PACKAGE__, sections => 'CLARIION OPTIONS', once => 1); + $options{options}->add_help(package => __PACKAGE__, sections => 'NAVISPHERE OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; @@ -221,13 +221,13 @@ __END__ =head1 NAME -Clariion +Navisphere =head1 SYNOPSIS my navisphere manage -=head1 CLARIION OPTIONS +=head1 NAVISPHERE OPTIONS =over 8 @@ -258,7 +258,7 @@ To be used for set a file. (Need to change command and use 'cat' instead). =item B<--hostname> -Emc Clariion SP Hostname. +Emc Clariion/VNX SP Hostname. =item B<--secfilepath> diff --git a/storage/emc/clariion/mode/cache.pm b/centreon/common/emc/navisphere/mode/cache.pm similarity index 99% rename from storage/emc/clariion/mode/cache.pm rename to centreon/common/emc/navisphere/mode/cache.pm index 16b439ad4..3ea2d8e5c 100644 --- a/storage/emc/clariion/mode/cache.pm +++ b/centreon/common/emc/navisphere/mode/cache.pm @@ -33,7 +33,7 @@ # #################################################################################### -package storage::emc::clariion::mode::cache; +package centreon::common::emc::navisphere::mode::cache; use base qw(centreon::plugins::mode); diff --git a/storage/emc/clariion/mode/controller.pm b/centreon/common/emc/navisphere/mode/controller.pm similarity index 99% rename from storage/emc/clariion/mode/controller.pm rename to centreon/common/emc/navisphere/mode/controller.pm index 05412a080..25a5552a3 100644 --- a/storage/emc/clariion/mode/controller.pm +++ b/centreon/common/emc/navisphere/mode/controller.pm @@ -33,7 +33,7 @@ # #################################################################################### -package storage::emc::clariion::mode::controller; +package centreon::common::emc::navisphere::mode::controller; use base qw(centreon::plugins::mode); diff --git a/storage/emc/clariion/mode/disk.pm b/centreon/common/emc/navisphere/mode/disk.pm similarity index 99% rename from storage/emc/clariion/mode/disk.pm rename to centreon/common/emc/navisphere/mode/disk.pm index d33e2f86a..a0cdf4385 100644 --- a/storage/emc/clariion/mode/disk.pm +++ b/centreon/common/emc/navisphere/mode/disk.pm @@ -33,7 +33,7 @@ # #################################################################################### -package storage::emc::clariion::mode::disk; +package centreon::common::emc::navisphere::mode::disk; sub get_absolute { my ($self, %options) = @_; diff --git a/storage/emc/clariion/mode/faults.pm b/centreon/common/emc/navisphere/mode/faults.pm similarity index 98% rename from storage/emc/clariion/mode/faults.pm rename to centreon/common/emc/navisphere/mode/faults.pm index afbfa6629..a2c051f2a 100644 --- a/storage/emc/clariion/mode/faults.pm +++ b/centreon/common/emc/navisphere/mode/faults.pm @@ -33,7 +33,7 @@ # #################################################################################### -package storage::emc::clariion::mode::faults; +package centreon::common::emc::navisphere::mode::faults; use base qw(centreon::plugins::mode); diff --git a/storage/emc/clariion/mode/hbastate.pm b/centreon/common/emc/navisphere/mode/hbastate.pm similarity index 99% rename from storage/emc/clariion/mode/hbastate.pm rename to centreon/common/emc/navisphere/mode/hbastate.pm index 2db07b53b..76a213192 100644 --- a/storage/emc/clariion/mode/hbastate.pm +++ b/centreon/common/emc/navisphere/mode/hbastate.pm @@ -33,7 +33,7 @@ # #################################################################################### -package storage::emc::clariion::mode::hbastate; +package centreon::common::emc::navisphere::mode::hbastate; use base qw(centreon::plugins::mode); diff --git a/storage/emc/clariion/mode/listluns.pm b/centreon/common/emc/navisphere/mode/listluns.pm similarity index 99% rename from storage/emc/clariion/mode/listluns.pm rename to centreon/common/emc/navisphere/mode/listluns.pm index cdaa890df..ac3ae3482 100644 --- a/storage/emc/clariion/mode/listluns.pm +++ b/centreon/common/emc/navisphere/mode/listluns.pm @@ -35,7 +35,7 @@ # Based on Apache Mode by Simon BOMM #################################################################################### -package storage::emc::clariion::mode::listluns; +package centreon::common::emc::navisphere::mode::listluns; use base qw(centreon::plugins::mode); diff --git a/storage/emc/clariion/mode/portstate.pm b/centreon/common/emc/navisphere/mode/portstate.pm similarity index 98% rename from storage/emc/clariion/mode/portstate.pm rename to centreon/common/emc/navisphere/mode/portstate.pm index 13872a56d..56ad8471a 100644 --- a/storage/emc/clariion/mode/portstate.pm +++ b/centreon/common/emc/navisphere/mode/portstate.pm @@ -33,7 +33,7 @@ # #################################################################################### -package storage::emc::clariion::mode::portstate; +package centreon::common::emc::navisphere::mode::portstate; use base qw(centreon::plugins::mode); diff --git a/storage/emc/clariion/mode/sp.pm b/centreon/common/emc/navisphere/mode/sp.pm similarity index 76% rename from storage/emc/clariion/mode/sp.pm rename to centreon/common/emc/navisphere/mode/sp.pm index e7b24a691..624046524 100644 --- a/storage/emc/clariion/mode/sp.pm +++ b/centreon/common/emc/navisphere/mode/sp.pm @@ -33,21 +33,21 @@ # #################################################################################### -package storage::emc::clariion::mode::sp; +package centreon::common::emc::navisphere::mode::sp; use base qw(centreon::plugins::mode); use strict; use warnings; -use storage::emc::clariion::mode::spcomponents::fan; -use storage::emc::clariion::mode::spcomponents::lcc; -use storage::emc::clariion::mode::spcomponents::psu; -use storage::emc::clariion::mode::spcomponents::battery; -use storage::emc::clariion::mode::spcomponents::memory; -use storage::emc::clariion::mode::spcomponents::cpu; -use storage::emc::clariion::mode::spcomponents::iomodule; -use storage::emc::clariion::mode::spcomponents::cable; -use storage::emc::clariion::mode::spcomponents::sp; +use centreon::common::emc::navisphere::mode::spcomponents::fan; +use centreon::common::emc::navisphere::mode::spcomponents::lcc; +use centreon::common::emc::navisphere::mode::spcomponents::psu; +use centreon::common::emc::navisphere::spcomponents::battery; +use centreon::common::emc::navisphere::spcomponents::memory; +use centreon::common::emc::navisphere::spcomponents::cpu; +use centreon::common::emc::navisphere::spcomponents::iomodule; +use centreon::common::emc::navisphere::spcomponents::cable; +use centreon::common::emc::navisphere::spcomponents::sp; sub new { my ($class, %options) = @_; @@ -86,33 +86,33 @@ sub component { my ($self, %options) = @_; if ($self->{option_results}->{component} eq 'all') { - storage::emc::clariion::mode::spcomponents::fan::check($self); - storage::emc::clariion::mode::spcomponents::lcc::check($self); - storage::emc::clariion::mode::spcomponents::psu::check($self); - storage::emc::clariion::mode::spcomponents::battery::check($self); - storage::emc::clariion::mode::spcomponents::cable::check($self); - storage::emc::clariion::mode::spcomponents::iomodule::check($self); - storage::emc::clariion::mode::spcomponents::memory::check($self); - storage::emc::clariion::mode::spcomponents::cpu::check($self); - storage::emc::clariion::mode::spcomponents::sp::check($self); + centreon::common::emc::navisphere::mode::spcomponents::fan::check($self); + centreon::common::emc::navisphere::mode::spcomponents::lcc::check($self); + centreon::common::emc::navisphere::mode::spcomponents::psu::check($self); + centreon::common::emc::navisphere::mode::spcomponents::battery::check($self); + centreon::common::emc::navisphere::mode::spcomponents::cable::check($self); + centreon::common::emc::navisphere::mode::spcomponents::iomodule::check($self); + centreon::common::emc::navisphere::mode::spcomponents::memory::check($self); + centreon::common::emc::navisphere::mode::spcomponents::cpu::check($self); + centreon::common::emc::navisphere::mode::spcomponents::sp::check($self); } elsif ($self->{option_results}->{component} eq 'sp') { - storage::emc::clariion::mode::spcomponents::sp::check($self); + centreon::common::emc::navisphere::mode::spcomponents::sp::check($self); } elsif ($self->{option_results}->{component} eq 'fan') { - storage::emc::clariion::mode::spcomponents::fan::check($self); + centreon::common::emc::navisphere::mode::spcomponents::fan::check($self); } elsif ($self->{option_results}->{component} eq 'lcc') { - storage::emc::clariion::mode::spcomponents::lcc::check($self); + centreon::common::emc::navisphere::mode::spcomponents::lcc::check($self); } elsif ($self->{option_results}->{component} eq 'psu') { - storage::emc::clariion::mode::spcomponents::psu::check($self); + centreon::common::emc::navisphere::mode::spcomponents::psu::check($self); } elsif ($self->{option_results}->{component} eq 'battery') { - storage::emc::clariion::mode::spcomponents::psu::check($self); + centreon::common::emc::navisphere::mode::spcomponents::psu::check($self); } elsif ($self->{option_results}->{component} eq 'memory') { - storage::emc::clariion::mode::spcomponents::memory::check($self); + centreon::common::emc::navisphere::mode::spcomponents::memory::check($self); } elsif ($self->{option_results}->{component} eq 'cpu') { - storage::emc::clariion::mode::spcomponents::cpu::check($self); + centreon::common::emc::navisphere::mode::spcomponents::cpu::check($self); } elsif ($self->{option_results}->{component} eq 'io') { - storage::emc::clariion::mode::spcomponents::iomodule::check($self); + centreon::common::emc::navisphere::mode::spcomponents::iomodule::check($self); } elsif ($self->{option_results}->{component} eq 'cable') { - storage::emc::clariion::mode::spcomponents::cable::check($self); + centreon::common::emc::navisphere::mode::spcomponents::cable::check($self); } else { $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); $self->{output}->option_exit(); diff --git a/storage/emc/clariion/mode/spcomponents/battery.pm b/centreon/common/emc/navisphere/mode/spcomponents/battery.pm similarity index 100% rename from storage/emc/clariion/mode/spcomponents/battery.pm rename to centreon/common/emc/navisphere/mode/spcomponents/battery.pm diff --git a/storage/emc/clariion/mode/spcomponents/cable.pm b/centreon/common/emc/navisphere/mode/spcomponents/cable.pm similarity index 100% rename from storage/emc/clariion/mode/spcomponents/cable.pm rename to centreon/common/emc/navisphere/mode/spcomponents/cable.pm diff --git a/storage/emc/clariion/mode/spcomponents/cpu.pm b/centreon/common/emc/navisphere/mode/spcomponents/cpu.pm similarity index 100% rename from storage/emc/clariion/mode/spcomponents/cpu.pm rename to centreon/common/emc/navisphere/mode/spcomponents/cpu.pm diff --git a/storage/emc/clariion/mode/spcomponents/fan.pm b/centreon/common/emc/navisphere/mode/spcomponents/fan.pm similarity index 100% rename from storage/emc/clariion/mode/spcomponents/fan.pm rename to centreon/common/emc/navisphere/mode/spcomponents/fan.pm diff --git a/storage/emc/clariion/mode/spcomponents/iomodule.pm b/centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm similarity index 100% rename from storage/emc/clariion/mode/spcomponents/iomodule.pm rename to centreon/common/emc/navisphere/mode/spcomponents/iomodule.pm diff --git a/storage/emc/clariion/mode/spcomponents/lcc.pm b/centreon/common/emc/navisphere/mode/spcomponents/lcc.pm similarity index 100% rename from storage/emc/clariion/mode/spcomponents/lcc.pm rename to centreon/common/emc/navisphere/mode/spcomponents/lcc.pm diff --git a/storage/emc/clariion/mode/spcomponents/memory.pm b/centreon/common/emc/navisphere/mode/spcomponents/memory.pm similarity index 100% rename from storage/emc/clariion/mode/spcomponents/memory.pm rename to centreon/common/emc/navisphere/mode/spcomponents/memory.pm diff --git a/storage/emc/clariion/mode/spcomponents/psu.pm b/centreon/common/emc/navisphere/mode/spcomponents/psu.pm similarity index 100% rename from storage/emc/clariion/mode/spcomponents/psu.pm rename to centreon/common/emc/navisphere/mode/spcomponents/psu.pm diff --git a/storage/emc/clariion/mode/spcomponents/sp.pm b/centreon/common/emc/navisphere/mode/spcomponents/sp.pm similarity index 100% rename from storage/emc/clariion/mode/spcomponents/sp.pm rename to centreon/common/emc/navisphere/mode/spcomponents/sp.pm diff --git a/storage/emc/clariion/mode/spinfo.pm b/centreon/common/emc/navisphere/mode/spinfo.pm similarity index 98% rename from storage/emc/clariion/mode/spinfo.pm rename to centreon/common/emc/navisphere/mode/spinfo.pm index 5ea2cf3f7..c869a130f 100644 --- a/storage/emc/clariion/mode/spinfo.pm +++ b/centreon/common/emc/navisphere/mode/spinfo.pm @@ -33,7 +33,7 @@ # #################################################################################### -package storage::emc::clariion::mode::spinfo; +package centreon::common::emc::navisphere::mode::spinfo; use base qw(centreon::plugins::mode); diff --git a/storage/emc/clariion/plugin.pm b/storage/emc/clariion/plugin.pm index b681ed055..b41cbeed2 100644 --- a/storage/emc/clariion/plugin.pm +++ b/storage/emc/clariion/plugin.pm @@ -48,17 +48,17 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'cache' => 'storage::emc::clariion::mode::cache', - 'controller' => 'storage::emc::clariion::mode::controller', - 'disk' => 'storage::emc::clariion::mode::disk', - 'sp' => 'storage::emc::clariion::mode::sp', - 'faults' => 'storage::emc::clariion::mode::faults', - 'list-luns' => 'storage::emc::clariion::mode::listluns', - 'sp-info' => 'storage::emc::clariion::mode::spinfo', - 'port-state' => 'storage::emc::clariion::mode::portstate', - 'hba-state' => 'storage::emc::clariion::mode::hbastate', + 'cache' => 'centreon::common::emc::navisphere::mode::cache', + 'controller' => 'centreon::common::emc::navisphere::mode::controller', + 'disk' => 'centreon::common::emc::navisphere::mode::disk', + 'sp' => 'centreon::common::emc::navisphere::mode::sp', + 'faults' => 'centreon::common::emc::navisphere::mode::faults', + 'list-luns' => 'centreon::common::emc::navisphere::mode::listluns', + 'sp-info' => 'centreon::common::emc::navisphere::mode::spinfo', + 'port-state' => 'centreon::common::emc::navisphere::mode::portstate', + 'hba-state' => 'centreon::common::emc::navisphere::mode::hbastate', ); - $self->{custom_modes}{clariion} = 'storage::emc::clariion::custom'; + $self->{custom_modes}{clariion} = 'centreon::common::emc::navisphere::custom::custom'; return $self; }