+ add symmetrix dmx34 plugin

This commit is contained in:
garnier-quentin 2016-04-23 18:11:57 +02:00
parent 63ee930b70
commit 3fb754568b
10 changed files with 946 additions and 0 deletions

View File

@ -0,0 +1,56 @@
#
# 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::config;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
# ---------[ Configuration Information ]---------
#
#...
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking config");
$self->{components}->{config} = {name => 'config', total => 0, skip => 0};
return if ($self->check_filter(section => 'config'));
if ($self->{content_file_health} !~ /----\[ Configuration Information(.*?)----\[/msi) {
$self->{output}->output_add(long_msg => 'skipping: cannot find config');
return ;
}
my $content = $1;
$self->{components}->{config}->{total}++;
# Error if not present:
# CODE OK!
if ($content !~ /CODE OK!/msi) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("problem of configuration"));
} else {
$self->{output}->output_add(long_msg => sprintf("no configuration problem detected"));
}
}
1;

View File

@ -0,0 +1,92 @@
#
# 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::director;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
# ---------------[ Director Status ]-------------
#
# 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16
#
# D ON .. .. .. .. .. .. ON ON .. .. .. .. .. .. ON
# C ON .. .. .. .. .. .. ON ON .. .. .. .. .. .. ON
# B ON .. .. .. .. .. .. DD ON .. .. .. .. .. .. ON
# A ON .. .. .. .. .. .. ON ON .. .. .. .. .. .. ON
#
# Key:
# ON - Director is online
# OF - Director is offline
# OF - DA is offline
# DD - Director is in DD state
# PR - Director is in Probe mode
# NC - Director is not comunicating
# ** - Director status is unknown
my %mapping = (
DD => 'DD state',
PR => 'Probe mode',
NC => 'not comunicating',
'**' => 'unknown',,
OF => 'offline',
ON => 'online',,
'..' => 'not configured',
);
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} !~ /---------------\[ Director Status(.*?)----\[/msi) {
$self->{output}->output_add(long_msg => 'skipping: cannot find directors');
return ;
}
my $content = $1;
while ($content =~ /\s([A-Z]\s+.*?)\n/msig) {
my ($director, @nums) = split /\s+/, $1;
my $i = 0;
foreach (@nums) {
$i++;
my $state = defined($mapping{$_}) ? $mapping{$_} : 'unknown';
my $instance = $director . '.' . $i;
next if ($self->check_filter(section => 'director', instance => $instance));
$self->{components}->{director}->{total}++;
$self->{output}->output_add(long_msg => sprintf("director '%s' state is '%s'",
$instance, $state));
my $exit = $self->get_severity(section => 'director', value => $state);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Director '%s' state is '%s'",
$instance, $state));
}
}
}
}
1;

View File

@ -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::netapp::snmp::mode::components::communication;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
my %map_com_states = (
1 => 'initializing',
2 => 'transitioning',
3 => 'active',
4 => 'inactive',
5 => 'reconfiguring',
6 => 'nonexistent',
);
my $oid_enclChannelShelfAddr = '.1.3.6.1.4.1.789.1.21.1.2.1.3';
my $oid_enclContactState = '.1.3.6.1.4.1.789.1.21.1.2.1.2';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_enclContactState };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking communications");
$self->{components}->{communication} = {name => 'communications', total => 0, skip => 0};
return if ($self->check_filter(section => 'communication'));
for (my $i = 1; $i <= $self->{number_shelf}; $i++) {
my $shelf_addr = $self->{shelf_addr}->{$oid_enclChannelShelfAddr . '.' . $i};
my $com_state = $map_com_states{$self->{results}->{$oid_enclContactState}->{$oid_enclContactState . '.' . $i}};
next if ($self->check_filter(section => 'communication', instance => $shelf_addr));
$self->{components}->{communication}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Shelve '%s' communication state is '%s'",
$shelf_addr, $com_state));
my $exit = $self->get_severity(section => 'communication', value => $com_state);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Shelve '%s' communication state is '%s'",
$shelf_addr, $com_state));
}
}
}
1;

View File

