This commit is contained in:
garnier-quentin 2014-04-28 00:01:26 +02:00
parent fcee8ab7d4
commit 7e117bb008
18 changed files with 181 additions and 149 deletions

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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',

View File

@ -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();
}

View File

@ -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',

View File

@ -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();
}

View File

@ -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();
}