| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package storage::hp::3par::ssh::mode::components::port; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
sub load { |
| 27 |
my ($self) = @_; |
| 28 |
|
| 29 |
#N:S:P Mode State ----Node_WWN---- -Port_WWN/HW_Addr- Type Protocol Label Partner FailoverState |
| 30 |
#0:0:1 initiator ready 50002ACFF70047C0 50002AC0010047C0 disk SAS DP-1 - - |
| 31 |
#0:0:2 initiator ready 50002ACFF70047C0 50002AC0020047C0 disk SAS DP-2 - - |
| 32 |
#0:1:1 target ready 2FF70002AC0047C0 20110002AC0047C0 host FC - 1:1:1 none |
| 33 |
#0:1:2 target ready 2FF70002AC0047C0 20120002AC0047C0 host FC - 1:1:2 none |
| 34 |
#0:2:1 initiator ready 2FF70002AC0047C0 20210002AC0047C0 rcfc FC - - - |
| 35 |
#0:2:2 target ready 2FF70002AC0047C0 20220002AC0047C0 host FC - - - |
| 36 |
#0:2:3 target ready 2FF70002AC0047C0 20230002AC0047C0 host FC - 1:2:3 none |
| 37 |
#0:2:4 target ready 2FF70002AC0047C0 20240002AC0047C0 host FC - 1:2:4 none |
| 38 |
#0:3:1 peer offline - B4B52FA71D43 free IP IP0 - - |
| 39 |
#1:0:1 initiator ready 50002ACFF70047C0 50002AC1010047C0 disk SAS DP-1 - - |
| 40 |
#1:0:2 initiator ready 50002ACFF70047C0 50002AC1020047C0 disk SAS DP-2 - - |
| 41 |
push @{$self->{commands}}, 'echo "===showport==="', 'showport'; |
| 42 |
} |
| 43 |
|
| 44 |
sub check { |
| 45 |
my ($self) = @_; |
| 46 |
|
| 47 |
$self->{output}->output_add(long_msg => "Checking ports"); |
| 48 |
$self->{components}->{port} = { name => 'ports', total => 0, skip => 0 }; |
| 49 |
return if ($self->check_filter(section => 'port')); |
| 50 |
|
| 51 |
return if ($self->{results} !~ /===showport===.*?\n(.*?)(===|\Z)/msi); |
| 52 |
my @results = split /\n/, $1; |
| 53 |
|
| 54 |
foreach (@results) { |
| 55 |
next if (!/^(\d+:\d+:\d+)\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)/); |
| 56 |
my ($nsp, $state, $type) = ($1, $2, $3); |
| 57 |
my $instance = $type . '.' . $nsp; |
| 58 |
|
| 59 |
next if ($self->check_filter(section => 'port', instance => $instance)); |
| 60 |
$self->{components}->{port}->{total}++; |
| 61 |
|
| 62 |
$self->{output}->output_add( |
| 63 |
long_msg => sprintf( |
| 64 |
"port '%s' state is '%s' [instance: '%s']", |
| 65 |
$nsp, $state, $instance |
| 66 |
) |
| 67 |
); |
| 68 |
|
| 69 |
my $exit = $self->get_severity(section => 'port', value => $state); |
| 70 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 71 |
$self->{output}->output_add( |
| 72 |
severity => $exit, |
| 73 |
short_msg => sprintf( |
| 74 |
"port '%s' state is '%s'", |
| 75 |
$nsp, $state |
| 76 |
) |
| 77 |
); |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
1; |