@ -0,0 +1,116 @@
#
# 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::disk;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
# ------------[ Device Information ]-------------
#
# RAID6 Configured: NO
# RAID5 Configured: NO
# RDF Configured: NO_RDF
# Verify Volume Status
# There are 16 local devices are not ready (device(DA)):- à 0 si pas de problème
# 10000(01a) 10072(01a) 20086(01a) 1009A(01a) 200AE(01a) 100C2(01a) 100EA(01a)
# 10112(01a) 20075(01d) 10089(01d) 2009D(01d) 100B1(01d) 100C9(01d) 100F1(01d)
# 10119(01d) 20061(01d)
#
# No local devices have invalid tracks
#
# Deferred disk service is NOT enabled
#
# 8 hot spares are configured, 1 are invoked, none are not ready à none si pas de problème
#
# HotSpare 16d:D5 is invoked against 1d:D4 Time: MAR/24/16 04:48:49 à récupérer si pb
#
# No DAs have any volumes with Not Ready bit set
#
# All DAs have Write Optimize enabled
#
# No devices have TimeFinder Lock
#
# No Devices Found in Transient State
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking disks");
$self->{components}->{disk} = {name => 'disks (1 means all)', total => 0, skip => 0};
return if ($self->check_filter(section => 'disk'));
if ($self->{content_file_health} !~ /----\[ Device Information(.*?)----\[/msi) {
$self->{output}->output_add(long_msg => 'skipping: cannot find devices');
return ;
}
my $content = $1;
$self->{components}->{disk}->{total}++;
# Error if not present:
# No local devices have invalid tracks
if ($content !~ /No local devices have invalid tracks/msi) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("problem of invalid tracks on disks"));
} else {
$self->{output}->output_add(long_msg => sprintf("no invalid tracks on disks"));
}
# Error if not present:
# All local devices are ready
if ($content !~ /All local devices are ready/msi) {
$content =~ /There are\s+(\S+)\s+local devices are not ready.*?\n(.*?)\n\s*\n/msi;
my ($num, $disks) = ($1, $2);
$disks =~ s/\n/ /msg;
$disks =~ s/\s+/ /msg;
$disks =~ s/^\s+//;
$self->{output}->output_add(long_msg => sprintf("problem on following disks '%s'", $disks));
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("problem on '%s' disks", $num));
} else {
$self->{output}->output_add(long_msg => sprintf("all devices are ready"));
}
return if ($content !~ /(\S+) hot spares are configured, (\S+) are invoked/msi);
my ($total, $used) = ($1, $2);
$used = 0 if ($used =~ /none/i);
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'disk', instance => '1', value => $total - $used);
$self->{output}->output_add(long_msg => sprintf("'%s' spare disk availables on '%s'",
$total - $used, $total));
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("'%s' spare disk availables on '%s'",
$total - $used, $total));
}
$self->{output}->perfdata_add(label => "disk_spare_available",
value => $total - $used,
warning => $warn,
critical => $crit, min => 0, max => $total);
}
1;

View File

@ -0,0 +1,56 @@
#
# 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;

View File

@ -0,0 +1,92 @@
#
# 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::memory;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
#------------[ Memory Information ]-------------
#
# Memory Size: 80 GB
# Cache start Addr: 00088000 (Hex)
# Cache start Bank: 00000022 (Hex)
# Cache last Addr: 01400000 (Hex)
# Cache last Bank: 000004FF (Hex)
#
# Board Number M0 M1 M2 M3 M4 M5 M6 M7
# Slot Number 10 11 12 13 14 15 16 17
# ----------------------------------------------------------
# Size (GB) 16 16 16 16 8 8 .. ..
# Mode OPER OPER OPER OPER OPER OPER .. ..
# Status OK OK OK OK OK OK .. ..
#
# Status Key
# OK - Board is operating normally
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking memory");
$self->{components}->{memory} = {name => 'memory', total => 0, skip => 0};
return if ($self->check_filter(section => 'memory'));
if ($self->{content_file_health} !~ /----\[ Memory Information(.*?)----\[/msi) {
$self->{output}->output_add(long_msg => 'skipping: cannot find memory');
return ;
}
my $content = $1;
$content =~ /Board Number\s+(.*?)\n/msi;
my @board_numbers = split /\s+/, $1;
$content =~ /Slot Number\s+(.*?)\n/msi;
my @slot_numbers = split /\s+/, $1;
$content =~ /Mode\s+(.*?)\n/msi;
my @modes = split /\s+/, $1;
$content =~ /Status\s+(.*?)\n/msi;
my @status = split /\s+/, $1;
my $i = -1;
foreach my $name (@board_numbers) {
$i++;
my $instance = $name . '#' . $slot_numbers[$i];
my $state = $modes[$i] . '/' . $status[$i];
next if ($self->check_filter(section => 'memory', instance => $instance));
$self->{components}->{memory}->{total}++;
$self->{output}->output_add(long_msg => sprintf("memory '%s' state is '%s'",
$instance, $state));
my $exit = $self->get_severity(section => 'memory', value => $state);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Memory '%s' state is '%s'",
$instance, $state));
}
}
}
1;

