From 2bbf6084f36a12022dd3b41f789c462eeff2c7ff Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 22 Sep 2016 13:41:46 +0200 Subject: [PATCH] + enhance emc dmx plugin --- .../local/mode/components/environment.pm | 56 -------------- .../dmx34/local/mode/components/fru.pm | 75 +++++++++++++++++++ .../symmetrix/dmx34/local/mode/hardware.pm | 30 +++++--- 3 files changed, 93 insertions(+), 68 deletions(-) delete mode 100644 storage/emc/symmetrix/dmx34/local/mode/components/environment.pm create mode 100644 storage/emc/symmetrix/dmx34/local/mode/components/fru.pm diff --git a/storage/emc/symmetrix/dmx34/local/mode/components/environment.pm b/storage/emc/symmetrix/dmx34/local/mode/components/environment.pm deleted file mode 100644 index 8edda26ae..000000000 --- a/storage/emc/symmetrix/dmx34/local/mode/components/environment.pm +++ /dev/null @@ -1,56 +0,0 @@ -# -# Copyright 2016 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package storage::emc::symmetrix::dmx34::local::mode::components::environment; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -# -------------[ Power Information ]------------- -# -# No Environmental Problems found -sub check { - my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking environment"); - $self->{components}->{environment} = {name => 'environment', total => 0, skip => 0}; - return if ($self->check_filter(section => 'environment')); - - if ($self->{content_file_health} !~ /----\[ Power Information(.*?)----\[/msi) { - $self->{output}->output_add(long_msg => 'skipping: cannot find environment'); - return ; - } - - my $content = $1; - $self->{components}->{environment}->{total}++; - - # Error if not present: - # No Environmental Problems found - if ($content !~ /No Environmental Problems found/msi) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("environment problem detected")); - } else { - $self->{output}->output_add(long_msg => sprintf("no environment problem detected")); - } -} - -1; diff --git a/storage/emc/symmetrix/dmx34/local/mode/components/fru.pm b/storage/emc/symmetrix/dmx34/local/mode/components/fru.pm new file mode 100644 index 000000000..c22b628dc --- /dev/null +++ b/storage/emc/symmetrix/dmx34/local/mode/components/fru.pm @@ -0,0 +1,75 @@ +# +# Copyright 2016 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package storage::emc::symmetrix::dmx34::local::mode::components::fru; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#FRU status (alarms) table: +# +#+---------------------+--------------------+-----------+ +#| Description | FRU/Alarm Status | Comm. | +#+---------------------+--------------------+-----------+ +#| Dir 01 | OK | 01A | +#| Dir 02 | OK | 02A | +#... +#| Backplane | OK | 01A,16A | +#+---------------------+--------------------+-----------+ +#| Description | FRU/Alarm Status | Comm. | +#+---------------------+--------------------+-----------+ +# +# +#Analog readings: + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking frus"); + $self->{components}->{fru} = {name => 'frus', total => 0, skip => 0}; + return if ($self->check_filter(section => 'fru')); + + if ($self->{content_file_health_env} !~ /FRU status .*? table:.*?---------.*?Description.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find frus'); + return ; + } + + my $content = $1; + while ($content =~ /^\|(.*?)\|(.*?)\|.*?\n/msig) { + my ($fru, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'fru', instance => $fru)); + $self->{components}->{fru}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fru '%s' status is '%s'", + $fru, $status)); + my $exit = $self->get_severity(section => 'fru', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fru '%s' status is '%s'", + $fru, $status)); + } + } +} + +1; diff --git a/storage/emc/symmetrix/dmx34/local/mode/hardware.pm b/storage/emc/symmetrix/dmx34/local/mode/hardware.pm index 010a6a303..4ca886dad 100644 --- a/storage/emc/symmetrix/dmx34/local/mode/hardware.pm +++ b/storage/emc/symmetrix/dmx34/local/mode/hardware.pm @@ -54,10 +54,14 @@ sub set_system { ['\.\./.*', 'OK'], ['.*', 'CRITICAL'], ], + fru => [ + ['OK', 'OK'], + ['.*', 'CRITICAL'], + ], }; $self->{components_path} = 'storage::emc::symmetrix::dmx34::local::mode::components'; - $self->{components_module} = ['director', 'xcm', 'disk', 'memory', 'config', 'environment', 'test']; + $self->{components_module} = ['director', 'xcm', 'disk', 'memory', 'config', 'test', 'fru']; } sub check_options { @@ -100,17 +104,19 @@ sub read_files { $self->{output}->add_option_msg(short_msg => "Please set option --file-health and --file-health-env."); $self->{output}->option_exit(); } - $self->{content_file_health} = do { - local $/ = undef; - if (!open my $fh, "<", $self->{option_results}->{file_health}) { - $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{file_health} : $!"); - $self->{output}->option_exit(); - } - <$fh>; - }; - # We remove color syntax - $self->{content_file_health} =~ s/\x{1b}\[.*?m|\r//msg; + foreach (('file_health', 'file_health_env')) { + $self->{'content_' . $_} = do { + local $/ = undef; + if (!open my $fh, "<", $self->{option_results}->{$_}) { + $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{$_} : $!"); + $self->{output}->option_exit(); + } + <$fh>; + }; + # We remove color syntax + $self->{'content_' . $_} =~ s/\x{1b}\[.*?m|\r//msg; + } # ***************************************************************** #* Health Check Run From Scheduler Version 2.0 * @@ -247,7 +253,7 @@ Check hardware. =item B<--component> Which component to check (Default: '.*'). -Can be: 'director', 'xcm', 'disk', 'memory', 'config', 'environment', 'test' +Can be: 'director', 'xcm', 'disk', 'memory', 'config', 'fru', 'test' =item B<--filter>