From 951ffdda94fc723d8fd57ecf0e3bea7af1cf2f8c Mon Sep 17 00:00:00 2001 From: qgarnier Date: Fri, 28 Apr 2023 10:08:10 +0200 Subject: [PATCH] (plugin) storage::ibm::storwize::ssh - mode hardware add option --add-name-instance (#4391) --- src/centreon/plugins/templates/hardware.pm | 4 +++- .../ibm/storwize/ssh/mode/components/array.pm | 10 ++++++++-- .../ibm/storwize/ssh/mode/components/drive.pm | 2 +- .../ibm/storwize/ssh/mode/components/enclosure.pm | 4 ++-- .../ssh/mode/components/enclosurebattery.pm | 9 +++++++-- .../ssh/mode/components/enclosurecanister.pm | 4 ++-- .../storwize/ssh/mode/components/enclosurepsu.pm | 4 ++-- .../ibm/storwize/ssh/mode/components/host.pm | 6 +++--- .../ibm/storwize/ssh/mode/components/mdisk.pm | 6 +++--- .../ibm/storwize/ssh/mode/components/node.pm | 6 +++--- .../ibm/storwize/ssh/mode/components/portfc.pm | 9 +++++---- .../ibm/storwize/ssh/mode/components/portsas.pm | 9 +++++---- .../ibm/storwize/ssh/mode/components/quorum.pm | 12 +++++++++--- .../storwize/ssh/mode/components/systemstats.pm | 10 +++++++--- .../ibm/storwize/ssh/mode/components/vdisk.pm | 12 +++++++++--- src/storage/ibm/storwize/ssh/mode/hardware.pm | 14 +++++++++----- 16 files changed, 78 insertions(+), 43 deletions(-) diff --git a/src/centreon/plugins/templates/hardware.pm b/src/centreon/plugins/templates/hardware.pm index 3f480e68a..923ef69a3 100644 --- a/src/centreon/plugins/templates/hardware.pm +++ b/src/centreon/plugins/templates/hardware.pm @@ -453,7 +453,9 @@ sub get_severity { my ($self, %options) = @_; my $status = 'UNKNOWN'; # default - foreach (@{$self->{overload_th}}) { + $options{instance} .= '#' . $options{name} if (defined($self->{option_results}->{add_name_instance}) && defined($options{name})); + + foreach (@{$self->{overload_th}}) { if ($options{section} =~ /$_->{section}/i) { if ($options{value} =~ /$_->{filter}/i && (!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) { diff --git a/src/storage/ibm/storwize/ssh/mode/components/array.pm b/src/storage/ibm/storwize/ssh/mode/components/array.pm index 84412d6e1..63e7d285f 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/array.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/array.pm @@ -41,7 +41,7 @@ sub check { my $result = $self->{custom}->get_hasharray(content => $content, delim => ':'); foreach (@$result) { - next if ($self->check_filter(section => 'array', instance => $_->{mdisk_id})); + next if ($self->check_filter(section => 'array', instance => $_->{mdisk_id}, name => $_->{mdisk_name})); $self->{components}->{array}->{total}++; $self->{output}->output_add( @@ -52,7 +52,13 @@ sub check { $_->{mdisk_id} ) ); - my $exit = $self->get_severity(label => 'default', section => 'array', value => $_->{status}); + my $exit = $self->get_severity( + label => 'default', + section => 'array', + instance => $_->{mdisk_id}, + name => $_->{mdisk_name}, + value => $_->{status} + ); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/drive.pm b/src/storage/ibm/storwize/ssh/mode/components/drive.pm index 5d8656de0..237c487b4 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/drive.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/drive.pm @@ -51,7 +51,7 @@ sub check { $_->{id} ) ); - my $exit = $self->get_severity(label => 'default', section => 'drive', value => $_->{status}); + my $exit = $self->get_severity(label => 'default', section => 'drive', instance => $_->{id}, value => $_->{status}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/enclosure.pm b/src/storage/ibm/storwize/ssh/mode/components/enclosure.pm index 1f89e0091..d910f373b 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/enclosure.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/enclosure.pm @@ -46,13 +46,13 @@ sub check { $self->{output}->output_add( long_msg => sprintf( - "enclosure '%s' status is '%s' [instance: %s].", + "enclosure '%s' status is '%s' [instance: %s]", $_->{id}, $_->{status}, $_->{id} ) ); - my $exit = $self->get_severity(label => 'default', section => 'enclosure', value => $_->{status}); + my $exit = $self->get_severity(label => 'default', section => 'enclosure', instance => $_->{id}, value => $_->{status}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/enclosurebattery.pm b/src/storage/ibm/storwize/ssh/mode/components/enclosurebattery.pm index 4a1bc03e8..9b1ec3c30 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/enclosurebattery.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/enclosurebattery.pm @@ -47,13 +47,18 @@ sub check { $self->{output}->output_add( long_msg => sprintf( - "enclosure battery '%s' status is '%s' [instance: %s].", + "enclosure battery '%s' status is '%s' [instance: %s]", $instance, $_->{status}, $instance ) ); - my $exit = $self->get_severity(label => 'default', section => 'enclosurebattery', value => $_->{status}); + my $exit = $self->get_severity( + label => 'default', + section => 'enclosurebattery', + instance => $instance, + value => $_->{status} + ); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/enclosurecanister.pm b/src/storage/ibm/storwize/ssh/mode/components/enclosurecanister.pm index 1ca5c304e..f7f96de0a 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/enclosurecanister.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/enclosurecanister.pm @@ -47,13 +47,13 @@ sub check { $self->{output}->output_add( long_msg => sprintf( - "enclosure canister '%s' status is '%s' [instance: %s].", + "enclosure canister '%s' status is '%s' [instance: %s]", $instance, $_->{status}, $instance ) ); - my $exit = $self->get_severity(label => 'default', section => 'enclosurecanister', value => $_->{status}); + my $exit = $self->get_severity(label => 'default', section => 'enclosurecanister', instance => $instance, value => $_->{status}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/enclosurepsu.pm b/src/storage/ibm/storwize/ssh/mode/components/enclosurepsu.pm index a9d54de73..807a6b0a4 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/enclosurepsu.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/enclosurepsu.pm @@ -47,13 +47,13 @@ sub check { $self->{output}->output_add( long_msg => sprintf( - "enclosure power supply '%s' status is '%s' [instance: %s].", + "enclosure power supply '%s' status is '%s' [instance: %s]", $instance, $_->{status}, $instance ) ); - my $exit = $self->get_severity(label => 'default', section => 'enclosurepsu', value => $_->{status}); + my $exit = $self->get_severity(label => 'default', section => 'enclosurepsu', instance => $instance, value => $_->{status}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/host.pm b/src/storage/ibm/storwize/ssh/mode/components/host.pm index 998cbae8e..1d286e7b8 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/host.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/host.pm @@ -41,18 +41,18 @@ sub check { my $result = $self->{custom}->get_hasharray(content => $content, delim => ':'); foreach (@$result) { - next if ($self->check_filter(section => 'host', instance => $_->{id})); + next if ($self->check_filter(section => 'host', instance => $_->{id}, name => $_->{name})); $self->{components}->{host}->{total}++; $self->{output}->output_add( long_msg => sprintf( - "host '%s' status is '%s' [instance: %s].", + "host '%s' status is '%s' [instance: %s]", $_->{name}, $_->{status}, $_->{id} ) ); - my $exit = $self->get_severity(label => 'default', section => 'host', value => $_->{status}); + my $exit = $self->get_severity(label => 'default', section => 'host',instance => $_->{id}, name => $_->{name}, value => $_->{status}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/mdisk.pm b/src/storage/ibm/storwize/ssh/mode/components/mdisk.pm index 4254cb4f5..292b68931 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/mdisk.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/mdisk.pm @@ -41,18 +41,18 @@ sub check { my $result = $self->{custom}->get_hasharray(content => $content, delim => ':'); foreach (@$result) { - next if ($self->check_filter(section => 'mdisk', instance => $_->{id})); + next if ($self->check_filter(section => 'mdisk', instance => $_->{id}, name => $_->{name})); $self->{components}->{mdisk}->{total}++; $self->{output}->output_add( long_msg => sprintf( - "mdisk '%s' status is '%s' [instance: %s].", + "mdisk '%s' status is '%s' [instance: %s]", $_->{name}, $_->{status}, $_->{id} ) ); - my $exit = $self->get_severity(section => 'mdisk', value => $_->{status}); + my $exit = $self->get_severity(section => 'mdisk', instance => $_->{id}, name => $_->{name}, value => $_->{status}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/node.pm b/src/storage/ibm/storwize/ssh/mode/components/node.pm index 27b58b24d..bef90b392 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/node.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/node.pm @@ -41,18 +41,18 @@ sub check { my $result = $self->{custom}->get_hasharray(content => $content, delim => ':'); foreach (@$result) { - next if ($self->check_filter(section => 'node', instance => $_->{id})); + next if ($self->check_filter(section => 'node', instance => $_->{id}, name => $_->{name})); $self->{components}->{node}->{total}++; $self->{output}->output_add( long_msg => sprintf( - "node '%s' status is '%s' [instance: %s].", + "node '%s' status is '%s' [instance: %s]", $_->{name}, $_->{status}, $_->{id} ) ); - my $exit = $self->get_severity(label => 'default', section => 'node', value => $_->{status}); + my $exit = $self->get_severity(label => 'default', section => 'node', instance => $_->{id}, name => $_->{name}, value => $_->{status}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/portfc.pm b/src/storage/ibm/storwize/ssh/mode/components/portfc.pm index c2ae85b2a..4ea13afc2 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/portfc.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/portfc.pm @@ -41,19 +41,20 @@ sub check { my $result = $self->{custom}->get_hasharray(content => $content, delim => ':'); foreach (@$result) { - next if ($self->check_filter(section => 'portfc', instance => $_->{id})); + my $name = $_->{node_name} . "." . $_->{WWPN}; + + next if ($self->check_filter(section => 'portfc', instance => $_->{id}, name => $name)); $self->{components}->{portfc}->{total}++; - my $name = $_->{node_name} . "." . $_->{WWPN}; $self->{output}->output_add( long_msg => sprintf( - "portfc '%s' status is '%s' [instance: %s].", + "portfc '%s' status is '%s' [instance: %s]", $name, $_->{status}, $_->{id} ) ); - my $exit = $self->get_severity(section => 'portfc', value => $_->{status}); + my $exit = $self->get_severity(section => 'portfc', instance => $_->{id}, name => $name, value => $_->{status}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/portsas.pm b/src/storage/ibm/storwize/ssh/mode/components/portsas.pm index b38809b23..27785038e 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/portsas.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/portsas.pm @@ -41,19 +41,20 @@ sub check { my $result = $self->{custom}->get_hasharray(content => $content, delim => ':'); foreach (@$result) { - next if ($self->check_filter(section => 'portsas', instance => $_->{id})); + my $name = $_->{node_name} . '.' . $_->{WWPN}; + + next if ($self->check_filter(section => 'portsas', instance => $_->{id}, name => $name)); $self->{components}->{portsas}->{total}++; - my $name = $_->{node_name} . "." . $_->{WWPN}; $self->{output}->output_add( long_msg => sprintf( - "port sas '%s' status is '%s' [instance: %s].", + "port sas '%s' status is '%s' [instance: %s]", $name, $_->{status}, $_->{id} ) ); - my $exit = $self->get_severity(section => 'portsas', value => $_->{status}); + my $exit = $self->get_severity(section => 'portsas', instance => $_->{id}, name => $name, value => $_->{status}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/quorum.pm b/src/storage/ibm/storwize/ssh/mode/components/quorum.pm index 10e20e06e..5561c191d 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/quorum.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/quorum.pm @@ -41,18 +41,24 @@ sub check { my $result = $self->{custom}->get_hasharray(content => $content, delim => ':'); foreach (@$result) { - next if ($self->check_filter(section => 'quorum', instance => $_->{quorum_index})); + next if ($self->check_filter(section => 'quorum', instance => $_->{quorum_index}, name => $_->{controller_name})); $self->{components}->{quorum}->{total}++; $self->{output}->output_add( long_msg => sprintf( - "quorum '%s' status is '%s' [instance: %s].", + "quorum '%s' status is '%s' [instance: %s]", $_->{controller_name}, $_->{status}, $_->{quorum_index} ) ); - my $exit = $self->get_severity(label => 'default', section => 'quorum', value => $_->{status}); + my $exit = $self->get_severity( + label => 'default', + section => 'quorum', + instance => $_->{quorum_index}, + name => $_->{controller_name}, + value => $_->{status} + ); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/systemstats.pm b/src/storage/ibm/storwize/ssh/mode/components/systemstats.pm index 02143e629..d6dc46103 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/systemstats.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/systemstats.pm @@ -41,18 +41,22 @@ sub check { my $result = $self->{custom}->get_hasharray(content => $content, delim => '\s+'); foreach (@$result) { - next if ($self->check_filter(section => 'systemstats', instance => $_->{stat_name})); + next if ($self->check_filter(section => 'systemstats', instance => $_->{stat_name}, name => $_->{stat_name})); $self->{components}->{systemstats}->{total}++; $self->{output}->output_add( long_msg => sprintf( - "system stat '%s' value is '%s' [instance: %s].", + "system stat '%s' value is '%s' [instance: %s]", $_->{stat_name}, $_->{stat_current}, $_->{stat_name} ) ); - my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'systemstats', instance => $_->{stat_name}, value => $_->{stat_current}); + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric( + section => 'systemstats', + instance => $_->{stat_name}, + value => $_->{stat_current} + ); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/components/vdisk.pm b/src/storage/ibm/storwize/ssh/mode/components/vdisk.pm index fa16fca6c..383e24b7b 100644 --- a/src/storage/ibm/storwize/ssh/mode/components/vdisk.pm +++ b/src/storage/ibm/storwize/ssh/mode/components/vdisk.pm @@ -41,18 +41,24 @@ sub check { my $result = $self->{custom}->get_hasharray(content => $content, delim => ':'); foreach (@$result) { - next if ($self->check_filter(section => 'vdisk', instance => $_->{id})); + next if ($self->check_filter(section => 'vdisk', instance => $_->{id}, name => $_->{name})); $self->{components}->{vdisk}->{total}++; $self->{output}->output_add( long_msg => sprintf( - "vdisk '%s' status is '%s' [instance: %s].", + "vdisk '%s' status is '%s' [instance: %s]", $_->{name}, $_->{status}, $_->{id} ) ); - my $exit = $self->get_severity(label => 'default', section => 'vdisk', value => $_->{status}); + my $exit = $self->get_severity( + label => 'default', + section => 'vdisk', + instance => $_->{id}, + name => $_->{name}, + value => $_->{status} + ); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, diff --git a/src/storage/ibm/storwize/ssh/mode/hardware.pm b/src/storage/ibm/storwize/ssh/mode/hardware.pm index 28da40c53..fc6d592a3 100644 --- a/src/storage/ibm/storwize/ssh/mode/hardware.pm +++ b/src/storage/ibm/storwize/ssh/mode/hardware.pm @@ -38,19 +38,19 @@ sub set_system { ['offline', 'CRITICAL'], ['degraded', 'WARNING'], ['excluded', 'OK'], # lsarray - ['mask', 'OK'], # lshost + ['mask', 'OK'] # lshost ], portfc => [ ['active', 'OK'], ['inactive_unconfigured', 'OK'], - ['.*', 'CRITICAL'], + ['.*', 'CRITICAL'] ], portsas => [ ['online', 'OK'], ['offline_unconfigured', 'OK'], ['excluded', 'OK'], ['offline', 'CRITICAL'], - ['degraded', 'WARNING'], + ['degraded', 'WARNING'] ], mdisk => [ ['online', 'OK'], @@ -58,8 +58,8 @@ sub set_system { ['offline', 'CRITICAL'], ['degraded_paths', 'WARNING'], ['degraded_ports', 'WARNING'], - ['degraded', 'WARNING'], - ], + ['degraded', 'WARNING'] + ] }; $self->{components_path} = 'storage::ibm::storwize::ssh::mode::components'; @@ -103,6 +103,10 @@ Which component to check (Default: '.*'). Can be: 'array', 'drive', 'enclosure', 'enclosurebattery', 'enclosurecanister', 'enclosurepsu', 'host', 'portfc', 'portsas', 'vdisk', 'node', 'quorum', 'mdisk', 'systemstats'. +=item B<--add-name-instance> + +Add literal description for instance value (used in filter, absent-problem and threshold options). + =item B<--filter> Exclude some parts (comma seperated list) (Example: --filter=host --filter=enclosurecanister)