View File

@ -0,0 +1,60 @@
#
# 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::test;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
#--------------[ Director Tests ]---------------
#
# No offline pending DAs are present
# 1C test: All Directors Passed
# F2,SAME,,,EE test: All Directors Passed
# EE test: All Directors Passed
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking test");
$self->{components}->{test} = {name => 'test', total => 0, skip => 0};
return if ($self->check_filter(section => 'test'));
if ($self->{content_file_health} !~ /----\[ Director Tests(.*?)----\[/msi) {
$self->{output}->output_add(long_msg => 'skipping: cannot find tests');
return ;
}
my $content = $1;
$self->{components}->{test}->{total}++;
foreach (('No offline pending DAs are present', '1C test: All Directors Passed',
'F2,SAME,,,EE test: All Directors Passed', 'EE test: All Directors Passed')) {
if ($content !~ /$_/msi) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("test problem detected"));
} else {
$self->{output}->output_add(long_msg => sprintf("%s", $_));
}
}
}
1;

View File

@ -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::xcm;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
# --------------[ XCM Information ]--------------
#
#XCM/ECM/CCM status
# XCM0 XCM1
# EMUL EMUL
#
#Message Bus status
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking xcm");
$self->{components}->{xcm} = {name => 'xcm', total => 0, skip => 0};
return if ($self->check_filter(section => 'xcm'));
if ($self->{content_file_health} !~ /----\[ XCM Information(.*?)----\[/msi) {
$self->{output}->output_add(long_msg => 'skipping: cannot find xcm');
return ;
}
my $content = $1;
if ($content =~ /XCM\/ECM\/CCM status\s*\n\s*(.*?)\n\s*(.*?)\n\s*\n/msig) {
my @names = split /\s+/, $1;
my @status = split /\s+/, $2;
my $i = -1;
foreach my $name (@names) {
$i++;
my $instance = $name;
my $state = $status[$i];
next if ($self->check_filter(section => 'xcm', instance => $instance));
$self->{components}->{xcm}->{total}++;
$self->{output}->output_add(long_msg => sprintf("xcm '%s' state is '%s'",
$instance, $state));
my $exit = $self->get_severity(section => 'xcm', value => $state);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("XCM '%s' state is '%s'",
$instance, $state));
}
}
}
}
1;

View File

@ -0,0 +1,281 @@
#
# 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::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} = '^(disk)$';
$self->{cb_hook1} = 'read_files';
$self->{cb_hook4} = 'send_email';
$self->{thresholds} = {
director => [
['DD state', 'CRITICAL'],
['Probe mode', 'CRITICAL'],
['not comunicating', 'CRITICAL'],
['unknown', 'CRITICAL'],
['offline', 'OK'],
['online', 'OK'],
['not configured', 'OK'],
],
xcm => [
['emul', 'OK'],
['.*', 'CRITICAL'],
],
memory => [
['OPER/OK', 'OK'],
['\.\./.*', 'OK'],
['.*', 'CRITICAL'],
],
};
$self->{components_path} = 'storage::emc::symmetrix::dmx34::local::mode::components';
$self->{components_module} = ['director', 'xcm', 'disk', 'memory', 'config', 'environment', 'test'];
}
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();
}
$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;
# *****************************************************************
#* Health Check Run From Scheduler Version 2.0 *
#* *
#* Serial: 000290103984 Run Time: 03/24/2016 12:27:07 *
#* Run Type: FULL Code Level: 5773-184-130 *
#*****************************************************************
my ($serial, $site) = ('unknown', 'unknown');
$serial = $1 if ($self->{content_file_health} =~ /Serial:\s*(\S+)/msi);
$self->{output}->output_add(long_msg => sprintf('serial number: %s, site name: %s', $serial, $site));
}
#
# 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}->{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_dmx34_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');
}
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: 'director', 'xcm', 'disk', 'memory', 'config', 'environment', 'test'
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=director --filter=xcm)
Can also exclude specific instance: --filter=director,1
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='director,CRITICAL,^(?!(online)$)'
=item B<--warning>
Set warning threshold for disk (syntax: type,regexp,threshold)
Example: --warning='disk,.*,5:'
=item B<--critical>
Set critical threshold for disk (syntax: type,regexp,threshold)
Example: --critical='disk,.*,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/HealthCheck_ENV.log).
=back
=cut

View File

@ -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::dmx34::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::dmx34::local::mode::hardware',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check symmetrix DMX 3 and 4. The plugin needs to be installed on Windows Management.
=cut