From 43316f9dee52f6b9607f57837662b99356ac5bee Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 25 Apr 2014 23:51:09 +0200 Subject: [PATCH] Refs #5491 Fix indentation and some helps --- os/aix/local/mode/errpt.pm | 87 +++++++++++------------------------ os/aix/local/mode/mirrorvg.pm | 12 ++--- os/aix/local/plugin.pm | 21 ++------- 3 files changed, 36 insertions(+), 84 deletions(-) diff --git a/os/aix/local/mode/errpt.pm b/os/aix/local/mode/errpt.pm index 62748e2d4..779bc37ae 100644 --- a/os/aix/local/mode/errpt.pm +++ b/os/aix/local/mode/errpt.pm @@ -58,10 +58,9 @@ sub new { "sudo" => { name => 'sudo' }, "command:s" => { name => 'command', default => 'errpt' }, "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => ' ' }, "error-type:s" => { name => 'error_type' }, - "error-class:s" => { name => 'error_class' }, - "retention:s" => { name => 'retention' }, + "error-class:s" => { name => 'error_class' }, + "retention:s" => { name => 'retention' }, }); $self->{result} = {}; return $self; @@ -74,33 +73,33 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - my $extra_options = ''; + my $extra_options = ''; - if (defined($self->{option_results}->{error_type})){ - $extra_options = $extra_options.' -T '.$self->{option_results}->{error_type}; - } - if (defined($self->{option_results}->{error_class})){ + if (defined($self->{option_results}->{error_type})){ + $extra_options = $extra_options.' -T '.$self->{option_results}->{error_type}; + } + if (defined($self->{option_results}->{error_class})){ $extra_options = $extra_options.' -d '.$self->{option_results}->{error_class}; } - if (defined($self->{option_results}->{retention})){ - my $retention = time() - $self->{option_results}->{retention}; - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($retention); - $year = $year - 100; - if (length($sec)==1){ - $sec = '0'.$sec; - } - if (length($min)==1){ + if (defined($self->{option_results}->{retention})){ + my $retention = time() - $self->{option_results}->{retention}; + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($retention); + $year = $year - 100; + if (length($sec)==1){ + $sec = '0'.$sec; + } + if (length($min)==1){ $min = '0'.$min; } - if (length($hour)==1){ + if (length($hour)==1){ $hour = '0'.$hour; } - $mon = $mon + 1; - if (length($mon)==1){ + $mon = $mon + 1; + if (length($mon)==1){ $mon = '0'.$mon; } - $retention = $mon.$mday.$hour.$min.$year; - $extra_options = $extra_options.' -s '.$retention; + $retention = $mon.$mday.$hour.$min.$year; + $extra_options = $extra_options.' -s '.$retention; } my $stdout = centreon::plugins::misc::execute(output => $self->{output}, @@ -108,14 +107,14 @@ sub manage_selection { sudo => $self->{option_results}->{sudo}, command => $self->{option_results}->{command}, command_path => $self->{option_results}->{command_path}, - command_options => $extra_options.' '.$self->{option_results}->{command_options}); + command_options => $extra_options); my @lines = split /\n/, $stdout; # Header not needed shift @lines; foreach my $line (@lines) { next if ($line !~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)/); - my ($identifier, $timestamp, $resource_name) = ($1, $2, $5); + my ($identifier, $timestamp, $resource_name) = ($1, $2, $5); $self->{result}->{$identifier} = {timestamp => $timestamp, resource_name => $resource_name}; } @@ -126,13 +125,13 @@ sub manage_selection { $self->{output}->output_add(short_msg => "No error found."); } $self->{output}->display(); - $self->{output}->exit(); + $self->{output}->exit(); } } sub run { my ($self, %options) = @_; - + $self->manage_selection(); $self->{output}->output_add(severity => 'OK', short_msg => 'No error found.'); @@ -141,9 +140,9 @@ sub run { my $timestamp = $self->{result}->{$identifier}->{timestamp}; my $resource_name = $self->{result}->{$identifier}->{resource_name}; my $exit; - + $self->{output}->output_add(long_msg => sprintf("Error '%s' Date: %s ResourceName: %s", $identifier, - $timestamp, $resource_name)); + $timestamp, $resource_name)); $self->{output}->output_add(severity => 'critical', short_msg => sprintf("Error '%s' Date: %s ResourceName: %s", $identifier, $timestamp, $resource_name)); @@ -193,45 +192,13 @@ Use 'sudo' to execute the command. =item B<--command> -Command to get information (Default: 'df'). +Command to get information (Default: 'errpt'). Can be changed if you have output in a file. =item B<--command-path> Command path (Default: none). -=item B<--command-options> - -Command options (Default: '-P -k -T 2>&1'). - -=item B<--warning> - -Threshold warning. - -=item B<--critical> - -Threshold critical. - -=item B<--units> - -Units of thresholds (Default: '%') ('%', 'B'). - -=item B<--free> - -Thresholds are on free space left. - -=item B<--name> - -Set the storage mount point (empty means 'check all storages') - -=item B<--regexp> - -Allows to use regexp to filter storage mount point (with option --name). - -=item B<--regexp-isensitive> - -Allows to use regexp non case-sensitive (with --regexp). - =item B<--error-type> Filter error type separated by a coma (INFO, PEND, PERF, PERM, TEMP, UNKN). diff --git a/os/aix/local/mode/mirrorvg.pm b/os/aix/local/mode/mirrorvg.pm index c8695f199..d285742b9 100644 --- a/os/aix/local/mode/mirrorvg.pm +++ b/os/aix/local/mode/mirrorvg.pm @@ -116,7 +116,7 @@ sub manage_selection { sub run { my ($self, %options) = @_; - + $self->manage_selection(); if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp})) { $self->{output}->output_add(severity => 'OK', @@ -130,13 +130,13 @@ sub run { my $type = $self->{result}->{$name}->{type}; my $lp = $self->{result}->{$name}->{lp}; my $pp = $self->{result}->{$name}->{pp}; - my $pv = $self->{result}->{$name}->{pv}; - my $lvstate = $self->{result}->{$name}->{lvstate}; - my $mount = $name; - + my $pv = $self->{result}->{$name}->{pv}; + my $lvstate = $self->{result}->{$name}->{lvstate}; + my $mount = $name; + $self->{output}->output_add(long_msg => sprintf("LV '%s' MountPoint: '%s' State: '%s' [LP: %s PP: %s PV: %s]", $lv, $mount, $lvstate, - $lp, $pp, $pv)); + $lp, $pp, $pv)); $self->{output}->output_add(severity => 'critical', short_msg => sprintf("LV '%s' MountPoint: '%s' State: '%s' [LP: %s PP: %s PV: %s]", $lv, $mount, $lvstate, diff --git a/os/aix/local/plugin.pm b/os/aix/local/plugin.pm index a4748a2a0..3df4262e6 100644 --- a/os/aix/local/plugin.pm +++ b/os/aix/local/plugin.pm @@ -47,25 +47,10 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'cpu' => 'os::aix::local::mode::cpu', - 'cmd-return' => 'os::aix::local::mode::cmdreturn', - 'diskio' => 'os::aix::local::mode::diskio', - 'files-size' => 'os::aix::local::mode::filessize', - 'files-date' => 'os::aix::local::mode::filesdate', - 'inodes' => 'os::aix::local::mode::inodes', - 'load' => 'os::aix::local::mode::loadaverage', - 'list-interfaces' => 'os::aix::local::mode::listinterfaces', - 'list-partitions' => 'os::aix::local::mode::listpartitions', + 'errpt' => 'os::aix::local::mode::errpt', 'list-storages' => 'os::aix::local::mode::liststorages', - 'memory' => 'os::aix::local::mode::memory', - 'packet-errors' => 'os::aix::local::mode::packeterrors', - 'process' => 'os::aix::local::mode::process', 'storage' => 'os::aix::local::mode::storage', - 'swap' => 'os::aix::local::mode::swap', - 'traffic' => 'os::aix::local::mode::traffic', - 'uptime' => 'os::aix::local::mode::uptime', - 'mirrorvg' => 'os::aix::local::mode::mirrorvg', - 'errpt' => 'os::aix::local::mode::errpt', + 'mirrorvg' => 'os::aix::local::mode::mirrorvg', ); return $self; @@ -77,6 +62,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Linux through local commands (the plugin can use SSH). +Check AIX through local commands (the plugin can use SSH). =cut