From ff97d944fde138884c88a09c96a130ce286e43ce Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Wed, 3 Sep 2014 14:45:01 +0200 Subject: [PATCH] Refs #5425 Some new modes for clariion --- centreon-plugins/storage/emc/clariion/TODO | 641 ------------------ .../storage/emc/clariion/custom.pm | 2 +- .../storage/emc/clariion/mode/hbastate.pm | 201 ++++++ .../storage/emc/clariion/mode/portstate.pm | 159 +++++ .../storage/emc/clariion/mode/sp.pm | 16 +- .../storage/emc/clariion/plugin.pm | 2 + 6 files changed, 374 insertions(+), 647 deletions(-) create mode 100644 centreon-plugins/storage/emc/clariion/mode/hbastate.pm create mode 100644 centreon-plugins/storage/emc/clariion/mode/portstate.pm diff --git a/centreon-plugins/storage/emc/clariion/TODO b/centreon-plugins/storage/emc/clariion/TODO index c541a993e..5608eb28a 100644 --- a/centreon-plugins/storage/emc/clariion/TODO +++ b/centreon-plugins/storage/emc/clariion/TODO @@ -88,644 +88,3 @@ Free Capacity (Blocks,non-contiguous): 1442538706 Percent defragmented: 100 Percent expanded: 100 RaidGroup State: Valid_luns - -====================== -Mode pour les ports -====================== - -The output of the command (on ne peut pas filter par element): getall -hba -Server IP Address: 192.168.7.156 -Agent Rev: 6.26.0 (2.19) - - -HBA Information ---------------- - - -Total number of initiators: 16 - -SP Name: SP A -SP Port ID: 4 -Registered Initiators: 5 -Logged-In Initiators: 2 -Not Logged-In Initiators: 3 - -SP Name: SP A -SP Port ID: 5 -Registered Initiators: 2 -Logged-In Initiators: 1 -Not Logged-In Initiators: 1 - -SP Name: SP B -SP Port ID: 4 -Registered Initiators: 6 -Logged-In Initiators: 4 -Not Logged-In Initiators: 2 - -SP Name: SP B -SP Port ID: 5 -Registered Initiators: 3 -Logged-In Initiators: 1 -Not Logged-In Initiators: 2 - -SP Name: SP A -SP Port ID: 2 -Registered Initiators: 0 -Logged-In Initiators: 0 -Not Logged-In Initiators: 0 - -SP Name: SP A -SP Port ID: 3 -Registered Initiators: 0 -Logged-In Initiators: 0 -Not Logged-In Initiators: 0 - -SP Name: SP A -SP Port ID: 0 -Registered Initiators: 0 -Logged-In Initiators: 0 -Not Logged-In Initiators: 0 - -SP Name: SP A -SP Port ID: 1 -Registered Initiators: 0 -Logged-In Initiators: 0 -Not Logged-In Initiators: 0 - -SP Name: SP B -SP Port ID: 2 -Registered Initiators: 0 -Logged-In Initiators: 0 -Not Logged-In Initiators: 0 - -SP Name: SP B -SP Port ID: 3 -Registered Initiators: 0 -Logged-In Initiators: 0 -Not Logged-In Initiators: 0 - -SP Name: SP B -SP Port ID: 0 -Registered Initiators: 0 -Logged-In Initiators: 0 -Not Logged-In Initiators: 0 - -SP Name: SP B -SP Port ID: 1 -Registered Initiators: 0 -Logged-In Initiators: 0 -Not Logged-In Initiators: 0 - - -Information about each HBA: - -HBA UID: 20:00:00:1B:32:89:97:AD:21:00:00:1B:32:89:97:AD -Server Name: SERVER-v3108.INTERACT.AD -Server IP Address: UNKNOWN -HBA Model Description: @oem27.inf,%ql2300.devicedesc%;QLogic Fibre Channel Adapter -HBA Vendor Description: @oem27.inf,%qlogic%;QLogic -HBA Device Driver Name: ql2300 -Information about each port of this HBA: - - SP Name: SP B - SP Port ID: 4 - HBA Devicename: PwrP:SCSI3:0:1:0 - Trusted: NO - Logged In: YES - Source ID: 69376 - Defined: YES - Initiator Type: 3 - StorageGroup Name: Soft - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - SP Name: SP A - SP Port ID: 4 - HBA Devicename: PwrP:SCSI3:0:0:0 - Trusted: NO - Logged In: YES - Source ID: 69376 - Defined: YES - Initiator Type: 3 - StorageGroup Name: Soft - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - -Information about each HBA: - -HBA UID: 20:00:00:00:C9:40:60:37:10:00:00:00:C9:40:60:37 -Server Name: AUGUSTE -Server IP Address: 192.168.7.150 -HBA Model Description: Emulex LightPulse HBA - Multi-protocol Port Driver -HBA Vendor Description: Emulex -HBA Device Driver Name: elxsli2 -Information about each port of this HBA: - - SP Name: SP B - SP Port ID: 4 - HBA Devicename: \\.\SCSI5:0:14:0 - Trusted: NO - Logged In: YES - Source ID: 69632 - Defined: YES - Initiator Type: 3 - StorageGroup Name: auguste - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - -Information about each HBA: - -HBA UID: 20:01:00:1B:32:27:4B:FD:21:01:00:1B:32:27:4B:FD -Server Name: CESAR -Server IP Address: 192.168.7.155 -HBA Model Description: @oem36.inf,%ql2300.devicedesc%;QLogic Fibre Channel Adapter -HBA Vendor Description: @oem36.inf,%qlogic%;QLogic -HBA Device Driver Name: ql2300 -Information about each port of this HBA: - - SP Name: SP B - SP Port ID: 5 - HBA Devicename: PwrP:SCSI5:0:0:0 - Trusted: NO - Logged In: YES - Source ID: 91136 - Defined: YES - Initiator Type: 3 - StorageGroup Name: Eftp - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - SP Name: SP A - SP Port ID: 4 - HBA Devicename: PwrP:SCSI4:0:1:0 - Trusted: NO - Logged In: NO - Defined: YES - Initiator Type: 3 - StorageGroup Name: Eftp - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - SP Name: SP B - SP Port ID: 4 - HBA Devicename: \\.\SCSI5:0:1:0 - Trusted: NO - Logged In: NO - Defined: YES - Initiator Type: 3 - StorageGroup Name: Eftp - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - -Information about each HBA: - -HBA UID: 20:00:00:1B:32:07:4B:FD:21:00:00:1B:32:07:4B:FD -Server Name: CESAR -Server IP Address: 192.168.7.155 -HBA Model Description: @oem36.inf,%ql2300.devicedesc%;QLogic Fibre Channel Adapter -HBA Vendor Description: @oem36.inf,%qlogic%;QLogic -HBA Device Driver Name: ql2300 -Information about each port of this HBA: - - SP Name: SP B - SP Port ID: 5 - HBA Devicename: \\.\SCSI3:0:4:0 - Trusted: NO - Logged In: NO - Defined: YES - Initiator Type: 3 - StorageGroup Name: Eftp - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - SP Name: SP A - SP Port ID: 4 - HBA Devicename: \\.\SCSI4:0:6:0 - Trusted: NO - Logged In: YES - Source ID: 98048 - Defined: YES - Initiator Type: 3 - StorageGroup Name: None - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - -Information about each HBA: - -HBA UID: 20:01:00:1B:32:28:6F:03:21:01:00:1B:32:28:6F:03 -Server Name: CESAR -Server IP Address: 192.168.7.155 -HBA Model Description: @oem36.inf,%ql2300.devicedesc%;QLogic Fibre Channel Adapter -HBA Vendor Description: @oem36.inf,%qlogic%;QLogic -HBA Device Driver Name: ql2300 -Information about each port of this HBA: - - SP Name: SP B - SP Port ID: 4 - HBA Devicename: PwrP:SCSI6:0:1:0 - Trusted: NO - Logged In: NO - Defined: YES - Initiator Type: 3 - StorageGroup Name: Eftp - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - SP Name: SP A - SP Port ID: 5 - HBA Devicename: PwrP:SCSI7:0:0:0 - Trusted: NO - Logged In: YES - Source ID: 70912 - Defined: YES - Initiator Type: 3 - StorageGroup Name: Eftp - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - SP Name: SP A - SP Port ID: 4 - HBA Devicename: \\.\SCSI7:0:1:0 - Trusted: NO - Logged In: NO - Defined: YES - Initiator Type: 3 - StorageGroup Name: Eftp - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - -Information about each HBA: - -HBA UID: 20:00:00:1B:32:08:6F:03:21:00:00:1B:32:08:6F:03 -Server Name: CESAR -Server IP Address: 192.168.7.155 -HBA Model Description: @oem36.inf,%ql2300.devicedesc%;QLogic Fibre Channel Adapter -HBA Vendor Description: @oem36.inf,%qlogic%;QLogic -HBA Device Driver Name: ql2300 -Information about each port of this HBA: - - SP Name: SP B - SP Port ID: 4 - HBA Devicename: \\.\SCSI6:0:1:0 - Trusted: NO - Logged In: YES - Source ID: 65536 - Defined: YES - Initiator Type: 3 - StorageGroup Name: None - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - -Information about each HBA: - -HBA UID: 20:00:00:1B:32:1A:84:CF:21:00:00:1B:32:1A:84:CF -Server Name: oberon -Server IP Address: 192.168.249.5 -HBA Model Description: -HBA Vendor Description: -HBA Device Driver Name: -Information about each port of this HBA: - - SP Name: SP B - SP Port ID: 4 - HBA Devicename: mpio0:c5t60060160F8C01E00282387A46D10E111d0s2 - Trusted: NO - Logged In: YES - Source ID: 68608 - Defined: YES - Initiator Type: 3 - StorageGroup Name: Cedric_Sun - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - SP Name: SP A - SP Port ID: 4 - HBA Devicename: c6t5006016041E06B78d0s7 - Trusted: NO - Logged In: NO - Defined: YES - Initiator Type: 3 - StorageGroup Name: None - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - SP Name: SP B - SP Port ID: 5 - HBA Devicename: c6t5006016941E06B78d0s3 - Trusted: NO - Logged In: NO - Defined: YES - Initiator Type: 3 - StorageGroup Name: None - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - - SP Name: SP A - SP Port ID: 5 - HBA Devicename: c6t5006016141E06B78d0s2 - Trusted: NO - Logged In: NO - Defined: YES - Initiator Type: 3 - StorageGroup Name: None - ArrayCommPath: 1 - Failover mode: 1 - Unit serial number: Array - -Information about each SPPORT: - -SP Name: SP A -SP Port ID: 4 -SP UID: 50:06:01:60:C1:E0:6B:78:50:06:01:60:41:E0:6B:78 -Link Status: Up -Port Status: Online -Switch Present: YES -Switch UID: 10:00:00:60:69:E4:22:4C:20:0E:00:60:69:E4:22:4C -SP Source ID: 69120 -ALPA Value: 0 -Speed Value : 2Gbps -Auto Negotiable : NO -Available Speeds: -1Gbps -2Gbps -4Gbps -Auto -Requested Value: Auto -MAC Address: Not Applicable -SFP State: Online -Reads: 0 -Writes: 0 -Blocks Read: 0 -Blocks Written: 0 -Queue Full/Busy: 0 - -SP Name: SP A -SP Port ID: 5 -SP UID: 50:06:01:60:C1:E0:6B:78:50:06:01:61:41:E0:6B:78 -Link Status: Up -Port Status: Online -Switch Present: YES -Switch UID: 10:00:00:60:69:E4:22:4C:20:65:00:60:69:E4:22:4C -SP Source ID: 91392 -ALPA Value: 0 -Speed Value : 2Gbps -Auto Negotiable : NO -Available Speeds: -1Gbps -2Gbps -4Gbps -Auto -Requested Value: Auto -MAC Address: Not Applicable -SFP State: Online -Reads: 6653814 -Writes: 401613 -Blocks Read: 2498922225 -Blocks Written: 325292333 -Queue Full/Busy: 0 - -SP Name: SP B -SP Port ID: 4 -SP UID: 50:06:01:60:C1:E0:6B:78:50:06:01:68:41:E0:6B:78 -Link Status: Up -Port Status: Online -Switch Present: YES -Switch UID: 10:00:00:60:69:E4:22:4C:20:0D:00:60:69:E4:22:4C -SP Source ID: 68864 -ALPA Value: 0 -Speed Value : 2Gbps -Auto Negotiable : NO -Available Speeds: -1Gbps -2Gbps -4Gbps -Auto -Requested Value: Auto -MAC Address: Not Applicable -SFP State: Online -Reads: 41886606 -Writes: 42365482 -Blocks Read: 3601845798 -Blocks Written: 1546828148 -Queue Full/Busy: 3 - -SP Name: SP B -SP Port ID: 5 -SP UID: 50:06:01:60:C1:E0:6B:78:50:06:01:69:41:E0:6B:78 -Link Status: Up -Port Status: Online -Switch Present: YES -Switch UID: 10:00:00:60:69:E4:22:4C:20:16:00:60:69:E4:22:4C -SP Source ID: 71168 -ALPA Value: 0 -Speed Value : 2Gbps -Auto Negotiable : NO -Available Speeds: -1Gbps -2Gbps -4Gbps -Auto -Requested Value: Auto -MAC Address: Not Applicable -SFP State: Online -Reads: 744257 -Writes: 325827 -Blocks Read: 1303741732 -Blocks Written: 324948212 -Queue Full/Busy: 0 - -SP Name: SP A -SP Port ID: 2 -SP UID: iqn.1992-04.com.emc:cx.ck200074800997.a2 -Link Status: Down -Port Status: Online -Switch Present: Not Applicable -Speed Value : N/A -Auto Negotiable : YES -Available Speeds: -1Gbps -10Mbps -100Mbps -Auto -Requested Value: Auto -MAC Address: 00:00:00:00:00:00 -SFP State: None -Reads: 0 -Writes: 0 -Blocks Read: 0 -Blocks Written: 0 -Queue Full/Busy: 0 - -SP Name: SP A -SP Port ID: 3 -SP UID: iqn.1992-04.com.emc:cx.ck200074800997.a3 -Link Status: Down -Port Status: Online -Switch Present: Not Applicable -Speed Value : N/A -Auto Negotiable : YES -Available Speeds: -1Gbps -10Mbps -100Mbps -Auto -Requested Value: Auto -MAC Address: 00:00:00:00:00:00 -SFP State: None -Reads: 0 -Writes: 0 -Blocks Read: 0 -Blocks Written: 0 -Queue Full/Busy: 0 - -SP Name: SP A -SP Port ID: 0 -SP UID: iqn.1992-04.com.emc:cx.ck200074800997.a0 -Link Status: Down -Port Status: Online -Switch Present: Not Applicable -Speed Value : N/A -Auto Negotiable : YES -Available Speeds: -1Gbps -10Mbps -100Mbps -Auto -Requested Value: Auto -MAC Address: 00:00:00:00:00:00 -SFP State: None -Reads: 0 -Writes: 0 -Blocks Read: 0 -Blocks Written: 0 -Queue Full/Busy: 0 - -SP Name: SP A -SP Port ID: 1 -SP UID: iqn.1992-04.com.emc:cx.ck200074800997.a1 -Link Status: Down -Port Status: Online -Switch Present: Not Applicable -Speed Value : N/A -Auto Negotiable : YES -Available Speeds: -1Gbps -10Mbps -100Mbps -Auto -Requested Value: Auto -MAC Address: 00:00:00:00:00:00 -SFP State: None -Reads: 0 -Writes: 0 -Blocks Read: 0 -Blocks Written: 0 -Queue Full/Busy: 0 - -SP Name: SP B -SP Port ID: 2 -SP UID: iqn.1992-04.com.emc:cx.ck200074800997.b2 -Link Status: Down -Port Status: Online -Switch Present: Not Applicable -Speed Value : N/A -Auto Negotiable : YES -Available Speeds: -1Gbps -10Mbps -100Mbps -Auto -Requested Value: Auto -MAC Address: 00:00:00:00:00:00 -SFP State: None -Reads: 0 -Writes: 0 -Blocks Read: 0 -Blocks Written: 0 -Queue Full/Busy: 0 - -SP Name: SP B -SP Port ID: 3 -SP UID: iqn.1992-04.com.emc:cx.ck200074800997.b3 -Link Status: Down -Port Status: Online -Switch Present: Not Applicable -Speed Value : N/A -Auto Negotiable : YES -Available Speeds: -1Gbps -10Mbps -100Mbps -Auto -Requested Value: Auto -MAC Address: 00:00:00:00:00:00 -SFP State: None -Reads: 0 -Writes: 0 -Blocks Read: 0 -Blocks Written: 0 -Queue Full/Busy: 0 - -SP Name: SP B -SP Port ID: 0 -SP UID: iqn.1992-04.com.emc:cx.ck200074800997.b0 -Link Status: Down -Port Status: Online -Switch Present: Not Applicable -Speed Value : N/A -Auto Negotiable : YES -Available Speeds: -1Gbps -10Mbps -100Mbps -Auto -Requested Value: Auto -MAC Address: 00:00:00:00:00:00 -SFP State: None -Reads: 0 -Writes: 0 -Blocks Read: 0 -Blocks Written: 0 -Queue Full/Busy: 0 - -SP Name: SP B -SP Port ID: 1 -SP UID: iqn.1992-04.com.emc:cx.ck200074800997.b1 -Link Status: Down -Port Status: Online -Switch Present: Not Applicable -Speed Value : N/A -Auto Negotiable : YES -Available Speeds: -1Gbps -10Mbps -100Mbps -Auto -Requested Value: Auto -MAC Address: 00:00:00:00:00:00 -SFP State: None -Reads: 0 -Writes: 0 -Blocks Read: 0 -Blocks Written: 0 -Queue Full/Busy: 0 - - diff --git a/centreon-plugins/storage/emc/clariion/custom.pm b/centreon-plugins/storage/emc/clariion/custom.pm index dfb06b94b..5201e59a8 100644 --- a/centreon-plugins/storage/emc/clariion/custom.pm +++ b/centreon-plugins/storage/emc/clariion/custom.pm @@ -146,7 +146,7 @@ sub build_command { } if (defined($self->{special_arg}) && $self->{special_arg} ne '') { - $self->{cmd} .= $self->{special_arg}; + $self->{cmd} .= ' ' . $self->{special_arg}; $self->{no_navicmd} = 1; # It's ok if we use a file. $self->{secure} = 1; diff --git a/centreon-plugins/storage/emc/clariion/mode/hbastate.pm b/centreon-plugins/storage/emc/clariion/mode/hbastate.pm new file mode 100644 index 000000000..2db07b53b --- /dev/null +++ b/centreon-plugins/storage/emc/clariion/mode/hbastate.pm @@ -0,0 +1,201 @@ +################################################################################ +# 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::hbastate; + +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 => + { + "filter-server:s" => { name => 'filter_server' }, + "filter-uid:s" => { name => 'filter_uid' }, + "path-status:s@" => { name => 'path_status' }, + }); + $self->{total_hba} = 0; + $self->{total_hba_noskip} = 0; + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (!defined($self->{option_results}->{path_status}) || scalar(@{$self->{option_results}->{path_status}}) == 0) { + $self->{output}->add_option_msg(short_msg => "Need to set --path-status option."); + $self->{output}->option_exit(); + } + my $i = 0; + foreach (@{$self->{option_results}->{path_status}}) { + my ($warning, $critical, $filter_uid, $filter_server) = split /,/; + + if (!defined($filter_uid) && !defined($filter_server)) { + $self->{output}->add_option_msg(short_msg => "Need to set a filter in --path-status '" . $_ . "' option."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'warning-' . $i, value => $warning)) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $warning . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical-' . $i, value => $critical)) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $critical . "'."); + $self->{output}->option_exit(); + } + $i++; + } +} + +sub check_hba { + my ($self, %options) = @_; + + my @result = split /Information about each HBA/i, $self->{response}; + foreach (@result) { + my $hba_infos = $_; + + # Not in hba section. we move. + next if ($hba_infos !~ /^HBA UID:\s*(\S*)/mi); + my $hba_uid = $1; + $hba_infos =~ /^Server Name:\s*(.*?)\s*$/mi; + my $server_name = $1; + + $self->{total_hba}++; + if (defined($self->{option_results}->{filter_server}) && $self->{option_results}->{filter_server} ne '' && $server_name !~ /$self->{option_results}->{filter_server}/) { + $self->{output}->output_add(long_msg => "Skipping hba '$hba_uid' server '$server_name'"); + next; + } + if (defined($self->{option_results}->{filter_uid}) && $self->{option_results}->{filter_uid} ne '' && $hba_uid !~ /$self->{option_results}->{filter_uid}/) { + $self->{output}->output_add(long_msg => "Skipping hba '$hba_uid' server '$server_name'"); + next; + } + $self->{total_hba_noskip}++; + + $self->{output}->output_add(long_msg => "Checking hba '$hba_uid' server '$server_name'"); + + my $not_logged = 0; + my $logged = 0; + while ($hba_infos =~ /(SP Name:.*?)\n\n/msig) { + my $port_infos = $1; + + # Not in good section + next if ($port_infos !~ /HBA Devicename:/mi); + $port_infos =~ /SP Name:\s*(.*?)\s*$/mi; + my $port_name = $1; + $port_infos =~ /SP Port ID:\s*(.*?)\s*$/mi; + my $port_id = $1; + $port_infos =~ /Logged In:\s*(.*?)\s*$/mi; + my $logged_in = $1; + if ($logged_in !~ /YES/i) { + $not_logged++; + } else { + $logged++; + } + $self->{output}->output_add(long_msg => " port [sp name: $port_name] [sp port id: $port_id] logged is $logged_in"); + } + + # Do the checking + my $i = -1; + foreach (@{$self->{option_results}->{path_status}}) { + my ($warning, $critical, $filter_uid, $filter_server) = split /,/; + $i++; + + next if (defined($filter_uid) && $filter_uid ne '' && $hba_uid !~ /$filter_uid/); + next if (defined($filter_server) && $filter_server ne '' && $server_name !~ /$filter_server/); + + + my $exit = $self->{perfdata}->threshold_check(value => $logged, + threshold => [ { label => 'critical-' . $i, 'exit_litteral' => 'critical' }, { label => 'warning-' . $i, exit_litteral => 'warning' } ]); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => "Path connection problem for hba '$hba_uid' server '$server_name'"); + } + + last; + } + } +} + +sub run { + my ($self, %options) = @_; + my $clariion = $options{custom}; + + $self->{response} = $clariion->execute_command(cmd => 'getall -hba'); + chomp $self->{response}; + + $self->check_hba(); + + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("All hba states (%s/%s) are ok.", + $self->{total_hba_noskip}, $self->{total_hba}) + ); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check connection state of servers. + +=over 8 + +=item B<--filter-server> + +Set server to check (not set, means 'all'). + +=item B<--filter-uid> + +Set hba uid to check (not set, means 'all'). + +=item B<--path-status> + +Set how much path must be connected (Can be multiple). +Syntax: [WARNING],[CRITICAL],filter_uid,filter_server +Example: ,,@0:1,.* - Means all server must have at least two paths connected. + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/storage/emc/clariion/mode/portstate.pm b/centreon-plugins/storage/emc/clariion/mode/portstate.pm new file mode 100644 index 000000000..da8bb850b --- /dev/null +++ b/centreon-plugins/storage/emc/clariion/mode/portstate.pm @@ -0,0 +1,159 @@ +################################################################################ +# Copyright 2005-2014 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package storage::emc::clariion::mode::portstate; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-name:s" => { name => 'filter_name' }, + "filter-id:s" => { name => 'filter_id' }, + }); + $self->{total_port} = 0; + $self->{total_port_noskip} = 0; + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub check_logged { + my ($self, %options) = @_; + + +} + +sub check_port { + my ($self, %options) = @_; + + if ($self->{response} =~ /Information about each SPPORT:(.*)/msi) { + my $port_infos = $1; + + while ($port_infos =~ /(SP Name:.*?)\n\n/msig) { + my $port_infos = $1; + + # Not in good section + next if ($port_infos !~ /Switch Present:/mi); + $port_infos =~ /SP Name:\s*(.*?)\s*$/mi; + my $port_name = $1; + $port_infos =~ /SP Port ID:\s*(.*?)\s*$/mi; + my $port_id = $1; + $port_infos =~ /Link Status:\s*(.*?)\s*$/mi; + my $link_status = $1; + $port_infos =~ /Port Status:\s*(.*?)\s*$/mi; + my $port_status = $1; + + $self->{total_port}++; + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $port_name !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping SP $port_name port $port_id [link status: $link_status] [port status: $port_status]"); + next; + } + if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' && $port_id !~ /$self->{option_results}->{filter_id}/) { + $self->{output}->output_add(long_msg => "Skipping SP $port_name port $port_id [link status: $link_status] [port status: $port_status]"); + next; + } + $self->{total_port_noskip}++; + + $self->{output}->output_add(long_msg => "Checking SP $port_name port $port_id [link status: $link_status] [port status: $port_status]"); + my ($error, $error_append) = ('', ''); + if ($port_status !~ /Online|Enabled/i) { + $error = "port status is '" . $port_status . "'"; + $error_append = ', '; + } + if ($link_status !~ /Up/i) { + $error .= $error_append . "link status is '" . $link_status . "'"; + } + if ($error ne '') { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("SP %s port %s: %s.", + $port_name, $port_id, $error) + ); + } + } + } +} + +sub run { + my ($self, %options) = @_; + my $clariion = $options{custom}; + + $self->{response} = $clariion->execute_command(cmd => 'getall -hba'); + chomp $self->{response}; + + $self->check_port(); + + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("All ports (%s/%s) are ok.", + $self->{total_port_noskip}, $self->{total_port}) + ); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check SP port states. + +=over 8 + +=item B<--filter-name> + +Set SP Name to check (not set, means 'all'). + +=item B<--filter-id> + +Set SP port ID to check (not set, means 'all'). + +=back + +=cut \ No newline at end of file diff --git a/centreon-plugins/storage/emc/clariion/mode/sp.pm b/centreon-plugins/storage/emc/clariion/mode/sp.pm index ff34f6150..c6333022f 100644 --- a/centreon-plugins/storage/emc/clariion/mode/sp.pm +++ b/centreon-plugins/storage/emc/clariion/mode/sp.pm @@ -57,10 +57,11 @@ sub new { $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' }, + { + "getcrus-options:s" => { name => 'getcrus_options', default => '-all' }, + "exclude:s" => { name => 'exclude' }, + "component:s" => { name => 'component', default => 'all' }, + "no-component:s" => { name => 'no_component' }, }); $self->{components} = {}; @@ -145,7 +146,7 @@ sub run { my ($self, %options) = @_; my $clariion = $options{custom}; - $self->{response} = $clariion->execute_command(cmd => 'getcrus -all'); + $self->{response} = $clariion->execute_command(cmd => 'getcrus ' . $self->{option_results}->{getcrus_options}); chomp $self->{response}; $self->component(); @@ -180,6 +181,11 @@ Check status of storage processor. =over 8 +=item B<--getcrus-options> + +Set option for 'getcrus' command (Default: '-all'). +'-all' option is for some new flare version. + =item B<--component> Which component to check (Default: 'all'). diff --git a/centreon-plugins/storage/emc/clariion/plugin.pm b/centreon-plugins/storage/emc/clariion/plugin.pm index bbf179936..5890aa45f 100644 --- a/centreon-plugins/storage/emc/clariion/plugin.pm +++ b/centreon-plugins/storage/emc/clariion/plugin.pm @@ -54,6 +54,8 @@ sub new { 'faults' => 'storage::emc::clariion::mode::faults', 'list-luns' => 'storage::emc::clariion::mode::listluns', 'sp-info' => 'storage::emc::clariion::mode::spinfo', + 'port-state' => 'storage::emc::clariion::mode::portstate', + 'hba-state' => 'storage::emc::clariion::mode::hbastate', ); $self->{custom_modes}{clariion} = 'storage::emc::clariion::custom';