From 4e939f95969aea105a9437dfea3f7cbb075fb51a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Apr 2014 10:20:02 +0200 Subject: [PATCH 1/8] correction databasessize.pm --- database/mysql/mode/databasessize.pm | 138 --------------------------- 1 file changed, 138 deletions(-) delete mode 100644 database/mysql/mode/databasessize.pm diff --git a/database/mysql/mode/databasessize.pm b/database/mysql/mode/databasessize.pm deleted file mode 100644 index b218222c7..000000000 --- a/database/mysql/mode/databasessize.pm +++ /dev/null @@ -1,138 +0,0 @@ -################################################################################ -# Copyright 2005-2013 MERETHIS -# Centreon is developped by : Julien Mathis and Romain Le Merlus under -# GPL Licence 2.0. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation ; either version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, see . -# -# Linking this program statically or dynamically with other modules is making a -# combined work based on this program. Thus, the terms and conditions of the GNU -# General Public License cover the whole combination. -# -# As a special exception, the copyright holders of this program give MERETHIS -# permission to link this program with independent modules to produce an executable, -# regardless of the license terms of these independent modules, and to copy and -# distribute the resulting executable under terms of MERETHIS choice, provided that -# MERETHIS also meet, for each linked independent module, the terms and conditions -# of the license of that module. An independent module is a module which is not -# derived from this program. If you modify this program, you may extend this -# exception to your version of the program, but you are not obliged to do so. If you -# do not wish to do so, delete this exception statement from your version. -# -# For more information : contact@centreon.com -# Authors : Quentin Garnier -# -#################################################################################### - -package database::mysql::mode::databasessize; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', }, - "filter:s" => { name => 'filter', }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning})) . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { - my ($self, %options) = @_; - # $options{sql} = sqlmode object - $self->{sql} = $options{sql}; - - $self->{sql}->connect(); - $self->{sql}->query(query => 'SELECT table_schema AS NAME, SUM(data_length+index_length) - FROM information_schema.tables - GROUP BY table_schema'); - my $result = $self->{sql}->fetchall_arrayref(); - - if (!($self->{sql}->is_version_minimum(version => '5'))) { - $self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported."); - $self->{output}->option_exit(); - } - - $self->{output}->output_add(severity => 'OK', - short_msg => "All databases are ok."); - foreach my $row (@$result) { - next if (defined($self->{option_results}->{filter}) && - $$row[0] !~ /$self->{option_results}->{filter}/); - - my $exit_code = $self->{perfdata}->threshold_check(value => $$row[1], threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - - my ($value, $value_unit) = $self->{perfdata}->change_bytes(value => $$row[1]); - $self->{output}->output_add(long_msg => sprintf("DB '" . $$row[0] . "' size: %.3f%s", $value, $value_unit)); - if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("DB '" . $$row[0] . "' size: %.3f%s", $value, $value_unit)); - } - $self->{output}->perfdata_add(label => $$row[0] . '_size', - value => $$row[1], - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0); - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check MySQL databases size. - -=over 8 - -=item B<--warning> - -Threshold warning in bytes. - -=item B<--critical> - -Threshold critical in bytes. - -=item B<--filter> - -Filter database to checks. - -=back - -=cut From fae7ed18539153bcb5f62b9c6a2f905068ecd171 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Apr 2014 10:23:34 +0200 Subject: [PATCH 2/8] correction databasessize.pm --- database/mysql/mode/databasessize.pm | 138 +++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 database/mysql/mode/databasessize.pm diff --git a/database/mysql/mode/databasessize.pm b/database/mysql/mode/databasessize.pm new file mode 100644 index 000000000..50fad0583 --- /dev/null +++ b/database/mysql/mode/databasessize.pm @@ -0,0 +1,138 @@ +################################################################################ +# 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 database::mysql::mode::databasessize; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning', }, + "critical:s" => { name => 'critical', }, + "filter:s" => { name => 'filter', }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } +} + +sub run { + my ($self, %options) = @_; + # $options{sql} = sqlmode object + $self->{sql} = $options{sql}; + + $self->{sql}->connect(); + $self->{sql}->query(query => 'SELECT table_schema AS NAME, SUM(data_length+index_length) + FROM information_schema.tables + GROUP BY table_schema'); + my $result = $self->{sql}->fetchall_arrayref(); + + if (!($self->{sql}->is_version_minimum(version => '5'))) { + $self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported."); + $self->{output}->option_exit(); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => "All databases are ok."); + foreach my $row (@$result) { + next if (defined($self->{option_results}->{filter}) && + $$row[0] !~ /$self->{option_results}->{filter}/); + + my $exit_code = $self->{perfdata}->threshold_check(value => $$row[1], threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + + my ($value, $value_unit) = $self->{perfdata}->change_bytes(value => $$row[1]); + $self->{output}->output_add(long_msg => sprintf("DB '" . $$row[0] . "' size: %.3f%s", $value, $value_unit)); + if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit_code, + short_msg => sprintf("DB '" . $$row[0] . "' size: %.3f%s", $value, $value_unit)); + } + $self->{output}->perfdata_add(label => $$row[0] . '_size', + value => $$row[1], + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => 0); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check MySQL databases size. + +=over 8 + +=item B<--warning> + +Threshold warning in bytes. + +=item B<--critical> + +Threshold critical in bytes. + +=item B<--filter> + +Filter database to checks. + +=back + +=cut From a5bef3a1bc6d926d28cdc439bfe54dbfa8ac4255 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Jul 2014 14:04:40 +0200 Subject: [PATCH 3/8] =?UTF-8?q?refs=20#5601=20modification=20li=C3=A9es=20?= =?UTF-8?q?au=20ticket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/screenos/mode/components/fan.pm | 2 +- .../common/screenos/mode/components/module.pm | 6 +- .../common/screenos/mode/components/psu.pm | 2 +- .../screenos/mode/components/temperature.pm | 19 +++--- .../juniper/common/screenos/mode/hardware.pm | 64 ++++--------------- 5 files changed, 25 insertions(+), 68 deletions(-) diff --git a/network/juniper/common/screenos/mode/components/fan.pm b/network/juniper/common/screenos/mode/components/fan.pm index 75f8782b4..422af6721 100644 --- a/network/juniper/common/screenos/mode/components/fan.pm +++ b/network/juniper/common/screenos/mode/components/fan.pm @@ -46,7 +46,7 @@ my %map_status = ( sub check { my ($self) = @_; - $self->{components}->{fans} = {name => 'fans', total => 0, skip => 0}; + $self->{components}->{fans} = {name => 'fans', total => 0}; $self->{output}->output_add(long_msg => "Checking fans"); return if ($self->check_exclude(section => 'fans')); diff --git a/network/juniper/common/screenos/mode/components/module.pm b/network/juniper/common/screenos/mode/components/module.pm index 97ef5a02a..9ec423137 100644 --- a/network/juniper/common/screenos/mode/components/module.pm +++ b/network/juniper/common/screenos/mode/components/module.pm @@ -46,7 +46,7 @@ my %map_status = ( sub check { my ($self) = @_; - $self->{components}->{modules} = {name => 'modules', total => 0, skip => 0}; + $self->{components}->{modules} = {name => 'modules', total => 0}; $self->{output}->output_add(long_msg => "Checking modules"); return if ($self->check_exclude(section => 'modules')); @@ -62,11 +62,11 @@ sub check { my $instance = $1; next if ($self->check_exclude(section => 'modules', instance => $instance)); - $self->{components}->{modules}->{total}++; my $type = $result->{$oid_nsSlotType . '.' . $instance}; my $status = $result->{$oid_nsSlotStatus . '.' . $instance}; - + + $self->{components}->{modules}->{total}++; $self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s].", $type, $map_status{$status}, $instance)); if ($status != 1) { diff --git a/network/juniper/common/screenos/mode/components/psu.pm b/network/juniper/common/screenos/mode/components/psu.pm index 766215e0d..d1c4985ec 100644 --- a/network/juniper/common/screenos/mode/components/psu.pm +++ b/network/juniper/common/screenos/mode/components/psu.pm @@ -46,7 +46,7 @@ my %map_status = ( sub check { my ($self) = @_; - $self->{components}->{psus} = {name => 'psus', total => 0, skip => 0}; + $self->{components}->{psus} = {name => 'psus', total => 0}; $self->{output}->output_add(long_msg => "Checking power supplies"); return if ($self->check_exclude(section => 'psus')); diff --git a/network/juniper/common/screenos/mode/components/temperature.pm b/network/juniper/common/screenos/mode/components/temperature.pm index 48e61e2b3..d9c5e501e 100644 --- a/network/juniper/common/screenos/mode/components/temperature.pm +++ b/network/juniper/common/screenos/mode/components/temperature.pm @@ -42,7 +42,7 @@ sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking temperatures"); - $self->{components}->{temperatures} = {name => 'temperatures', total => 0, skip => 0}; + $self->{components}->{temperatures} = {name => 'temperatures', total => 0}; return if ($self->check_exclude('temperatures')); my $oid_nsTemperatureEntry = '.1.3.6.1.4.1.3224.21.4.1'; @@ -58,10 +58,10 @@ sub check { next if ($self->check_exclude(section => 'temperatures', instance => $instance)); - my $temperature_name = $result->{$oid_nsTemperatureDesc . '.' . $instance}; + my $temperature_name = $result->{$oid_nsTemperatureDesc . '.' . $instance}; - my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_nsTemperatureCur . '.' . $instance}, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_nsTemperatureCur . '.' . $instance}, + threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{components}->{temperatures}->{total}++; @@ -71,13 +71,12 @@ sub check { $self->{output}->output_add(severity => $exit_code,short_msg => sprintf($temperature_name . " is %.2f C", $result->{$oid_nsTemperatureCur . '.' . $instance})); } - $temperature_name =~ s/\ /_/g; - $self->{output}->perfdata_add(label => $temperature_name, unit => 'C', - value => sprintf("%.2f", $result->{$oid_nsTemperatureCur . '.' . $instance}), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')); + $temperature_name =~ s/\ /_/g; + $self->{output}->perfdata_add(label => $temperature_name , unit => 'C', value => sprintf("%.2f", $result->{$oid_nsTemperatureCur . '.' . $instance}), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')); + } } -} 1; diff --git a/network/juniper/common/screenos/mode/hardware.pm b/network/juniper/common/screenos/mode/hardware.pm index afe36a89e..963def039 100644 --- a/network/juniper/common/screenos/mode/hardware.pm +++ b/network/juniper/common/screenos/mode/hardware.pm @@ -52,13 +52,11 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { + { "exclude:s" => { name => 'exclude' }, - "absent-problem:s" => { name => 'absent' }, "component:s" => { name => 'component', default => 'all' }, - "no-component:s" => { name => 'no_component' }, - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', }, + "warning:s" => { name => 'warning', default => '' }, + "critical:s" => { name => 'critical', default => '' }, }); $self->{components} = {}; return $self; @@ -76,13 +74,7 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); $self->{output}->option_exit(); } - if (defined($self->{option_results}->{no_component})) { - if ($self->{option_results}->{no_component} ne '') { - $self->{no_components} = $self->{option_results}->{no_component}; - } else { - $self->{no_components} = 'critical'; - } - } + } sub global { @@ -114,14 +106,15 @@ sub run { $self->{output}->option_exit(); } + my $total_components = 0; my $display_by_component = ''; my $display_by_component_append = ''; foreach my $comp (sort(keys %{$self->{components}})) { # Skipping short msg when no components - next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); - $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $self->{components}->{$comp}->{name}; + next if ($self->{components}->{$comp}->{total} == 0); + $total_components += $self->{components}->{$comp}->{total}; + $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $self->{components}->{$comp}->{name}; $display_by_component_append = ', '; } @@ -132,46 +125,20 @@ sub run { ) ); - if (defined($self->{option_results}->{no_component}) && $total_components == 0) { - $self->{output}->output_add(severity => $self->{no_components}, - short_msg => 'No components are checked.'); - } - $self->{output}->display(); $self->{output}->exit(); } sub check_exclude { - my ($self, %options) = @_; + my ($self, $section) = @_; - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); + if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$section(\s|,|$)/) { + $self->{output}->output_add(long_msg => sprintf("Skipping $section section.")); return 1; } return 0; } -sub absent_problem { - my ($self, %options) = @_; - - if (defined($self->{option_results}->{absent}) && - $self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Component '%s' instance '%s' is not present", - $options{section}, $options{instance})); - } - - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)")); - $self->{components}->{$options{section}}->{skip}++; - return 1; -} - 1; __END__ @@ -192,15 +159,6 @@ Can be: 'fan', 'psu', 'module'. Exclude some parts (comma seperated list) (Example: --exclude=fans,modules) Can also exclude specific instance: --exclude=fans#1#2#,modules#1#,psus -=item B<--absent-problem> - -N/A for following equipment. Not needed. - -=item B<--no-component> - -Return an error if no compenents are checked. -If total (with skipped) is 0. (Default: 'critical' returns). - =item B<--warning> Threshold warning in degree celsius. From d5aa529a2ba55d11e75ac9127a8014917e437d1c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Jul 2014 11:00:43 +0200 Subject: [PATCH 4/8] refs #5601 change thresholds name --- network/juniper/common/screenos/mode/cpu.pm | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/network/juniper/common/screenos/mode/cpu.pm b/network/juniper/common/screenos/mode/cpu.pm index 88f1b663b..1bb27cc30 100644 --- a/network/juniper/common/screenos/mode/cpu.pm +++ b/network/juniper/common/screenos/mode/cpu.pm @@ -59,31 +59,31 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - ($self->{warn1s}, $self->{warn4s}, $self->{warn64s}) = split /,/, $self->{option_results}->{warning}; - ($self->{crit1s}, $self->{crit4s}, $self->{crit64s}) = split /,/, $self->{option_results}->{critical}; + ($self->{warn1m}, $self->{warn5m}, $self->{warn15m}) = split /,/, $self->{option_results}->{warning}; + ($self->{crit1m}, $self->{crit5m}, $self->{crit15m}) = split /,/, $self->{option_results}->{critical}; - if (($self->{perfdata}->threshold_validate(label => 'warn1min', value => $self->{warn1s})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1s} . "'."); + if (($self->{perfdata}->threshold_validate(label => 'warn1min', value => $self->{warn1m})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1m} . "'."); $self->{output}->option_exit(); } - if (($self->{perfdata}->threshold_validate(label => 'warn5min', value => $self->{warn4s})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn4s} . "'."); + if (($self->{perfdata}->threshold_validate(label => 'warn5min', value => $self->{warn5m})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn5m} . "'."); $self->{output}->option_exit(); } - if (($self->{perfdata}->threshold_validate(label => 'warn15min', value => $self->{warn64s})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (15min) threshold '" . $self->{warn64s} . "'."); + if (($self->{perfdata}->threshold_validate(label => 'warn15min', value => $self->{warn15m})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning (15min) threshold '" . $self->{warn15m} . "'."); $self->{output}->option_exit(); } - if (($self->{perfdata}->threshold_validate(label => 'crit1min', value => $self->{crit1s})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1s} . "'."); + if (($self->{perfdata}->threshold_validate(label => 'crit1min', value => $self->{crit1m})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1m} . "'."); $self->{output}->option_exit(); } - if (($self->{perfdata}->threshold_validate(label => 'crit5min', value => $self->{crit4s})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit4s} . "'."); + if (($self->{perfdata}->threshold_validate(label => 'crit5min', value => $self->{crit5m})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit5m} . "'."); $self->{output}->option_exit(); } - if (($self->{perfdata}->threshold_validate(label => 'crit15min', value => $self->{crit64s})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (15min) threshold '" . $self->{crit64s} . "'."); + if (($self->{perfdata}->threshold_validate(label => 'crit15min', value => $self->{crit15m})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical (15min) threshold '" . $self->{crit15m} . "'."); $self->{output}->option_exit(); } } From 04c12898d8abe1d7559eaee06c2b9226606e92e2 Mon Sep 17 00:00:00 2001 From: Remi Werquin Date: Thu, 3 Jul 2014 16:16:16 +0200 Subject: [PATCH 5/8] Bug in pfsense plugins --- apps/pfsense/snmp/mode/blockedpackets.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/pfsense/snmp/mode/blockedpackets.pm b/apps/pfsense/snmp/mode/blockedpackets.pm index 15d92d0a6..232b203f7 100644 --- a/apps/pfsense/snmp/mode/blockedpackets.pm +++ b/apps/pfsense/snmp/mode/blockedpackets.pm @@ -211,7 +211,7 @@ sub run { sub manage_selection { my ($self, %options) = @_; - $all_ids = []; + my $all_ids = []; $self->{names} = {}; my $result = $self->{snmp}->get_table(oid => $oid_pfsenseInterfaceName, nothing_quit => 1); foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { From 69abfd42a09bc1934d25262be10ca9efa011c997 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Thu, 3 Jul 2014 17:17:51 +0200 Subject: [PATCH 6/8] Refs #5425 --- storage/emc/clariion/TODO | 31 -- storage/emc/clariion/custom.pm | 8 +- storage/emc/clariion/mode/disk.pm | 399 ++++++++++++++++++++++++++ storage/emc/clariion/mode/listluns.pm | 2 +- storage/emc/clariion/mode/sp.pm | 178 ++---------- storage/emc/clariion/plugin.pm | 1 + 6 files changed, 433 insertions(+), 186 deletions(-) create mode 100644 storage/emc/clariion/mode/disk.pm diff --git a/storage/emc/clariion/TODO b/storage/emc/clariion/TODO index f4978fc54..c541a993e 100644 --- a/storage/emc/clariion/TODO +++ b/storage/emc/clariion/TODO @@ -52,37 +52,6 @@ Total Writes: 401613 Total Reads: 6653775 Prct Idle: 94.2 -====================== -Mode pour les disques -====================== - -La commande pour tous: getdisk -state -bytrd -bytwrt -hw -hr - -Bus 1 Enclosure 7 Disk 13 -State: Enabled -Kbytes Read: 311959566 -Kbytes Written: 0 -Hard Write Errors: 0 -Hard Read Errors: 0 - -Bus 1 Enclosure 7 Disk 14 -State: Hot Spare Ready -Kbytes Read: 1957049160 -Kbytes Written: 0 -Hard Write Errors: 0 -Hard Read Errors: 0 - - -La commande pour un seul: getdisk 1_7_14 -state -bytrd -bytwrt -hw -hr - -Bus 1 Enclosure 7 Disk 14 -State: Hot Spare Ready -Kbytes Read: 1957105480 -Kbytes Written: 0 -Hard Write Errors: 0 -Hard Read Errors: 0 - - ====================== Mode pour les raid group ====================== diff --git a/storage/emc/clariion/custom.pm b/storage/emc/clariion/custom.pm index 7c7ce1225..dfb06b94b 100644 --- a/storage/emc/clariion/custom.pm +++ b/storage/emc/clariion/custom.pm @@ -233,19 +233,19 @@ my navisphere manage =item B<--navicli-path> -Specify navicli path (default: '/opt/Navisphere/bin') +Specify navicli path (default: 'navicli') =item B<--navicli-command> -Specify navicli command (default: 'navicli'). +Specify navicli command (default: '/opt/Navisphere/bin'). =item B<--naviseccli-path> -Specify naviseccli path (default: '/opt/Navisphere/bin') +Specify naviseccli path (default: 'naviseccli') =item B<--naviseccli-command> -Specify naviseccli command (default: 'naviseccli'). +Specify naviseccli command (default: '/opt/Navisphere/bin'). =item B<--sudo> diff --git a/storage/emc/clariion/mode/disk.pm b/storage/emc/clariion/mode/disk.pm new file mode 100644 index 000000000..d33e2f86a --- /dev/null +++ b/storage/emc/clariion/mode/disk.pm @@ -0,0 +1,399 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package storage::emc::clariion::mode::disk; + +sub get_absolute { + my ($self, %options) = @_; + my $name = $options{instance} . '_' . $options{label}; + my $value; + + $self->{new_datas}->{$name} = $1; + + $self->{old_datas}->{$name} = $self->{statefile_value}->get(name => $name); + return undef if (!defined($self->{old_datas}->{$name})); + + # Reward... put to 0 + if ($self->{old_datas}->{$name} > $self->{new_datas}->{$name}) { + $self->{old_datas}->{$name} = 0; + } + + $value = ($self->{new_datas}->{$name} - $self->{old_datas}->{$name}); + + return ($value, $value); +} + +sub get_bytes_per_seconds { + my ($self, %options) = @_; + my $name = $options{instance} . '_' . $options{label}; + my $value; + + $self->{new_datas}->{$name} = $1; + if (!defined($self->{old_datas}->{last_timestamp})) { + $self->{old_datas}->{last_timestamp} = $self->{statefile_value}->get(name => 'last_timestamp'); + } + $self->{old_datas}->{$name} = $self->{statefile_value}->get(name => $name); + return undef if (!defined($self->{old_datas}->{last_timestamp}) || !defined($self->{old_datas}->{$name})); + + # Reward... put to 0 + if ($self->{old_datas}->{$name} > $self->{new_datas}->{$name}) { + $self->{old_datas}->{$name} = 0; + } + # At least one second + my $delta_time = $self->{new_datas}->{last_timestamp} - $self->{old_datas}->{last_timestamp}; + if ($delta_time <= 0) { + $delta_time = 1; + } + + $value = ($self->{new_datas}->{$name} - $self->{old_datas}->{$name}) / $delta_time; + my ($scale_value, $scale_unit) = $self->{perfdata}->change_bytes(value => $value); + + return ($value, $scale_value . ' ' . $scale_unit); +} + +sub get_utils { + my ($self, %options) = @_; + my $name = $options{instance} . '_' . $options{label}; + my $value; + + $self->{new_datas}->{$name . '_busy'} = $1; + $self->{new_datas}->{$name . '_idle'} = $2; + + $self->{old_datas}->{$name . '_busy'} = $self->{statefile_value}->get(name => $name . '_busy'); + $self->{old_datas}->{$name . '_idle'} = $self->{statefile_value}->get(name => $name . '_idle'); + return undef if (!defined($self->{old_datas}->{$name . '_busy'}) || !defined($self->{old_datas}->{$name . '_idle'})); + + # Reward... put to 0 + if ($self->{old_datas}->{$name . '_busy'} > $self->{new_datas}->{$name . '_busy'}) { + $self->{old_datas}->{$name . '_busy'} = 0; + } + if ($self->{old_datas}->{$name . '_idle'} > $self->{new_datas}->{$name . '_idle'}) { + $self->{old_datas}->{$name . '_idle'} = 0; + } + + my $total_ticks = ($self->{new_datas}->{$name . '_idle'} - $self->{old_datas}->{$name . '_idle'}) + + ($self->{new_datas}->{$name . '_busy'} - $self->{old_datas}->{$name . '_busy'}); + if ($total_ticks <= 0) { + return (0, 0); + } + $value = ($self->{new_datas}->{$name . '_busy'} - $self->{old_datas}->{$name . '_busy'}) * 100 / $total_ticks; + + return ($value, $value); +} + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::statefile; +use centreon::plugins::misc; + +my $maps_counters = { + hard_read_errors => { thresholds => { + warning_hard_read_errors => { label => 'warning-hard-read-errors', exit_value => 'warning' }, + critical_hard_read_errors => { label => 'critical-hard-read-errors', exit_value => 'critical' }, + }, + matching => 'Hard Read Errors:\s+(\d+)', closure => \&get_absolute, + output_msg => 'Hard Read Errors : %d', perfdata => '%s', + unit => '', + }, + hard_write_errors => { thresholds => { + warning_hard_write_errors => { label => 'warning-hard-write-errors', exit_value => 'warning' }, + critical_hard_write_errors => { label => 'critical-hard-write-errors', exit_value => 'critical' }, + }, + matching => 'Hard Write Errors:\s+(\d+)', closure => \&get_absolute, + output_msg => 'Hard Write Errors : %d', perfdata => '%s', + unit => '', + }, + write_io => { thresholds => { + warning_write_io => { label => 'warning-write-io', exit_value => 'warning' }, + critical_write_io => { label => 'critical-write-io', exit_value => 'critical' }, + }, + matching => 'Kbytes Written:\s+(\d+)', closure => \&get_bytes_per_seconds, + output_msg => 'Write I/O : %s', perfdata => '%d', + unit => 'B', + }, + read_io => { thresholds => { + warning_read_io => { label => 'warning-read-io', exit_value => 'warning' }, + critical_read_io => { label => 'critical-read-io', exit_value => 'critical' }, + }, + matching => 'Kbytes Read:\s+(\d+)', closure => \&get_bytes_per_seconds, + output_msg => 'Read I/O : %s', perfdata => '%d', + unit => 'B', + }, + utils => { thresholds => { + warning_utils => { label => 'warning-utils', exit_value => 'warning' }, + critical_utils => { label => 'critical-utils', exit_value => 'critical' }, + }, + matching => 'Busy Ticks:\s+(\d+).*Idle Ticks:\s+(\d+)', closure => \&get_utils, + output_msg => 'Utils : %.2f %%', perfdata => '%.2f', + unit => '%', + }, +}; + +my @states = ( + ['^enabled$' , 'OK'], + ['^binding$' , 'OK'], + ['^expanding$' , 'OK'], + ['^ready$' , 'OK'], + ['^unbound$' , 'OK'], + ['^empty$' , 'OK'], + ['^hot spare ready$' , 'OK'], + ['^powering up$' , 'OK'], + ['^equalizing$' , 'WARNING'], + ['^formatting$' , 'WARNING'], + ['^removed$' , 'WARNING'], + ['^unformatted$' , 'WARNING'], + ['^failed$' , 'CRITICAL'], + ['^off$' , 'CRITICAL'], + ['^empty$' , 'CRITICAL'], + ['^unsupported$' , 'CRITICAL'], + ['^.*$' , 'CRITICAL'], +); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "threshold-overload:s@" => { name => 'threshold_overload' }, + "filter-raidgroupid:s" => { name => 'filter_raidgroupid', }, + "filter-disk:s" => { name => 'filter_disk', }, + }); + + foreach (keys %{$maps_counters}) { + foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { + $options{options}->add_options(arguments => { + $maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name }, + }); + } + } + + $self->{statefile_value} = centreon::plugins::statefile->new(%options); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + foreach (keys %{$maps_counters}) { + foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { + if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'."); + $self->{output}->option_exit(); + } + } + } + + $self->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + if ($val !~ /(.*?)=(.*)/) { + $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + + my ($filter, $threshold) = ($1, $2); + if ($self->{output}->is_litteral_status(status => $threshold) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); + $self->{output}->option_exit(); + } + $self->{overload_th}->{$filter} = $threshold; + } + + $self->{statefile_value}->check_options(%options); +} + +sub get_severity { + my ($self, %options) = @_; + my $status = 'unknown'; + + foreach my $entry (@states) { + if ($options{value} =~ /${$entry}[0]/i) { + $status = ${$entry}[1]; + foreach my $filter (keys %{$self->{overload_th}}) { + if (${$entry}[0] =~ /$filter/i) { + $status = $self->{overload_th}->{$filter}; + last; + } + } + last; + } + } + + return $status; +} + +sub run { + my ($self, %options) = @_; + my $clariion = $options{custom}; + + my $response = $clariion->execute_command(cmd => 'getdisk -state -bytrd -bytwrt -hw -hr -busyticks -idleticks -rg'); + + my ($total_num_disks, $skip_num_disks) = (0, 0); + $self->{new_datas} = {}; + $self->{statefile_value}->read(statefile => "cache_clariion_" . $clariion->{hostname} . '_' . $self->{mode}); + $self->{new_datas}->{last_timestamp} = time(); + + #Bus 1 Enclosure 7 Disk 13 + #State: Enabled + #Kbytes Read: 1109878030 + #Kbytes Written: 0 + #Hard Write Errors: 0 + #Hard Read Errors: 0 + #Busy Ticks: 462350 + #Idle Ticks: 388743630 + #Raid Group ID: 0 + while ($response =~ /^Bus\s+(\S+)\s+Enclosure\s+(\S+)\s+Disk\s+(\S+)(.*?)\n\n/msgi) { + my $disk_instance = "$1_$2_$3"; + my $values = $4; + + # First Filters + if (defined($self->{option_results}->{filter_disk}) && $self->{option_results}->{filter_disk} ne '' && + $disk_instance !~ /$self->{option_results}->{filter_disk}/) { + $skip_num_disks++; + $self->{output}->output_add(long_msg => "Skipping disk '" . $disk_instance . "': no matching filter disk"); + next; + } + if (defined($self->{option_results}->{filter_raidgroupid}) && $self->{option_results}->{filter_raidgroupid} ne '' && + $values =~ /^Raid Group ID:\s+(\S+)/mi && $1 !~ /$self->{option_results}->{filter_raidgroupid}/) { + $skip_num_disks++; + $self->{output}->output_add(long_msg => "Skipping disk '" . $disk_instance . "': no matching filter raid group id"); + next; + } + + $total_num_disks++; + $values =~ /^State:\s+(.*?)(\n|$)/msi; + + my $state = centreon::plugins::misc::trim($1); + my $exit = $self->get_severity(value => $state); + if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Disk '%s' state is %s", + $disk_instance, $state)); + # Don't check values if in critical/warning + next; + } + + # Work on values. No check if in 'Hot Spare Ready' or 'Unbound' + next if ($state =~ /^(Hot Spare Ready|Unbound)$/i); + + my ($short_msg, $long_msg) = ('', ''); + my @exits; + foreach (keys %{$maps_counters}) { + next if ($values !~ /$maps_counters->{$_}->{matching}/msi); + my ($value_check, $value_output) = &{$maps_counters->{$_}->{closure}}($self, + instance => $disk_instance, label => $_); + next if (!defined($value_check)); + my ($warning, $critical); + + foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { + my $exit2 = $self->{perfdata}->threshold_check(value => $value_check, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]); + $long_msg .= ' ' . sprintf($maps_counters->{$_}->{output_msg}, $value_output); + if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { + $short_msg .= ' ' . sprintf($maps_counters->{$_}->{output_msg}, $value_output); + } + push @exits, $exit2; + + $warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning'); + $critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical'); + } + + $self->{output}->output_add(long_msg => "Disk '$disk_instance':$long_msg"); + $self->{output}->perfdata_add(label => $_ . '_' . $disk_instance, unit => $maps_counters->{$_}->{unit}, + value => sprintf($maps_counters->{$_}->{perfdata}, $value_check), + warning => $warning, + critical => $critical, + min => 0); + } + + $exit = $self->{output}->get_most_critical(status => [ @exits ]); + if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { + $self->{output}->output_add(severity => $exit, + short_msg => "Disk '$disk_instance':$short_msg" + ); + } + } + + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("All %s disks are ok.", + $total_num_disks . '/' . $skip_num_disks) + ); + $self->{statefile_value}->write(data => $self->{new_datas}); + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check the status of the physical disks. + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'read-errors', 'write-errors', 'read-io', 'write-io', 'utils'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'read-errors', 'write-errors', 'read-io', 'write-io', 'utils'. + +=item B<--threshold-overload> + +Set to overload default threshold value. +Example: --threshold-overload='(enabled)=critical' + +=item B<--filter-disk> + +Filter Disk (regexp can be used). +Example: 1_7_14 ([BUS]_[ENCLOSURE]_[DISK]). + +=item B<--filter-raidgroupid> + +Filter Raid Group ID (regexp can be used). +Example: N/A or a number. + +=back + +=cut diff --git a/storage/emc/clariion/mode/listluns.pm b/storage/emc/clariion/mode/listluns.pm index f1053de1b..cdaa890df 100644 --- a/storage/emc/clariion/mode/listluns.pm +++ b/storage/emc/clariion/mode/listluns.pm @@ -198,7 +198,7 @@ Example: N/A, SATAII, Fibre Channel,... Filter Raid types (regexp can be used). Example: N/A, Hot Spare, RAID5,... -=item B<--filter-raidtype> +=item B<--filter-raidgroupid> Filter Raid Group ID (regexp can be used). Example: N/A or a number. diff --git a/storage/emc/clariion/mode/sp.pm b/storage/emc/clariion/mode/sp.pm index 11448704c..1973075f3 100644 --- a/storage/emc/clariion/mode/sp.pm +++ b/storage/emc/clariion/mode/sp.pm @@ -33,164 +33,42 @@ # #################################################################################### -package storage::emc::clariion::mode::sp; - -use base qw(centreon::plugins::mode); +package storage::emc::clariion::mode::spcomponents::sp; use strict; use warnings; -use centreon::plugins::misc; -use storage::emc::clariion::mode::spcomponents::fan; -use storage::emc::clariion::mode::spcomponents::lcc; -use storage::emc::clariion::mode::spcomponents::psu; -use storage::emc::clariion::mode::spcomponents::memory; -use storage::emc::clariion::mode::spcomponents::cpu; -use storage::emc::clariion::mode::spcomponents::iomodule; -use storage::emc::clariion::mode::spcomponents::cable; -use storage::emc::clariion::mode::spcomponents::sp; -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "exclude:s" => { name => 'exclude' }, - "component:s" => { name => 'component', default => 'all' }, - "no-component:s" => { name => 'no_component' }, - }); +my %conditions = ( + 1 => ['^(?!(Present|Valid)$)' => 'CRITICAL'], +); - $self->{components} = {}; - $self->{no_components} = undef; - - return $self; -} +sub check { + my ($self) = @_; -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->{output}->output_add(long_msg => "Checking sp"); + $self->{components}->{sp} = {name => 'sp', total => 0, skip => 0}; + return if ($self->check_exclude(section => 'sp')); - if (defined($self->{option_results}->{no_component})) { - if ($self->{option_results}->{no_component} ne '') { - $self->{no_components} = $self->{option_results}->{no_component}; - } else { - $self->{no_components} = 'critical'; + # SP A State: Present + while ($self->{response} =~ /^SP\s+(\S+)\s+State:\s+(.*)$/mgi) { + my $instance = $1; + my $state = $2; + + next if ($self->check_exclude(section => 'sp', instance => $instance)); + $self->{components}->{sp}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("sp '%s' state is %s.", + $instance, $state) + ); + foreach (keys %conditions) { + if ($state =~ /${$conditions{$_}}[0]/i) { + $self->{output}->output_add(severity => ${$conditions{$_}}[1], + short_msg => sprintf("sp '%s' state is %s", + $instance, $state)); + last; + } } } } -sub component { - my ($self, %options) = @_; - - if ($self->{option_results}->{component} eq 'all') { - storage::emc::clariion::mode::spcomponents::fan::check($self); - storage::emc::clariion::mode::spcomponents::lcc::check($self); - storage::emc::clariion::mode::spcomponents::psu::check($self); - storage::emc::clariion::mode::spcomponents::cable::check($self); - storage::emc::clariion::mode::spcomponents::iomodule::check($self); - storage::emc::clariion::mode::spcomponents::memory::check($self); - storage::emc::clariion::mode::spcomponents::cpu::check($self); - storage::emc::clariion::mode::spcomponents::sp::check($self); - } elsif ($self->{option_results}->{component} eq 'sp') { - storage::emc::clariion::mode::spcomponents::sp::check($self); - } elsif ($self->{option_results}->{component} eq 'fan') { - storage::emc::clariion::mode::spcomponents::fan::check($self); - } elsif ($self->{option_results}->{component} eq 'lcc') { - storage::emc::clariion::mode::spcomponents::lcc::check($self); - } elsif ($self->{option_results}->{component} eq 'psu') { - storage::emc::clariion::mode::spcomponents::psu::check($self); - } elsif ($self->{option_results}->{component} eq 'memory') { - storage::emc::clariion::mode::spcomponents::memory::check($self); - } elsif ($self->{option_results}->{component} eq 'cpu') { - storage::emc::clariion::mode::spcomponents::cpu::check($self); - } elsif ($self->{option_results}->{component} eq 'io') { - storage::emc::clariion::mode::spcomponents::iomodule::check($self); - } elsif ($self->{option_results}->{component} eq 'cable') { - storage::emc::clariion::mode::spcomponents::cable::check($self); - } else { - $self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'."); - $self->{output}->option_exit(); - } - - my $total_components = 0; - my $display_by_component = ''; - my $display_by_component_append = ''; - foreach my $comp (sort(keys %{$self->{components}})) { - # Skipping short msg when no components - next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0); - $total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip}; - $display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $self->{components}->{$comp}->{name}; - $display_by_component_append = ', '; - } - - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("All %s components [%s] are ok.", - $total_components, - $display_by_component) - ); - - if (defined($self->{option_results}->{no_component}) && $total_components == 0) { - $self->{output}->output_add(severity => $self->{no_components}, - short_msg => 'No components are checked.'); - } -} - -sub run { - my ($self, %options) = @_; - my $clariion = $options{custom}; - - $self->{response} = $clariion->execute_command(cmd => 'getcrus -all'); - chomp $self->{response}; - - $self->component(); - - $self->{output}->display(); - $self->{output}->exit(); -} - -sub check_exclude { - my ($self, %options) = @_; - - if (defined($options{instance})) { - if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) { - $self->{components}->{$options{section}}->{skip}++; - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance.")); - return 1; - } - } elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) { - $self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section.")); - return 1; - } - return 0; -} - -1; - -__END__ - -=head1 MODE - -Check status of storage processor. - -=over 8 - -=item B<--component> - -Which component to check (Default: 'all'). -Can be: 'cpu', 'psu', 'pc', 'fan', 'network', 'temperature', 'storage'. - -=item B<--exclude> - -Exclude some parts (comma seperated list) (Example: --exclude=fan,lcc) -Can also exclude specific instance: --exclude=fan#1.2#,lcc - -=item B<--no-component> - -Return an error if no compenents are checked. -If total (with skipped) is 0. (Default: 'critical' returns). - -=back - -=cut \ No newline at end of file +1; \ No newline at end of file diff --git a/storage/emc/clariion/plugin.pm b/storage/emc/clariion/plugin.pm index e0370177c..bbf179936 100644 --- a/storage/emc/clariion/plugin.pm +++ b/storage/emc/clariion/plugin.pm @@ -49,6 +49,7 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( 'cache' => 'storage::emc::clariion::mode::cache', + 'disk' => 'storage::emc::clariion::mode::disk', 'sp' => 'storage::emc::clariion::mode::sp', 'faults' => 'storage::emc::clariion::mode::faults', 'list-luns' => 'storage::emc::clariion::mode::listluns', From 3f70132c25a98df156fc70a31ec23455dff3cdbc Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Fri, 4 Jul 2014 11:53:09 +0200 Subject: [PATCH 7/8] Refs #5225 Change name --- .../em01/web/mode/contact.pm | 2 +- .../em01/web/mode/flood.pm | 2 +- .../em01/web/mode/humidity.pm | 2 +- .../em01/web/mode/illumination.pm | 4 ++-- .../em01/web/mode/temperature.pm | 6 +++--- .../em01/web/mode/thermistor.pm | 6 +++--- .../em01/web/mode/voltage.pm | 2 +- .../em01/web/plugin.pm | 18 +++++++++--------- 8 files changed, 21 insertions(+), 21 deletions(-) rename hardware/sensors/{sequoia => sensormetrix}/em01/web/mode/contact.pm (98%) rename hardware/sensors/{sequoia => sensormetrix}/em01/web/mode/flood.pm (98%) rename hardware/sensors/{sequoia => sensormetrix}/em01/web/mode/humidity.pm (98%) rename hardware/sensors/{sequoia => sensormetrix}/em01/web/mode/illumination.pm (97%) rename hardware/sensors/{sequoia => sensormetrix}/em01/web/mode/temperature.pm (97%) rename hardware/sensors/{sequoia => sensormetrix}/em01/web/mode/thermistor.pm (97%) rename hardware/sensors/{sequoia => sensormetrix}/em01/web/mode/voltage.pm (98%) rename hardware/sensors/{sequoia => sensormetrix}/em01/web/plugin.pm (75%) diff --git a/hardware/sensors/sequoia/em01/web/mode/contact.pm b/hardware/sensors/sensormetrix/em01/web/mode/contact.pm similarity index 98% rename from hardware/sensors/sequoia/em01/web/mode/contact.pm rename to hardware/sensors/sensormetrix/em01/web/mode/contact.pm index b5f3afdb1..7fb4c2b39 100644 --- a/hardware/sensors/sequoia/em01/web/mode/contact.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/contact.pm @@ -34,7 +34,7 @@ # Based on De Bodt Lieven plugin #################################################################################### -package hardware::sensors::sequoia::em01::web::mode::contact; +package hardware::sensors::sensormetrix::em01::web::mode::contact; use base qw(centreon::plugins::mode); diff --git a/hardware/sensors/sequoia/em01/web/mode/flood.pm b/hardware/sensors/sensormetrix/em01/web/mode/flood.pm similarity index 98% rename from hardware/sensors/sequoia/em01/web/mode/flood.pm rename to hardware/sensors/sensormetrix/em01/web/mode/flood.pm index 2ea40f5a4..5de893e46 100644 --- a/hardware/sensors/sequoia/em01/web/mode/flood.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/flood.pm @@ -34,7 +34,7 @@ # Based on De Bodt Lieven plugin #################################################################################### -package hardware::sensors::sequoia::em01::web::mode::flood; +package hardware::sensors::sensormetrix::em01::web::mode::flood; use base qw(centreon::plugins::mode); diff --git a/hardware/sensors/sequoia/em01/web/mode/humidity.pm b/hardware/sensors/sensormetrix/em01/web/mode/humidity.pm similarity index 98% rename from hardware/sensors/sequoia/em01/web/mode/humidity.pm rename to hardware/sensors/sensormetrix/em01/web/mode/humidity.pm index ce356d3ac..99fa8c5f2 100644 --- a/hardware/sensors/sequoia/em01/web/mode/humidity.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/humidity.pm @@ -34,7 +34,7 @@ # Based on De Bodt Lieven plugin #################################################################################### -package hardware::sensors::sequoia::em01::web::mode::humidity; +package hardware::sensors::sensormetrix::em01::web::mode::humidity; use base qw(centreon::plugins::mode); diff --git a/hardware/sensors/sequoia/em01/web/mode/illumination.pm b/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm similarity index 97% rename from hardware/sensors/sequoia/em01/web/mode/illumination.pm rename to hardware/sensors/sensormetrix/em01/web/mode/illumination.pm index 0618ff12e..45992724c 100644 --- a/hardware/sensors/sequoia/em01/web/mode/illumination.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm @@ -34,7 +34,7 @@ # Based on De Bodt Lieven plugin #################################################################################### -package hardware::sensors::sequoia::em01::web::mode::illumination; +package hardware::sensors::sensormetrix::em01::web::mode::illumination; use base qw(centreon::plugins::mode); @@ -93,7 +93,7 @@ sub run { my $webcontent = centreon::plugins::httplib::connect($self); my $illumination; - if ($webcontent !~ /(.*)<\/body>/msi || $1 !~ /IL\s*([0-9\.]+)/i) { + if ($webcontent !~ /(.*)<\/body>/msi || $1 !~ /IL\s*(?::\s*([0-9\.]+)|([0-9\.]+))/i) { $self->{output}->add_option_msg(short_msg => "Could not find illumination information."); $self->{output}->option_exit(); } diff --git a/hardware/sensors/sequoia/em01/web/mode/temperature.pm b/hardware/sensors/sensormetrix/em01/web/mode/temperature.pm similarity index 97% rename from hardware/sensors/sequoia/em01/web/mode/temperature.pm rename to hardware/sensors/sensormetrix/em01/web/mode/temperature.pm index 12c973283..1b27c2e86 100644 --- a/hardware/sensors/sequoia/em01/web/mode/temperature.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/temperature.pm @@ -34,7 +34,7 @@ # Based on De Bodt Lieven plugin #################################################################################### -package hardware::sensors::sequoia::em01::web::mode::temperature; +package hardware::sensors::sensormetrix::em01::web::mode::temperature; use base qw(centreon::plugins::mode); @@ -162,11 +162,11 @@ Threshold for HTTP timeout =item B<--warning> -Warning Threshold for Humidity +Warning Threshold for Temperature =item B<--critical> -Critical Threshold for Humidity +Critical Threshold for Temperature =back diff --git a/hardware/sensors/sequoia/em01/web/mode/thermistor.pm b/hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm similarity index 97% rename from hardware/sensors/sequoia/em01/web/mode/thermistor.pm rename to hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm index fdd609241..0928ab778 100644 --- a/hardware/sensors/sequoia/em01/web/mode/thermistor.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm @@ -34,7 +34,7 @@ # Based on De Bodt Lieven plugin #################################################################################### -package hardware::sensors::sequoia::em01::web::mode::thermistor; +package hardware::sensors::sensormetrix::em01::web::mode::thermistor; use base qw(centreon::plugins::mode); @@ -162,11 +162,11 @@ Threshold for HTTP timeout =item B<--warning> -Warning Threshold for Humidity +Warning Threshold for Thermistor Temperature =item B<--critical> -Critical Threshold for Humidity +Critical Threshold for Thermistor Temperature =back diff --git a/hardware/sensors/sequoia/em01/web/mode/voltage.pm b/hardware/sensors/sensormetrix/em01/web/mode/voltage.pm similarity index 98% rename from hardware/sensors/sequoia/em01/web/mode/voltage.pm rename to hardware/sensors/sensormetrix/em01/web/mode/voltage.pm index 206463b59..ad1725907 100644 --- a/hardware/sensors/sequoia/em01/web/mode/voltage.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/voltage.pm @@ -34,7 +34,7 @@ # Based on De Bodt Lieven plugin #################################################################################### -package hardware::sensors::sequoia::em01::web::mode::voltage; +package hardware::sensors::sensormetrix::em01::web::mode::voltage; use base qw(centreon::plugins::mode); diff --git a/hardware/sensors/sequoia/em01/web/plugin.pm b/hardware/sensors/sensormetrix/em01/web/plugin.pm similarity index 75% rename from hardware/sensors/sequoia/em01/web/plugin.pm rename to hardware/sensors/sensormetrix/em01/web/plugin.pm index 7a9ef0a5d..a4a8796bb 100644 --- a/hardware/sensors/sequoia/em01/web/plugin.pm +++ b/hardware/sensors/sensormetrix/em01/web/plugin.pm @@ -33,7 +33,7 @@ # #################################################################################### -package hardware::sensors::sequoia::em01::web::plugin; +package hardware::sensors::sensormetrix::em01::web::plugin; use strict; use warnings; @@ -47,13 +47,13 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'contact' => 'hardware::sensors::sequoia::em01::web::mode::contact', - 'temperature' => 'hardware::sensors::sequoia::em01::web::mode::temperature', - 'humidity' => 'hardware::sensors::sequoia::em01::web::mode::humidity', - 'illumination' => 'hardware::sensors::sequoia::em01::web::mode::illumination', - 'flood' => 'hardware::sensors::sequoia::em01::web::mode::flood', - 'thermistor' => 'hardware::sensors::sequoia::em01::web::mode::thermistor', - 'voltage' => 'hardware::sensors::sequoia::em01::web::mode::voltage', + 'contact' => 'hardware::sensors::sensormetrix::em01::web::mode::contact', + 'temperature' => 'hardware::sensors::sensormetrix::em01::web::mode::temperature', + 'humidity' => 'hardware::sensors::sensormetrix::em01::web::mode::humidity', + 'illumination' => 'hardware::sensors::sensormetrix::em01::web::mode::illumination', + 'flood' => 'hardware::sensors::sensormetrix::em01::web::mode::flood', + 'thermistor' => 'hardware::sensors::sensormetrix::em01::web::mode::thermistor', + 'voltage' => 'hardware::sensors::sensormetrix::em01::web::mode::voltage', ); return $self; @@ -65,6 +65,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Sequoia em01 sensors through webpage. +Check Sensormetrix em01 sensors through webpage. =cut From e8d430130a65fb67fc5dd9ef2a57e8a6f3c49b7c Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Fri, 4 Jul 2014 14:19:40 +0200 Subject: [PATCH 8/8] Refs #5225 --- hardware/sensors/sensormetrix/em01/web/mode/contact.pm | 2 +- hardware/sensors/sensormetrix/em01/web/mode/illumination.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hardware/sensors/sensormetrix/em01/web/mode/contact.pm b/hardware/sensors/sensormetrix/em01/web/mode/contact.pm index 7fb4c2b39..2291c7b2e 100644 --- a/hardware/sensors/sensormetrix/em01/web/mode/contact.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/contact.pm @@ -120,7 +120,7 @@ __END__ =head1 MODE -Check sensor voltage. +Check sensor contact. =over 8 diff --git a/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm b/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm index 45992724c..420bcc392 100644 --- a/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm @@ -93,7 +93,7 @@ sub run { my $webcontent = centreon::plugins::httplib::connect($self); my $illumination; - if ($webcontent !~ /(.*)<\/body>/msi || $1 !~ /IL\s*(?::\s*([0-9\.]+)|([0-9\.]+))/i) { + if ($webcontent !~ /(.*)<\/body>/msi || $1 !~ /IL(?:\s*:\s*|\s*)([0-9\.]+)/i) { $self->{output}->add_option_msg(short_msg => "Could not find illumination information."); $self->{output}->option_exit(); }