From 7e117bb0084845ba198ea7ef9e63b438e412173d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 28 Apr 2014 00:01:26 +0200 Subject: [PATCH] Fix #5502 --- apps/hddtemp/mode/listdrives.pm | 17 +++--- apps/iis/local/mode/listapplicationpools.pm | 25 +++++---- apps/iis/local/mode/listsites.pm | 25 +++++---- apps/iis/wsman/mode/listapplicationpools.pm | 16 +++--- apps/msmq/local/mode/listqueues.pm | 14 ++--- apps/tomcat/web/mode/listapplication.pm | 30 ++++++---- database/informix/mode/listdatabases.pm | 8 ++- database/informix/mode/listdbspaces.pm | 8 ++- database/postgres/mode/listdatabases.pm | 8 ++- .../common/mode/listvirtualdomains.pm | 21 +++---- network/securactive/mode/listbca.pm | 15 ++--- network/securactive/mode/listbcn.pm | 9 +-- os/aix/local/mode/liststorages.pm | 23 ++++---- os/linux/local/mode/liststorages.pm | 2 +- os/windows/wsman/mode/listservices.pm | 18 +++--- snmp_standard/mode/liststorages.pm | 2 +- storage/emc/clariion/mode/listluns.pm | 55 +++++++++++-------- storage/netapp/mode/listfilesys.pm | 34 +++++++----- 18 files changed, 181 insertions(+), 149 deletions(-) diff --git a/apps/hddtemp/mode/listdrives.pm b/apps/hddtemp/mode/listdrives.pm index 9527d0928..207dfecc5 100644 --- a/apps/hddtemp/mode/listdrives.pm +++ b/apps/hddtemp/mode/listdrives.pm @@ -106,8 +106,11 @@ sub manage_selection { while ($line =~ /\|([^|]+)\|([^|]+)\|([^|]+)\|(C|F)\|/g) { my ($drive, $serial, $temperature, $unit) = ($1, $2, $3, $4); - next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $drive !~ /$self->{option_results}->{filter_name}/); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $drive !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping drive '" . $drive . "': no matching filter name"); + next; + } $self->{result}->{$drive} = {serial => $serial, temperature => $temperature, unit => $unit}; } @@ -117,17 +120,13 @@ sub run { my ($self, %options) = @_; $self->manage_selection(); - - my $drive_display = ''; - my $drive_display_append = ''; foreach my $name (sort(keys %{$self->{result}})) { - $drive_display .= $drive_display_append . 'name = ' . $name . ' [temperature = ' . $self->{result}->{$name}->{temperature} . $self->{result}->{$name}->{unit} . ']'; - $drive_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "' [temperature = " . $self->{result}->{$name}->{temperature} . $self->{result}->{$name}->{unit} . ']'); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List Drives: ' . $drive_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List Drives:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/apps/iis/local/mode/listapplicationpools.pm b/apps/iis/local/mode/listapplicationpools.pm index 2e536b0f0..e681de2fd 100644 --- a/apps/iis/local/mode/listapplicationpools.pm +++ b/apps/iis/local/mode/listapplicationpools.pm @@ -87,11 +87,18 @@ sub manage_selection { my $state = $obj->GetState(); if (defined($self->{option_results}->{filter_state}) && $state_map{$state} !~ /$self->{option_results}->{filter_state}/) { + $self->{output}->output_add(long_msg => "Skipping application pool '" . $name . "': no matching filter state"); next; } - next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && $name ne $self->{option_results}->{name}); - next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && $name !~ /$self->{option_results}->{name}/); + if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && $name ne $self->{option_results}->{name}) { + $self->{output}->output_add(long_msg => "Skipping application pool '" . $name . "': no matching filter name"); + next; + } + if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && $name !~ /$self->{option_results}->{name}/) { + $self->{output}->output_add(long_msg => "Skipping application pool '" . $name . "': no matching filter name (regexp)"); + next; + } $self->{result}->{$name} = {AutoStart => $auto_start, State => $state}; } @@ -101,19 +108,15 @@ sub run { my ($self, %options) = @_; $self->manage_selection(); - my $pools_display = ''; - my $pools_display_append = ''; foreach my $name (sort(keys %{$self->{result}})) { - $pools_display .= $pools_display_append . 'name = ' . $name . - ' [AutoStart = ' . $self->{result}->{$name}->{AutoStart} . ', ' . - 'State = ' . $state_map{$self->{result}->{$name}->{State}} . - ']'; - $pools_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "' [AutoStart = " . $self->{result}->{$name}->{AutoStart} . '] [' . + 'State = ' . $state_map{$self->{result}->{$name}->{State}} . + ']'); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List application pools: ' . $pools_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List application pools:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/apps/iis/local/mode/listsites.pm b/apps/iis/local/mode/listsites.pm index 0749d9476..69b7bf72c 100644 --- a/apps/iis/local/mode/listsites.pm +++ b/apps/iis/local/mode/listsites.pm @@ -87,11 +87,18 @@ sub manage_selection { my $state = $obj->GetState(); if (defined($self->{option_results}->{filter_state}) && $state_map{$state} !~ /$self->{option_results}->{filter_state}/) { + $self->{output}->output_add(long_msg => "Skipping site '" . $name . "': no matching filter state"); next; } - next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && $name ne $self->{option_results}->{name}); - next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && $name !~ /$self->{option_results}->{name}/); + if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && $name ne $self->{option_results}->{name}) { + $self->{output}->output_add(long_msg => "Skipping site '" . $name . "': no matching filter name"); + next; + } + if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && $name !~ /$self->{option_results}->{name}/) { + $self->{output}->output_add(long_msg => "Skipping site '" . $name . "': no matching filter name (regexp)"); + next; + } $self->{result}->{$name} = {AutoStart => $auto_start, State => $state}; } @@ -101,19 +108,15 @@ sub run { my ($self, %options) = @_; $self->manage_selection(); - my $sites_display = ''; - my $sites_display_append = ''; foreach my $name (sort(keys %{$self->{result}})) { - $sites_display .= $sites_display_append . 'name = ' . $name . - ' [AutoStart = ' . $self->{result}->{$name}->{AutoStart} . ', ' . - 'State = ' . $state_map{$self->{result}->{$name}->{State}} . - ']'; - $sites_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "' [AutoStart = " . $self->{result}->{$name}->{AutoStart} . '] [' . + 'State = ' . $state_map{$self->{result}->{$name}->{State}} . + ']'); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List sites: ' . $sites_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List sites:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/apps/iis/wsman/mode/listapplicationpools.pm b/apps/iis/wsman/mode/listapplicationpools.pm index 84a5751ff..03f9ecfe1 100644 --- a/apps/iis/wsman/mode/listapplicationpools.pm +++ b/apps/iis/wsman/mode/listapplicationpools.pm @@ -79,6 +79,7 @@ sub manage_selection { # AppPoolState -> 1=started, 2=starting, 3 = stopped, 4=stopping foreach my $name (sort(keys %{$self->{result}})) { if (defined($self->{option_results}->{filter_state}) && $state_map{$self->{result}->{$name}->{AppPoolState}} !~ /$self->{option_results}->{filter_state}/) { + $self->{output}->output_add(long_msg => "Skipping application pool '" . $name . "': no matching filter state"); delete $self->{result}->{$name}; next; } @@ -89,6 +90,7 @@ sub manage_selection { next if (!defined($self->{option_results}->{use_regexp}) && $name eq $self->{option_results}->{name}); next if (defined($self->{option_results}->{use_regexp}) && $name =~ /$self->{option_results}->{name}/); + $self->{output}->output_add(long_msg => "Skipping application pool '" . $name . "': no matching filter name"); delete $self->{result}->{$name}; } } @@ -99,19 +101,15 @@ sub run { $self->{wsman} = $options{wsman}; $self->manage_selection(); - my $pools_display = ''; - my $pools_display_append = ''; foreach my $name (sort(keys %{$self->{result}})) { - $pools_display .= $pools_display_append . 'name = ' . $name . - ' [AutoStart = ' . $self->{result}->{$name}->{AppPoolAutoStart} . ',' . - 'State = ' . $state_map{$self->{result}->{$name}->{AppPoolState}} . - ']'; - $pools_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "' [AutoStart = " . $self->{result}->{$name}->{AppPoolAutoStart} . '] [' . + 'State = ' . $state_map{$self->{result}->{$name}->{AppPoolState}} . + ']'); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List application pools: ' . $pools_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List application pools:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/apps/msmq/local/mode/listqueues.pm b/apps/msmq/local/mode/listqueues.pm index 26ed01190..933c32d98 100644 --- a/apps/msmq/local/mode/listqueues.pm +++ b/apps/msmq/local/mode/listqueues.pm @@ -112,19 +112,15 @@ sub run { my ($self, %options) = @_; $self->manage_selection(); - my $pools_display = ''; - my $pools_display_append = ''; foreach my $name (sort(keys %{$self->{result}})) { - $pools_display .= $pools_display_append . 'name = ' . $name . - ' [AutoStart = ' . $self->{result}->{$name}->{AutoStart} . ', ' . - 'State = ' . $state_map{$self->{result}->{$name}->{State}} . - ']'; - $pools_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "' [AutoStart = " . $self->{result}->{$name}->{AutoStart} . ', ' . + 'State = ' . $state_map{$self->{result}->{$name}->{State}} . + ']'); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List application pools: ' . $pools_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List application pools:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/apps/tomcat/web/mode/listapplication.pm b/apps/tomcat/web/mode/listapplication.pm index 85bcaa9bb..240438f83 100644 --- a/apps/tomcat/web/mode/listapplication.pm +++ b/apps/tomcat/web/mode/listapplication.pm @@ -96,12 +96,21 @@ sub manage_selection { while ($webcontent =~ m/\/(.*):(.*):(.*):(.*)/g) { my ($context, $state, $sessions, $contextpath) = ($1, $2, $3, $4); - next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $context !~ /$self->{option_results}->{filter_name}/); - next if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' && - $state !~ /$self->{option_results}->{filter_state}/); - next if (defined($self->{option_results}->{filter_path}) && $self->{option_results}->{filter_path} ne '' && - $contextpath !~ /$self->{option_results}->{filter_path}/); + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $context !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "Skipping context '" . $context . "': no matching filter name"); + next; + } + if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' && + $state !~ /$self->{option_results}->{filter_state}/) { + $self->{output}->output_add(long_msg => "Skipping context '" . $context . "': no matching filter state"); + next; + } + if (defined($self->{option_results}->{filter_path}) && $self->{option_results}->{filter_path} ne '' && + $contextpath !~ /$self->{option_results}->{filter_path}/) { + $self->{output}->output_add(long_msg => "Skipping context '" . $context . "': no matching filter path"); + next; + } $self->{result}->{$context} = {state => $state, sessions => $sessions, contextpath => $contextpath}; } @@ -111,16 +120,13 @@ sub run { my ($self, %options) = @_; $self->manage_selection(); - my $context_display = ''; - my $context_display_append = ''; foreach my $name (sort(keys %{$self->{result}})) { - $context_display .= $context_display_append . 'name = ' . $name . ' [state = ' . $self->{result}->{$name}->{state} . ']'; - $context_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "' [state = " . $self->{result}->{$name}->{state} . ']'); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List Contexts: ' . $context_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List Contexts:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/database/informix/mode/listdatabases.pm b/database/informix/mode/listdatabases.pm index e3f87c9d2..dd54c8763 100644 --- a/database/informix/mode/listdatabases.pm +++ b/database/informix/mode/listdatabases.pm @@ -71,6 +71,7 @@ SELECT name FROM sysdatabases ORDER BY name $self->{list_databases} = []; while ((my $row = $self->{sql}->fetchrow_hashref())) { if (defined($self->{option_results}->{exclude}) && $row->{name} !~ /$self->{option_results}->{exclude}/) { + $self->{output}->output_add(long_msg => "Skipping database '" . centreon::plugins::misc::trim($row->{name}) . "': no matching filter name"); next; } push @{$self->{list_databases}}, centreon::plugins::misc::trim($row->{name}); @@ -84,10 +85,13 @@ sub run { $self->manage_selection(); + foreach my $name (sort @{$self->{list_databases}}) { + $self->{output}->output_add(long_msg => "'" . $name . "'"); + } $self->{output}->output_add(severity => 'OK', - short_msg => "List of dbspaces: " . join(', ', @{$self->{list_databases}})); + short_msg => "List of databases:"); - $self->{output}->display(); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/database/informix/mode/listdbspaces.pm b/database/informix/mode/listdbspaces.pm index 9fff39883..e6266b5ac 100644 --- a/database/informix/mode/listdbspaces.pm +++ b/database/informix/mode/listdbspaces.pm @@ -71,6 +71,7 @@ SELECT name FROM sysdbspaces ORDER BY name $self->{list_dbspaces} = []; while ((my $row = $self->{sql}->fetchrow_hashref())) { if (defined($self->{option_results}->{exclude}) && $row->{name} !~ /$self->{option_results}->{exclude}/) { + $self->{output}->output_add(long_msg => "Skipping dbspace '" . centreon::plugins::misc::trim($row->{name}) . "': no matching filter name"); next; } push @{$self->{list_dbspaces}}, centreon::plugins::misc::trim($row->{name}); @@ -84,10 +85,13 @@ sub run { $self->manage_selection(); + foreach my $name (sort @{$self->{list_dbspaces}}) { + $self->{output}->output_add(long_msg => "'" . $name . "'"); + } $self->{output}->output_add(severity => 'OK', - short_msg => "List of dbspaces: " . join(', ', @{$self->{list_dbspaces}})); + short_msg => "List of dbspaces:"); - $self->{output}->display(); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/database/postgres/mode/listdatabases.pm b/database/postgres/mode/listdatabases.pm index 75a44de96..5b0553656 100644 --- a/database/postgres/mode/listdatabases.pm +++ b/database/postgres/mode/listdatabases.pm @@ -70,6 +70,7 @@ SELECT datname FROM pg_database $self->{list_db} = []; while ((my $row = $self->{sql}->fetchrow_hashref())) { if (defined($self->{option_results}->{exclude}) && $row->{datname} !~ /$self->{option_results}->{exclude}/) { + $self->{output}->output_add(long_msg => "Skipping database '" . $row->{datname} . "': no matching filter name"); next; } push @{$self->{list_db}}, $row->{datname}; @@ -83,10 +84,13 @@ sub run { $self->manage_selection(); + foreach my $name (sort @{$self->{list_db}}) { + $self->{output}->output_add(long_msg => "'" . $name . "'"); + } $self->{output}->output_add(severity => 'OK', - short_msg => "List of databases: " . join(', ', @{$self->{list_db}})); + short_msg => "List of databases:"); - $self->{output}->display(); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/network/fortinet/fortigate/common/mode/listvirtualdomains.pm b/network/fortinet/fortigate/common/mode/listvirtualdomains.pm index 4bb73880c..432e29137 100644 --- a/network/fortinet/fortigate/common/mode/listvirtualdomains.pm +++ b/network/fortinet/fortigate/common/mode/listvirtualdomains.pm @@ -77,12 +77,16 @@ sub manage_selection { next; } - if (!defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} eq $self->{option_results}->{name}) { - push @{$self->{virtualdomain_id_selected}}, $instance; + if (!defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} ne $self->{option_results}->{name}) { + $self->{output}->output_add(long_msg => "Skipping virtualdomain '" . $self->{result_names}->{$oid} . "': no matching filter name"); + next; } - if (defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} =~ /$self->{option_results}->{name}/) { - push @{$self->{virtualdomain_id_selected}}, $instance; + if (defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} !~ /$self->{option_results}->{name}/) { + $self->{output}->output_add(long_msg => "Skipping virtualdomain '" . $self->{result_names}->{$oid} . "': no matching filter name (regexp)"); + next; } + + push @{$self->{virtualdomain_id_selected}}, $instance; } } @@ -92,18 +96,15 @@ sub run { $self->{snmp} = $options{snmp}; $self->manage_selection(); - my $virtualdomains_display = ''; - my $virtualdomains_display_append = ''; foreach my $instance (sort @{$self->{virtualdomain_id_selected}}) { my $name = $self->{result_names}->{$oid_fgVdEntName . '.' . $instance}; - $virtualdomains_display .= $virtualdomains_display_append . "name = $name"; - $virtualdomains_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "'"); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List virtualdomains: ' . $virtualdomains_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List virtualdomains:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/network/securactive/mode/listbca.pm b/network/securactive/mode/listbca.pm index e3995703b..6897f4d95 100644 --- a/network/securactive/mode/listbca.pm +++ b/network/securactive/mode/listbca.pm @@ -79,11 +79,15 @@ sub manage_selection { $self->{result_names}->{$oid} = $self->{output}->to_utf8($self->{result_names}->{$oid}); if (!defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} eq $self->{option_results}->{name}) { - push @{$self->{bca_id_selected}}, $instance; + push @{$self->{bca_id_selected}}, $instance; + next; } if (defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} =~ /$self->{option_results}->{name}/) { push @{$self->{bca_id_selected}}, $instance; + next; } + + $self->{output}->output_add(long_msg => "Skipping bca '" . $self->{result_names}->{$oid} . "': no matching filter name"); } } @@ -93,18 +97,15 @@ sub run { $self->{snmp} = $options{snmp}; $self->manage_selection(); - my $bca_display = ''; - my $bca_display_append = ''; foreach my $instance (sort @{$self->{bca_id_selected}}) { my $name = $self->{result_names}->{$oid_spvBCAName . '.' . $instance}; - $bca_display .= $bca_display_append . "name = $name "; - $bca_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "'"); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List bca: ' . $bca_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List bca:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/network/securactive/mode/listbcn.pm b/network/securactive/mode/listbcn.pm index 25631e010..5556dcab5 100644 --- a/network/securactive/mode/listbcn.pm +++ b/network/securactive/mode/listbcn.pm @@ -104,19 +104,16 @@ sub run { $self->{snmp} = $options{snmp}; $self->manage_selection(); - my $bcn_display = ''; - my $bcn_display_append = ''; foreach my $instance (sort @{$self->{bcn_id_selected}}) { my $name = $self->{result_names}->{$oid_spvBCNName . '.' . $instance}; $name = $self->get_display_value(value => $name); - $bcn_display .= $bcn_display_append . "name = $name "; - $bcn_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "'"); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List bcn: ' . $bcn_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List bcn:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/os/aix/local/mode/liststorages.pm b/os/aix/local/mode/liststorages.pm index cc269c9f3..4d4d02e77 100644 --- a/os/aix/local/mode/liststorages.pm +++ b/os/aix/local/mode/liststorages.pm @@ -87,10 +87,16 @@ sub manage_selection { next if ($line !~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)/); my ($fs, $size, $used, $available, $percent, $mount) = ($1, $2, $3, $4, $5, $6); - next if (defined($self->{option_results}->{filter_fs}) && $self->{option_results}->{filter_fs} ne '' && - $fs !~ /$self->{option_results}->{filter_fs}/); - next if (defined($self->{option_results}->{filter_mount}) && $self->{option_results}->{filter_mount} ne '' && - $mount !~ /$self->{option_results}->{filter_mount}/); + if (defined($self->{option_results}->{filter_fs}) && $self->{option_results}->{filter_fs} ne '' && + $fs !~ /$self->{option_results}->{filter_fs}/) { + $self->{output}->output_add(long_msg => "Skipping storage '" . $mount . "': no matching filter fs"); + next; + } + if (defined($self->{option_results}->{filter_mount}) && $self->{option_results}->{filter_mount} ne '' && + $mount !~ /$self->{option_results}->{filter_mount}/) { + $self->{output}->output_add(long_msg => "Skipping storage '" . $mount . "': no matching filter mount"); + next; + } $self->{result}->{$mount} = {fs => $fs}; } @@ -100,16 +106,13 @@ sub run { my ($self, %options) = @_; $self->manage_selection(); - my $storages_display = ''; - my $storages_display_append = ''; foreach my $name (sort(keys %{$self->{result}})) { - $storages_display .= $storages_display_append . 'name = ' . $name . ' [fs = ' . $self->{result}->{$name}->{fs} . ']'; - $storages_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "' [fs = " . $self->{result}->{$name}->{fs} . ']'); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List storages: ' . $storages_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List storages:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/os/linux/local/mode/liststorages.pm b/os/linux/local/mode/liststorages.pm index 046e754b8..395732dd8 100644 --- a/os/linux/local/mode/liststorages.pm +++ b/os/linux/local/mode/liststorages.pm @@ -113,7 +113,7 @@ sub run { $self->manage_selection(); foreach my $name (sort(keys %{$self->{result}})) { - $self->{output}->output_add(long_msg => "'" . $name . "' [fs = " . $self->{result}->{$name}->{fs} . ', type = ' . $self->{result}->{$name}->{type} . ']'); + $self->{output}->output_add(long_msg => "'" . $name . "' [fs = " . $self->{result}->{$name}->{fs} . '] [type = ' . $self->{result}->{$name}->{type} . ']'); } $self->{output}->output_add(severity => 'OK', diff --git a/os/windows/wsman/mode/listservices.pm b/os/windows/wsman/mode/listservices.pm index 6be781286..a70367143 100644 --- a/os/windows/wsman/mode/listservices.pm +++ b/os/windows/wsman/mode/listservices.pm @@ -74,6 +74,7 @@ sub manage_selection { next if (!defined($self->{option_results}->{use_regexp}) && $name eq $self->{option_results}->{name}); next if (defined($self->{option_results}->{use_regexp}) && $name =~ /$self->{option_results}->{name}/); + $self->{output}->output_add(long_msg => "Skipping service '" . $name . "': no matching filter name"); delete $self->{result}->{$name}; } } @@ -84,21 +85,16 @@ sub run { $self->{wsman} = $options{wsman}; $self->manage_selection(); - my $services_display = ''; - my $services_display_append = ''; foreach my $name (sort(keys %{$self->{result}})) { - - $services_display .= $services_display_append . 'name = ' . $name . - ' [DisplayName = ' . $self->{output}->to_utf8($self->{result}->{$name}->{DisplayName}) . ',' . - 'StartMode = ' . $self->{result}->{$name}->{StartMode} . ',' . - 'State = ' . $self->{result}->{$name}->{State} . - ']'; - $services_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "' [DisplayName = " . $self->{output}->to_utf8($self->{result}->{$name}->{DisplayName}) . '] [' . + 'StartMode = ' . $self->{result}->{$name}->{StartMode} . '] [' . + 'State = ' . $self->{result}->{$name}->{State} . + ']'); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List services: ' . $services_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List services:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/snmp_standard/mode/liststorages.pm b/snmp_standard/mode/liststorages.pm index cedc5d104..d7926e633 100644 --- a/snmp_standard/mode/liststorages.pm +++ b/snmp_standard/mode/liststorages.pm @@ -143,7 +143,7 @@ sub run { next; } - $self->{output}->output_add(long_msg => "'" . $display_value . "' [size = " . $result->{$oid_hrStorageSize . "." . $_} * $result->{$oid_hrStorageAllocationUnits . "." . $_} . "B, id = $_]"); + $self->{output}->output_add(long_msg => "'" . $display_value . "' [size = " . $result->{$oid_hrStorageSize . "." . $_} * $result->{$oid_hrStorageAllocationUnits . "." . $_} . "B] [id = $_]"); } $self->{output}->output_add(severity => 'OK', diff --git a/storage/emc/clariion/mode/listluns.pm b/storage/emc/clariion/mode/listluns.pm index a1f1574a3..f1053de1b 100644 --- a/storage/emc/clariion/mode/listluns.pm +++ b/storage/emc/clariion/mode/listluns.pm @@ -99,16 +99,31 @@ sub manage_selection { $raid_group_id = $1 if ($content =~ /^RAIDGroup ID:\s+(.*)$/im); $drive_type = $1 if ($content =~ /^Drive Type:\s+(.*)$/im); - next if (defined($self->{option_results}->{filter_lunnumber}) && $self->{option_results}->{filter_lunnumber} ne '' && - $lun_num !~ /$self->{option_results}->{filter_lunnumber}/); - next if (defined($self->{option_results}->{filter_lunstate}) && $self->{option_results}->{filter_lunstate} ne '' && - $state !~ /$self->{option_results}->{filter_lunstate}/); - next if (defined($self->{option_results}->{filter_drivetype}) && $self->{option_results}->{filter_drivetype} ne '' && - $drive_type !~ /$self->{option_results}->{filter_drivetype}/); - next if (defined($self->{option_results}->{filter_raidtype}) && $self->{option_results}->{filter_raidtype} ne '' && - $raid_type !~ /$self->{option_results}->{filter_raidtype}/); - next if (defined($self->{option_results}->{filter_raidgroupid}) && $self->{option_results}->{filter_raidgroupid} ne '' && - $raid_group_id !~ /$self->{option_results}->{filter_raidgroupid}/); + if (defined($self->{option_results}->{filter_lunnumber}) && $self->{option_results}->{filter_lunnumber} ne '' && + $lun_num !~ /$self->{option_results}->{filter_lunnumber}/) { + $self->{output}->output_add(long_msg => "Skipping lun '" . $lun_num . "': no matching filter lun number"); + next; + } + if (defined($self->{option_results}->{filter_lunstate}) && $self->{option_results}->{filter_lunstate} ne '' && + $state !~ /$self->{option_results}->{filter_lunstate}/) { + $self->{output}->output_add(long_msg => "Skipping lun '" . $lun_num . "': no matching filter lun state"); + next; + } + if (defined($self->{option_results}->{filter_drivetype}) && $self->{option_results}->{filter_drivetype} ne '' && + $drive_type !~ /$self->{option_results}->{filter_drivetype}/) { + $self->{output}->output_add(long_msg => "Skipping lun '" . $lun_num . "': no matching filter lun drive type"); + next; + } + if (defined($self->{option_results}->{filter_raidtype}) && $self->{option_results}->{filter_raidtype} ne '' && + $raid_type !~ /$self->{option_results}->{filter_raidtype}/) { + $self->{output}->output_add(long_msg => "Skipping lun '" . $lun_num . "': no matching filter lun raid type"); + next; + } + if (defined($self->{option_results}->{filter_raidgroupid}) && $self->{option_results}->{filter_raidgroupid} ne '' && + $raid_group_id !~ /$self->{option_results}->{filter_raidgroupid}/) { + $self->{output}->output_add(long_msg => "Skipping lun '" . $lun_num . "': no matching filter lun raid group id"); + next; + } $self->{result}->{$lun_num} = {state => $state, drive_type => $drive_type, raid_type => $raid_type, raid_groupid => $raid_group_id}; } @@ -119,23 +134,17 @@ sub run { $self->{clariion} = $options{custom}; $self->manage_selection(); - - my $lun_display = ''; - my $lun_display_append = ''; foreach my $num (sort(keys %{$self->{result}})) { - $lun_display .= $lun_display_append . 'number = ' . $num . - ' [' . - 'state = ' . $self->{result}->{$num}->{state} . - ', drive type = ' . $self->{result}->{$num}->{drive_type} . - ', raid type = ' . $self->{result}->{$num}->{raid_type} . - ', raid groupid = ' . $self->{result}->{$num}->{raid_groupid} . - ']'; - $lun_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $num . "' [state = " . $self->{result}->{$num}->{state} . + '] [drive type = ' . $self->{result}->{$num}->{drive_type} . + '] [raid type = ' . $self->{result}->{$num}->{raid_type} . + '] [raid groupid = ' . $self->{result}->{$num}->{raid_groupid} . + ']'); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List LUNs: ' . $lun_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List LUNs:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/storage/netapp/mode/listfilesys.pm b/storage/netapp/mode/listfilesys.pm index 67a2955f9..aa110378d 100644 --- a/storage/netapp/mode/listfilesys.pm +++ b/storage/netapp/mode/listfilesys.pm @@ -92,14 +92,21 @@ sub manage_selection { next; } - if (!defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} eq $self->{option_results}->{name}) { - next if (defined($self->{option_results}->{type}) && $type !~ /$self->{option_results}->{type}/i); - push @{$self->{filesys_id_selected}}, $instance; + if (defined($self->{option_results}->{type}) && $type !~ /$self->{option_results}->{type}/i) { + $self->{output}->output_add(long_msg => "Skipping filesys '" . $self->{result_names}->{$oid} . "': no matching filter type"); + next; } - if (defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} =~ /$self->{option_results}->{name}/) { - next if (defined($self->{option_results}->{type}) && $type !~ /$self->{option_results}->{type}/i); - push @{$self->{filesys_id_selected}}, $instance; + + if (!defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} ne $self->{option_results}->{name}) { + $self->{output}->output_add(long_msg => "Skipping filesys '" . $self->{result_names}->{$oid} . "': no matching filter name"); + next; } + if (defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} !~ /$self->{option_results}->{name}/) { + $self->{output}->output_add(long_msg => "Skipping filesys '" . $self->{result_names}->{$oid} . "': no matching filter name (regexp)"); + next; + } + + push @{$self->{filesys_id_selected}}, $instance; } } @@ -121,8 +128,7 @@ sub run { $self->manage_selection(); my $result = $self->get_additional_information(); - my $filesys_display = ''; - my $filesys_display_append = ''; + foreach my $instance (sort @{$self->{filesys_id_selected}}) { my $name = $self->{result_names}->{$oid_dfFileSys . '.' . $instance}; my $type = $self->{result_types}->{$oid_dfType . '.' . $instance}; @@ -130,15 +136,17 @@ sub run { if (defined($result->{$oid_df64TotalKBytes . '.' . $instance}) && $result->{$oid_df64TotalKBytes . '.' . $instance} != 0) { $total_size = $result->{$oid_df64TotalKBytes . '.' . $instance} * 1024; } - next if (defined($self->{option_results}->{skip_total_zero}) && $total_size == 0); + if (defined($self->{option_results}->{skip_total_zero}) && $total_size == 0) { + $self->{output}->output_add(long_msg => "Skipping filesys '" . $name . "': total size is 0 and option --skip-total-zero is set"); + next; + } - $filesys_display .= $filesys_display_append . "name = $name [total_size = $total_size B, type = " . $map_types{$type} . "]"; - $filesys_display_append = ', '; + $self->{output}->output_add(long_msg => "'" . $name . "' [total_size = $total_size B] [type = " . $map_types{$type} . "]"); } $self->{output}->output_add(severity => 'OK', - short_msg => 'List filesys: ' . $filesys_display); - $self->{output}->display(nolabel => 1); + short_msg => 'List filesys:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); }