diff --git a/storage/emc/symmetrix/vmax/local/mode/components/cabling.pm b/storage/emc/symmetrix/vmax/local/mode/components/cabling.pm new file mode 100644 index 000000000..c904cdd3a --- /dev/null +++ b/storage/emc/symmetrix/vmax/local/mode/components/cabling.pm @@ -0,0 +1,70 @@ +# +# 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::vmax::local::mode::components::cabling; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Ethernet cabling: OK +# +#+--------------------------------------------------+--------+----------------------+--------------------+----------------------+----------------------+------------+--------------+ +#| Cable Name | Status | Expected 'From' Port | Actual 'From' Port | Expected 'To' Port | Actual 'To' Port | Error Code | Error string | +#+--------------------------------------------------+--------+----------------------+--------------------+----------------------+----------------------+------------+--------------+ +#| Cable from SRV A Adapter to MM-A ES-4 Lower port | OK | SRV A Adapter | SRV A Adapter | MM-A ES-4 Lower port | MM-A ES-4 Lower port | None | | +#| Cable from SRV B Adapter to MM-B ES-4 Lower port | OK | SRV B Adapter | SRV B Adapter | MM-B ES-4 Lower port | MM-B ES-4 Lower port | None | | +#+--------------------------------------------------+--------+----------------------+--------------------+----------------------+----------------------+------------+--------------+ +#| Cable Name | Status | Expected 'From' Port | Actual 'From' Port | Expected 'To' Port | Actual 'To' Port | Error Code | Error string | +#+--------------------------------------------------+--------+----------------------+--------------------+----------------------+----------------------+------------+--------------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking cabling"); + $self->{components}->{cabling} = {name => 'cabling', total => 0, skip => 0}; + return if ($self->check_filter(section => 'cabling')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Ethernet cabling.*?---------.*?Cable Name.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find cabling'); + return ; + } + + my $content = $1; + while ($content =~ /^\|(.*?)\|(.*?)\|.*?\n/msig) { + my ($cabling, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'cabling', instance => $cabling)); + $self->{components}->{cabling}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("cabling '%s' status is '%s'", + $cabling, $status)); + my $exit = $self->get_severity(label => 'default', section => 'cabling', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Cabling '%s' status is '%s'", + $cabling, $status)); + } + } +} + +1; diff --git a/storage/emc/symmetrix/vmax/local/mode/components/director.pm b/storage/emc/symmetrix/vmax/local/mode/components/director.pm new file mode 100644 index 000000000..93ab9d296 --- /dev/null +++ b/storage/emc/symmetrix/vmax/local/mode/components/director.pm @@ -0,0 +1,72 @@ +# +# 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::vmax::local::mode::components::director; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Directors status: OK +# +#+----------+--------+---------+-------------+---------+-----------------+-------------+ +#| Director | Type | State | Flags | Version | Address | Last Update | +#+----------+--------+---------+-------------+---------+-----------------+-------------+ +#| 07A | DA_4x1 | Online | [ON] (0x80) | 05 | 192.168.177.7 | 1110 | +#| 07B | DA_4x1 | Online | [ON] (0x80) | 05 | 192.168.177.23 | 1110 | +#| 07C | DA_4x1 | Online | [ON] (0x80) | 05 | 192.168.177.39 | 1110 | +#| 07D | DA_4x1 | Online | [ON] (0x80) | 05 | 192.168.177.55 | 1110 | +#+----------+--------+---------+-------------+---------+-----------------+-------------+ +#| Director | Type | State | Flags | Version | Address | Last Update | +#+----------+--------+---------+-------------+---------+-----------------+-------------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking directors"); + $self->{components}->{director} = {name => 'directors', total => 0, skip => 0}; + return if ($self->check_filter(section => 'director')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Directors status.*?---------.*?Director.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find directors'); + return ; + } + + my $content = $1; + while ($content =~ /^\|(.*?)\|.*?\|(.*?)\|.*?\n/msig) { + my ($director, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'director', instance => $director)); + $self->{components}->{director}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("director '%s' status is '%s'", + $director, $status)); + my $exit = $self->get_severity(label => 'default', section => 'director', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Director '%s' status is '%s'", + $director, $status)); + } + } +} + +1; diff --git a/storage/emc/symmetrix/vmax/local/mode/components/fabric.pm b/storage/emc/symmetrix/vmax/local/mode/components/fabric.pm new file mode 100644 index 000000000..b2b3df797 --- /dev/null +++ b/storage/emc/symmetrix/vmax/local/mode/components/fabric.pm @@ -0,0 +1,91 @@ +# +# 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::vmax::local::mode::components::fabric; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Fabric system: OK +# +#+-------------------------------------------------+---------------------------------+ +#| Item | Status | +#+-------------------------------------------------+---------------------------------+ +#| Fabric System General Status | OK | +#| Usage Mode | Full usage - BOSCO and Ethernet | +#| Initialization Status | OK | +#| Configuration Status | OK | +#| Fabric A Availability | Available | +#| Fabric B Availability | Available | +#| Directors' Fabric Links Status | OK | +#| Dir 7 (RIO 0x0C) | All links are up | +#| Link A status | Up | +#| Link B status | Up | +#+-------------------------------------------------+---------------------------------+ +#| Item | Status | +#+-------------------------------------------------+---------------------------------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fabrics"); + $self->{components}->{fabric} = {name => 'fabrics', total => 0, skip => 0}; + return if ($self->check_filter(section => 'fabric')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Fabric system.*?---------.*?Item.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find fabrics'); + return ; + } + + my $content = $1; + + my $total_components = 0; + my @stack = ({ indent => 0, long_instance => '' }); + while ($content =~ /^\|([ \t]+)(.*?)\|(.*?)\|\n/msig) { + my ($indent, $name, $status) = (length($1), centreon::plugins::misc::trim($2), centreon::plugins::misc::trim($3)); + + pop @stack while ($indent <= $stack[$#stack]->{indent}); + + my $long_instance = $stack[$#stack]->{long_instance} . '>' . $name; + if ($indent > $stack[$#stack]->{indent}) { + push @stack, { indent => $indent, + long_instance => $stack[$#stack]->{long_instance} . '>' . $name }; + } + + next if ($name !~ /status/i); + + next if ($self->check_filter(section => 'fabric', instance => $long_instance)); + $self->{components}->{fabric}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("fabric '%s' status is '%s'", + $long_instance, $status)); + my $exit = $self->get_severity(label => 'default', section => 'fabric', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Fabric '%s' status is '%s'", + $long_instance, $status)); + } + } +} + +1; diff --git a/storage/emc/symmetrix/vmax/local/mode/components/module.pm b/storage/emc/symmetrix/vmax/local/mode/components/module.pm new file mode 100644 index 000000000..f9b1b4667 --- /dev/null +++ b/storage/emc/symmetrix/vmax/local/mode/components/module.pm @@ -0,0 +1,71 @@ +# +# 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::vmax::local::mode::components::module; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Modules status (alarms): OK +#+-------------------------------------------------------------------+-----------+----------+--------+------------+ +#| Module | Ctrl dirs | Rep dirs | Status | Rel Status | +#+-------------------------------------------------------------------+-----------+----------+--------+------------+ +#| Engine 4 | 07A,08A | 07A,08A | OK | | +#| Engine SPS 4A | 07A | 07A | OK | | +#| Engine SPS 4B | 08A | 08A | OK | | +#| Engine Power Supply A of ES-4 | 07A | 07A | OK | | +#+-------------------------------------------------------------------+-----------+----------+--------+------------+ +#| Module | Ctrl dirs | Rep dirs | Status | Rel Status | +#+-------------------------------------------------------------------+-----------+----------+--------+------------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking modules"); + $self->{components}->{module} = {name => 'modules', total => 0, skip => 0}; + return if ($self->check_filter(section => 'module')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Modules status.*?---------.*?Module.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find modules'); + return ; + } + + my $content = $1; + while ($content =~ /^\|(.*?)\|.*?\|.*?\|(.*?)\|.*?\n/msig) { + my ($module, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'module', instance => $module)); + $self->{components}->{module}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("module '%s' status is '%s'", + $module, $status)); + my $exit = $self->get_severity(label => 'default', section => 'module', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Module '%s' status is '%s'", + $module, $status)); + } + } +} + +1; diff --git a/storage/emc/symmetrix/vmax/local/mode/components/power.pm b/storage/emc/symmetrix/vmax/local/mode/components/power.pm new file mode 100644 index 000000000..5bba09a19 --- /dev/null +++ b/storage/emc/symmetrix/vmax/local/mode/components/power.pm @@ -0,0 +1,95 @@ +# +# 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::vmax::local::mode::components::power; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Power system: OK +# +#+--------------------------------------------------------+--------------------------------------+ +#| Item | Status | +#+--------------------------------------------------------+--------------------------------------+ +#| Power input type | Three Phases | +#| System Bay AC Zones Status | OK | +#| AC Status Zone A | Zone AC OK | +#| AC Status Zone B | Zone AC OK | +#| Power modules status | OK | +#| System Bay 1 | OK | +#| Engine SPS 4A | OK | +#| General Status | OK | +#| Detailed Status | OK | +#| Condition Register | OK | +#| Battery Life (sec) | 600 | +#| Days of Operation | Unknown | +#| Slot | Slot B | +#| Manufacturer Information | ASTEC,AA23540,7E, 04/11/2008 | +#+--------------------------------------------------------+--------------------------------------+ +#| Item | Status | +#+--------------------------------------------------------+--------------------------------------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking powers"); + $self->{components}->{power} = {name => 'powers', total => 0, skip => 0}; + return if ($self->check_filter(section => 'power')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Power system.*?---------.*?Item.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find powers'); + return ; + } + + my $content = $1; + + my $total_components = 0; + my @stack = ({ indent => 0, long_instance => '' }); + while ($content =~ /^\|([ \t]+)(.*?)\|(.*?)\|\n/msig) { + my ($indent, $name, $status) = (length($1), centreon::plugins::misc::trim($2), centreon::plugins::misc::trim($3)); + + pop @stack while ($indent <= $stack[$#stack]->{indent}); + + my $long_instance = $stack[$#stack]->{long_instance} . '>' . $name; + if ($indent > $stack[$#stack]->{indent}) { + push @stack, { indent => $indent, + long_instance => $stack[$#stack]->{long_instance} . '>' . $name }; + } + + next if ($name !~ /status/i); + + next if ($self->check_filter(section => 'power', instance => $long_instance)); + $self->{components}->{power}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("power '%s' status is '%s'", + $long_instance, $status)); + my $exit = $self->get_severity(label => 'default', section => 'power', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power '%s' status is '%s'", + $long_instance, $status)); + } + } +} + +1; diff --git a/storage/emc/symmetrix/vmax/local/mode/components/sparedisk.pm b/storage/emc/symmetrix/vmax/local/mode/components/sparedisk.pm new file mode 100644 index 000000000..62834a546 --- /dev/null +++ b/storage/emc/symmetrix/vmax/local/mode/components/sparedisk.pm @@ -0,0 +1,62 @@ +# +# 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::vmax::local::mode::components::sparedisk; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +#06/15/2016 09:26:42.015 Verify Spare Status Test +#There are 1 non available Spare[s], deferred service is ON. +#06/15/2016 09:26:42.046 Verify Spare Status: Test Succeeded. + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking spare disks"); + $self->{components}->{sparedisk} = {name => 'spare disks', total => 0, skip => 0}; + return if ($self->check_filter(section => 'sparedisk')); + + if ($self->{content_file_health} !~ /There are (\d+) non available Spare/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find spare disks'); + return ; + } + + my $value = $1; + $self->{components}->{sparedisk}->{total}++; + + my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'sparedisk', instance => '1', value => $value); + $self->{output}->output_add(long_msg => sprintf("'%s' spare disk non availabled", + $value)); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("'%s' spare disk non availabled", + $value)); + } + + $self->{output}->perfdata_add(label => "disk_spare_non_available", + value => $value, + warning => $warn, + critical => $crit, min => 0); +} + +1; diff --git a/storage/emc/symmetrix/vmax/local/mode/components/temperature.pm b/storage/emc/symmetrix/vmax/local/mode/components/temperature.pm new file mode 100644 index 000000000..b1e561074 --- /dev/null +++ b/storage/emc/symmetrix/vmax/local/mode/components/temperature.pm @@ -0,0 +1,74 @@ +# +# 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::vmax::local::mode::components::temperature; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Temperatures check: OK +# +#+-------------------+------------+------------+------------------+--------+ +#| Module | Temp [°C] | Temp [°F] | High Limit [°C] | Status | +#+-------------------+------------+------------+------------------+--------+ +#| ES-PWS-A ES-4 | 24 | 75 | | OK | +#| ES-PWS-B ES-4 | 22 | 71 | | OK | +#| DIR-7 ES-4 | 34 | 93 | | OK | +#| DIR-8 ES-4 | 36 | 96 | | OK | +#| DIMM-0 DIR-7 ES-4 | 43 | 109 | 88 | OK | +#| DIMM-1 DIR-7 ES-4 | 48 | 118 | 91 | OK | +#+-------------------+------------+------------+------------------+--------+ +#| Module | Temp [°C] | Temp [°F] | High Limit [°C] | Status | +#+-------------------+------------+------------+------------------+--------+ + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + if ($self->{content_file_health_env} !~ /Ethernet cabling.*?Temperatures check.*?---------.*?Module.*?---------.*?\n(.*?\n)\+---------/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find temperatures'); + return ; + } + + my $content = $1; + while ($content =~ /^\|(.*?)\|.*?\|.*?\|.*?\|(.*?)\|.*?\n/msig) { + my ($temperature, $status) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2)); + + next if ($self->check_filter(section => 'temperature', instance => $temperature)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s'", + $temperature, $status)); + my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $status); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Temperature '%s' status is '%s'", + $temperature, $status)); + } + } +} + +1; diff --git a/storage/emc/symmetrix/vmax/local/mode/components/voltage.pm b/storage/emc/symmetrix/vmax/local/mode/components/voltage.pm new file mode 100644 index 000000000..195f17ddf --- /dev/null +++ b/storage/emc/symmetrix/vmax/local/mode/components/voltage.pm @@ -0,0 +1,55 @@ +# +# 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::vmax::local::mode::components::voltage; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +#Voltages check: OK +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking voltage"); + $self->{components}->{voltage} = {name => 'voltage', total => 0, skip => 0}; + return if ($self->check_filter(section => 'voltage')); + + if ($self->{content_file_health_env} !~ /Voltages check:(.*?)\n/msi) { + $self->{output}->output_add(long_msg => 'skipping: cannot find voltage'); + return ; + } + + my $content = centreon::plugins::misc::trim($1); + $self->{components}->{voltage}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("voltage status is '%s'", + $content)); + my $exit = $self->get_severity(label => 'default', section => 'voltage', value => $content); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Voltage status is '%s'", + $content)); + } +} + +1; diff --git a/storage/emc/symmetrix/vmax/local/mode/hardware.pm b/storage/emc/symmetrix/vmax/local/mode/hardware.pm new file mode 100644 index 000000000..8f2b7429a --- /dev/null +++ b/storage/emc/symmetrix/vmax/local/mode/hardware.pm @@ -0,0 +1,273 @@ +# +# 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::vmax::local::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::plugins::statefile; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_numeric_check_section_option} = '^(sparedisk)$'; + + $self->{cb_hook1} = 'read_files'; + $self->{cb_hook4} = 'send_email'; + + $self->{thresholds} = { + default => [ + ['Recoverable Error', 'OK'], # Fabric + ['Online', 'OK'], + ['Up', 'OK'], + ['OK', 'OK'], + ['.*', 'CRITICAL'], + ], + }; + + $self->{components_path} = 'storage::emc::symmetrix::vmax::local::mode::components'; + $self->{components_module} = ['module', 'temperature', 'director', 'cabling', 'power', 'fabric', 'voltage', 'sparedisk']; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{statefile_cache}->check_options(%options); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "file-health:s" => { name => 'file_health' }, + "file-health-env:s" => { name => 'file_health_env' }, + # Email + "email-warning:s" => { name => 'email_warning' }, + "email-critical:s" => { name => 'email_critical' }, + "email-smtp-host:s" => { name => 'email_smtp_host' }, + "email-smtp-username:s" => { name => 'email_smtp_username' }, + "email-smtp-password:s" => { name => 'email_smtp_password' }, + "email-smtp-from:s" => { name => 'email_smtp_from' }, + "email-smtp-options:s@" => { name => 'email_smtp_options' }, + "email-memory" => { name => 'email_memory' }, + }); + + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); + $self->{components_exec_load} = 0; + return $self; +} + +sub read_files { + my ($self, %options) = @_; + + if (!defined($self->{option_results}->{file_health}) || !defined($self->{option_results}->{file_health_env})) { + $self->{output}->add_option_msg(short_msg => "Please set option --file-health and --file-health-env."); + $self->{output}->option_exit(); + } + + 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 Results Log: + #Service Processor Date: 06/15/2016 09:26:41 + #Symmetrix Date from director 07c: 06/15/2016 09:33:45 + #The time difference between Service Processor and Symmetrix is : 00:07:03.672 + #System SN: 000292602920 + #System Model: VMAX20K + #mCode Level: 5876.288 + my ($serial) = ('unknown'); + $serial = $1 if ($self->{content_file_health} =~ /System SN:\s*(\S+)/msi); + + $self->{output}->output_add(long_msg => sprintf('serial number: %s', $serial)); +} + +# +# maybe we should add it in core (with cleaner code ;) +# + +sub send_email { + my ($self, %options) = @_; + + ####### + # Check SMTP options + return if (!((defined($self->{option_results}->{email_warning}) && $self->{option_results}->{email_warning} ne '') + || (defined($self->{option_results}->{email_critical}) && $self->{option_results}->{email_critical} ne ''))); + + if (!defined($self->{option_results}->{email_smtp_host})) { + $self->{output}->add_option_msg(short_msg => "Please set the --email-smtp-host option"); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{email_smtp_from})) { + $self->{output}->add_option_msg(short_msg => "Please set --email-smtp-from option"); + $self->{output}->option_exit(); + } + + my %smtp_options = ('-auth' => 'none'); + if (defined($self->{option_results}->{email_smtp_username}) && $self->{option_results}->{email_smtp_username} ne '') { + $smtp_options{-login} = $self->{option_results}->{email_smtp_username}; + delete $smtp_options{-auth}; + } + if (defined($self->{option_results}->{email_smtp_username}) && defined($self->{option_results}->{email_smtp_password})) { + $smtp_options{-pass} = $self->{option_results}->{email_smtp_password}; + } + foreach my $option (@{$self->{option_results}->{email_smtp_options}}) { + next if ($option !~ /^(.+?)=(.+)$/); + $smtp_options{-$1} = $2; + } + + ####### + # Get current data + my $stdout; + { + local *STDOUT; + open STDOUT, '>', \$stdout; + $self->{output}->display(force_long_output => 1); + } + + $stdout =~ /^(.*?)(\||\n)/msi; + my $subject = $1; + my $status = lc($self->{output}->get_litteral_status()); + + my $send_email = 0; + $send_email = 1 if ($status ne 'ok'); + ####### + # Check memory file + if (defined($self->{option_results}->{email_memory})) { + $self->{new_datas} = { status => $status, output => $subject }; + $self->{statefile_cache}->read(statefile => "cache_emc_symmetrix_vmax_email"); + my $prev_status = $self->{statefile_cache}->get(name => 'status'); + my $prev_output = $self->{statefile_cache}->get(name => 'output'); + # non-ok output is the same + $send_email = 0 if ($status ne 'ok' && defined($prev_output) && $prev_output eq $subject); + # recovery email + $send_email = 1 if ($status eq 'ok' && defined($prev_status) && $prev_status ne 'ok'); + $self->{statefile_cache}->write(data => $self->{new_datas}); + } + + my $smtp_to = ''; + $smtp_to = $self->{option_results}->{email_warning} if ($status eq 'warning' && defined($self->{option_results}->{email_warning} && $self->{option_results}->{email_warning}) ne ''); + $smtp_to = $self->{option_results}->{email_critical} if ($status eq 'critical' && defined($self->{option_results}->{email_critical} && $self->{option_results}->{email_critical}) ne ''); + if ($send_email == 1 && $status eq 'ok') { + my $append = ''; + foreach (('email_warning', 'email_critical')) { + if (defined($self->{option_results}->{$_}) && $self->{option_results}->{$_} ne '') { + $smtp_to .= $append . $self->{option_results}->{$_}; + $append .= ','; + } + } + } + + if ($send_email == 0) { + $self->{output}->add_option_msg(severity => 'OK', short_msg => "No email to send"); + return ; + } + + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Email::Send::SMTP::Gmail', + error_msg => "Cannot load module 'Email::Send::SMTP::Gmail'."); + my ($mail, $error) = Email::Send::SMTP::Gmail->new(-smtp => $self->{option_results}->{email_smtp_host}, + %smtp_options); + if ($mail == -1) { + $self->{output}->add_option_msg(short_msg => "session error: " . $error); + $self->{output}->option_exit(); + } + my $result = $mail->send(-to => $smtp_to, + -from => $self->{option_results}->{email_smtp_from}, + -subject => $subject, + -body => $stdout, + -attachments => $self->{option_results}->{file_health_env}); + $mail->bye(); + if ($result == -1) { + $self->{output}->add_option_msg(severity => 'UNKNOWN', short_msg => "problem to send the email"); + } else { + $self->{output}->add_option_msg(severity => 'OK', short_msg => "email sent"); + } +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'module', 'temperature', 'director, 'cabling', 'power', 'voltage', 'sparedisk'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=temperature --filter=module) +Can also exclude specific instance: --filter=temperature,ES-PWS-A ES-4 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='director,WARNING,^(?!(OK)$)' + +=item B<--warning> + +Set warning threshold for disk (syntax: type,regexp,threshold) +Example: --warning='sparedisk,.*,5:' + +=item B<--critical> + +Set critical threshold for disk (syntax: type,regexp,threshold) +Example: --critical='sparedisk,.*,3:' + +=item B<--file-health> + +The location of the global storage file status (Should be something like: C:/xxxx/HealthCheck.log). + +=item B<--file-health-env> + +The location of the environment storage file status (Should be something like: C:/xxxx/sumpl_env_health.log). + +=back + +=cut + \ No newline at end of file diff --git a/storage/emc/symmetrix/vmax/local/plugin.pm b/storage/emc/symmetrix/vmax/local/plugin.pm new file mode 100644 index 000000000..18fc9a995 --- /dev/null +++ b/storage/emc/symmetrix/vmax/local/plugin.pm @@ -0,0 +1,48 @@ +# +# 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::vmax::local::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_simple); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'hardware' => 'storage::emc::symmetrix::vmax::local::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check vmax storage. The plugin needs to be installed on Windows Management. + +=cut