From 4eb7912fffe75e6dcf552e13593f69f569f697af Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 14 Nov 2019 10:46:54 +0100 Subject: [PATCH] fix some indents --- .../apps/centreon/sql/mode/pollerdelay.pm | 2 +- .../apps/hddtemp/remote/plugin.pm | 18 ++--- .../apps/lmsensors/snmp/plugin.pm | 6 +- .../apps/nginx/serverstatus/plugin.pm | 20 ++--- centreon-plugins/apps/php/apc/web/plugin.pm | 12 +-- centreon-plugins/apps/php/fpm/web/plugin.pm | 12 +-- .../apps/protocols/http/plugin.pm | 12 +-- centreon-plugins/apps/protocols/ntp/plugin.pm | 12 +-- .../apps/sahipro/restapi/plugin.pm | 12 +-- centreon-plugins/apps/tomcat/web/plugin.pm | 12 +-- centreon-plugins/apps/varnish/local/plugin.pm | 12 +-- .../common/dell/fastpath/snmp/mode/cpu.pm | 75 +++++++++---------- .../common/dell/fastpath/snmp/mode/memory.pm | 47 ++++++------ .../cloud/aws/elasticache/mode/replication.pm | 59 ++++++++------- 14 files changed, 156 insertions(+), 155 deletions(-) diff --git a/centreon-plugins/apps/centreon/sql/mode/pollerdelay.pm b/centreon-plugins/apps/centreon/sql/mode/pollerdelay.pm index 2670bfa9a..1ee8dac23 100644 --- a/centreon-plugins/apps/centreon/sql/mode/pollerdelay.pm +++ b/centreon-plugins/apps/centreon/sql/mode/pollerdelay.pm @@ -80,7 +80,7 @@ sub manage_selection { next; } - if ($$row[3] == 0) { + if ($$row[3] == 0) { $self->{output}->output_add(severity => 'CRITICAL', short_msg => sprintf("%s is not running", $$row[1])); next; diff --git a/centreon-plugins/apps/hddtemp/remote/plugin.pm b/centreon-plugins/apps/hddtemp/remote/plugin.pm index 3476c6178..dda9c11bf 100644 --- a/centreon-plugins/apps/hddtemp/remote/plugin.pm +++ b/centreon-plugins/apps/hddtemp/remote/plugin.pm @@ -25,17 +25,17 @@ use warnings; use base qw(centreon::plugins::script_simple); sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'temperature' => 'apps::hddtemp::remote::mode::temperature', - 'list-drives' => 'apps::hddtemp::remote::mode::listdrives', - ); + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'temperature' => 'apps::hddtemp::remote::mode::temperature', + 'list-drives' => 'apps::hddtemp::remote::mode::listdrives', + ); - return $self; + return $self; } 1; diff --git a/centreon-plugins/apps/lmsensors/snmp/plugin.pm b/centreon-plugins/apps/lmsensors/snmp/plugin.pm index fbb30a929..db67b203c 100644 --- a/centreon-plugins/apps/lmsensors/snmp/plugin.pm +++ b/centreon-plugins/apps/lmsensors/snmp/plugin.pm @@ -29,12 +29,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{version} = '0.1'; + %{$self->{modes}} = ( 'sensors' => 'apps::lmsensors::snmp::mode::sensors', ); - return $self; + return $self; } 1; diff --git a/centreon-plugins/apps/nginx/serverstatus/plugin.pm b/centreon-plugins/apps/nginx/serverstatus/plugin.pm index dfc7e008d..81e082206 100644 --- a/centreon-plugins/apps/nginx/serverstatus/plugin.pm +++ b/centreon-plugins/apps/nginx/serverstatus/plugin.pm @@ -25,18 +25,18 @@ use warnings; use base qw(centreon::plugins::script_simple); sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'connections' => 'apps::nginx::serverstatus::mode::connections', - 'responsetime' => 'apps::nginx::serverstatus::mode::responsetime', - 'requests' => 'apps::nginx::serverstatus::mode::requests', - ); + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'connections' => 'apps::nginx::serverstatus::mode::connections', + 'responsetime' => 'apps::nginx::serverstatus::mode::responsetime', + 'requests' => 'apps::nginx::serverstatus::mode::requests', + ); - return $self; + return $self; } 1; diff --git a/centreon-plugins/apps/php/apc/web/plugin.pm b/centreon-plugins/apps/php/apc/web/plugin.pm index c9c7192c7..aa3085a6a 100644 --- a/centreon-plugins/apps/php/apc/web/plugin.pm +++ b/centreon-plugins/apps/php/apc/web/plugin.pm @@ -25,17 +25,17 @@ use warnings; use base qw(centreon::plugins::script_simple); sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{version} = '0.1'; + %{$self->{modes}} = ( 'file-cache' => 'apps::php::apc::web::mode::filecache', 'memory' => 'apps::php::apc::web::mode::memory', ); - return $self; + return $self; } 1; diff --git a/centreon-plugins/apps/php/fpm/web/plugin.pm b/centreon-plugins/apps/php/fpm/web/plugin.pm index c94a1cc54..8e8aedc4b 100644 --- a/centreon-plugins/apps/php/fpm/web/plugin.pm +++ b/centreon-plugins/apps/php/fpm/web/plugin.pm @@ -25,16 +25,16 @@ use warnings; use base qw(centreon::plugins::script_simple); sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{version} = '0.1'; + %{$self->{modes}} = ( 'usage' => 'apps::php::fpm::web::mode::usage', ); - return $self; + return $self; } 1; diff --git a/centreon-plugins/apps/protocols/http/plugin.pm b/centreon-plugins/apps/protocols/http/plugin.pm index 65e867531..a422a0cc5 100644 --- a/centreon-plugins/apps/protocols/http/plugin.pm +++ b/centreon-plugins/apps/protocols/http/plugin.pm @@ -25,19 +25,19 @@ use warnings; use base qw(centreon::plugins::script_simple); sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{version} = '0.1'; + %{$self->{modes}} = ( 'expected-content' => 'apps::protocols::http::mode::expectedcontent', 'json-content' => 'apps::protocols::http::mode::jsoncontent', 'response' => 'apps::protocols::http::mode::response', 'soap-content' => 'apps::protocols::http::mode::soapcontent', ); - return $self; + return $self; } 1; diff --git a/centreon-plugins/apps/protocols/ntp/plugin.pm b/centreon-plugins/apps/protocols/ntp/plugin.pm index b836050d0..3a8a8f16a 100644 --- a/centreon-plugins/apps/protocols/ntp/plugin.pm +++ b/centreon-plugins/apps/protocols/ntp/plugin.pm @@ -25,17 +25,17 @@ use warnings; use base qw(centreon::plugins::script_simple); sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{version} = '0.1'; + %{$self->{modes}} = ( 'offset' => 'apps::protocols::ntp::mode::offset', 'response-time' => 'apps::protocols::ntp::mode::responsetime', ); - return $self; + return $self; } 1; diff --git a/centreon-plugins/apps/sahipro/restapi/plugin.pm b/centreon-plugins/apps/sahipro/restapi/plugin.pm index 1b8884a93..556456327 100644 --- a/centreon-plugins/apps/sahipro/restapi/plugin.pm +++ b/centreon-plugins/apps/sahipro/restapi/plugin.pm @@ -25,16 +25,16 @@ use warnings; use base qw(centreon::plugins::script_simple); sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{version} = '0.1'; + %{$self->{modes}} = ( 'scenario' => 'apps::sahipro::restapi::mode::scenario', ); - return $self; + return $self; } 1; diff --git a/centreon-plugins/apps/tomcat/web/plugin.pm b/centreon-plugins/apps/tomcat/web/plugin.pm index f2c48808b..0044c68e8 100644 --- a/centreon-plugins/apps/tomcat/web/plugin.pm +++ b/centreon-plugins/apps/tomcat/web/plugin.pm @@ -25,19 +25,19 @@ use warnings; use base qw(centreon::plugins::script_simple); sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{version} = '0.1'; + %{$self->{modes}} = ( 'applications' => 'apps::tomcat::web::mode::applications', 'connectors' => 'apps::tomcat::web::mode::connectors', 'list-application' => 'apps::tomcat::web::mode::listapplication', 'memory' => 'apps::tomcat::web::mode::memory', ); - return $self; + return $self; } 1; diff --git a/centreon-plugins/apps/varnish/local/plugin.pm b/centreon-plugins/apps/varnish/local/plugin.pm index aa3563322..336eb0b89 100644 --- a/centreon-plugins/apps/varnish/local/plugin.pm +++ b/centreon-plugins/apps/varnish/local/plugin.pm @@ -25,16 +25,16 @@ use warnings; use base qw(centreon::plugins::script_simple); sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{version} = '0.1'; + %{$self->{modes}} = ( 'stats' => 'apps::varnish::local::mode::stats', ); - return $self; + return $self; } 1; diff --git a/centreon-plugins/centreon/common/dell/fastpath/snmp/mode/cpu.pm b/centreon-plugins/centreon/common/dell/fastpath/snmp/mode/cpu.pm index ead478151..32ee23682 100644 --- a/centreon-plugins/centreon/common/dell/fastpath/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/dell/fastpath/snmp/mode/cpu.pm @@ -30,11 +30,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning', default => '' }, - "critical:s" => { name => 'critical', default => '' }, - }); + $options{options}->add_options(arguments => { + 'warning:s' => { name => 'warning', default => '' }, + 'critical:s' => { name => 'critical', default => '' }, + }); return $self; } @@ -47,28 +46,28 @@ sub check_options { ($self->{crit5s}, $self->{crit1m}, $self->{crit5m}) = split /,/, $self->{option_results}->{critical}; if (($self->{perfdata}->threshold_validate(label => 'warn1s', value => $self->{warn5s})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (1sec) threshold '" . $self->{warn5s} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong warning (1sec) threshold '" . $self->{warn5s} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'warn1m', value => $self->{warn1m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1m} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1m} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'warn5m', value => $self->{warn5m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn5m} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn5m} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'crit1s', value => $self->{crit5s})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (1sec) threshold '" . $self->{crit5s} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong critical (1sec) threshold '" . $self->{crit5s} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'crit1m', value => $self->{crit1m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1m} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1m} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'crit5m', value => $self->{crit5m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit5m} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit5m} . "'."); + $self->{output}->option_exit(); } } @@ -77,27 +76,27 @@ sub run { $self->{snmp} = $options{snmp}; my $oid_agentSwitchCpuProcessTotalUtilization1 = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.9.0'; - my $oid_agentSwitchCpuProcessTotalUtilization2 = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.4.0'; # oid for 6200 series + my $oid_agentSwitchCpuProcessTotalUtilization2 = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.4.0'; # oid for 6200 series $self->{result} = $self->{snmp}->get_leef(oids => [ $oid_agentSwitchCpuProcessTotalUtilization1, $oid_agentSwitchCpuProcessTotalUtilization2 ], nothing_quit => 1); - my $cpu_usage; - if ((defined($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1})) && ($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1} =~ /sec.*(sec|min).*(sec|min)/i)) { - $cpu_usage = $self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1}; - } elsif ((defined($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2})) && ($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2} =~ /sec.*(sec|min).*(sec|min)/i)) { - $cpu_usage = $self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2}; - } else { - $self->{output}->output_add(severity => 'UNKNOWN', + my $cpu_usage; + if ((defined($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1})) && ($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1} =~ /sec.*(sec|min).*(sec|min)/i)) { + $cpu_usage = $self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1}; + } elsif ((defined($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2})) && ($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2} =~ /sec.*(sec|min).*(sec|min)/i)) { + $cpu_usage = $self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2}; + } else { + $self->{output}->output_add(severity => 'UNKNOWN', short_msg => sprintf("Can't get CPU information.")); - $self->{output}->display(); - $self->{output}->exit(); - } - if ($cpu_usage =~ /^.*\(\s*(\S+)%\).*\(\s*(\S+)%\).*\(\s*(\S+)%\)/) { - my $cpu5sec = $1; - my $cpu1min = $2; - my $cpu5min = $3; + $self->{output}->display(); + $self->{output}->exit(); + } + if ($cpu_usage =~ /^.*\(\s*(\S+)%\).*\(\s*(\S+)%\).*\(\s*(\S+)%\)/) { + my $cpu5sec = $1; + my $cpu1min = $2; + my $cpu5min = $3; - my $exit1 = $self->{perfdata}->threshold_check(value => $cpu5sec, + my $exit1 = $self->{perfdata}->threshold_check(value => $cpu5sec, threshold => [ { label => 'crit5s', 'exit_litteral' => 'critical' }, { label => 'warn5s', exit_litteral => 'warning' } ]); my $exit2 = $self->{perfdata}->threshold_check(value => $cpu1min, threshold => [ { label => 'crit1m', 'exit_litteral' => 'critical' }, { label => 'warn1m', exit_litteral => 'warning' } ]); @@ -105,11 +104,11 @@ sub run { threshold => [ { label => 'crit5m', 'exit_litteral' => 'critical' }, { label => 'warn5m', exit_litteral => 'warning' } ]); my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]); - $self->{output}->output_add(severity => $exit, + $self->{output}->output_add(severity => $exit, short_msg => sprintf("CPU Usage: %.2f%% (5sec), %.2f%% (1min), %.2f%% (5min)", $cpu5sec, $cpu1min, $cpu5min)); - $self->{output}->perfdata_add(label => "cpu_5s", unit => '%', + $self->{output}->perfdata_add(label => "cpu_5s", unit => '%', value => $cpu5sec, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5s'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5s'), @@ -124,10 +123,10 @@ sub run { warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'), min => 0, max => 100); - } else { - $self->{output}->output_add(severity => 'UNKNOWN', + } else { + $self->{output}->output_add(severity => 'UNKNOWN', short_msg => sprintf("Can't parse CPU usage.")); - } + } $self->{output}->display(); $self->{output}->exit(); diff --git a/centreon-plugins/centreon/common/dell/fastpath/snmp/mode/memory.pm b/centreon-plugins/centreon/common/dell/fastpath/snmp/mode/memory.pm index a28f1e362..8ec0aed26 100644 --- a/centreon-plugins/centreon/common/dell/fastpath/snmp/mode/memory.pm +++ b/centreon-plugins/centreon/common/dell/fastpath/snmp/mode/memory.pm @@ -30,11 +30,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + $options{options}->add_options(arguments => { + 'warning:s' => { name => 'warning' }, + 'critical:s' => { name => 'critical' }, + }); return $self; } @@ -44,12 +43,12 @@ sub check_options { $self->SUPER::init(%options); if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); } if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); } } @@ -60,29 +59,29 @@ sub run { my $oid_agentSwitchCpuProcessMemFree = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.1.0'; # in KB my $oid_agentSwitchCpuProcessMemAvailable = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.2.0'; # in KB - my $result = $self->{snmp}->get_leef(oids => [$oid_agentSwitchCpuProcessMemFree, - $oid_agentSwitchCpuProcessMemAvailable], + my $result = $self->{snmp}->get_leef(oids => [$oid_agentSwitchCpuProcessMemFree, + $oid_agentSwitchCpuProcessMemAvailable], nothing_quit => 1); - my $memory_free = $result->{$oid_agentSwitchCpuProcessMemFree} * 1024; - my $memory_available = $result->{$oid_agentSwitchCpuProcessMemAvailable} * 1024; - my $memory_used = $memory_available - $memory_free; - my $prct_used = ($memory_used / $memory_available) * 100; - my $prct_free = ($memory_free / $memory_available) * 100; + my $memory_free = $result->{$oid_agentSwitchCpuProcessMemFree} * 1024; + my $memory_available = $result->{$oid_agentSwitchCpuProcessMemAvailable} * 1024; + my $memory_used = $memory_available - $memory_free; + my $prct_used = ($memory_used / $memory_available) * 100; + my $prct_free = ($memory_free / $memory_available) * 100; - my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - my ($memory_used_value, $memory_used_unit) = $self->{perfdata}->change_bytes(value => $memory_used); - my ($memory_available_value, $memory_available_unit) = $self->{perfdata}->change_bytes(value => $memory_available); - my ($memory_free_value, $memory_free_unit) = $self->{perfdata}->change_bytes(value => $memory_free); + my ($memory_used_value, $memory_used_unit) = $self->{perfdata}->change_bytes(value => $memory_used); + my ($memory_available_value, $memory_available_unit) = $self->{perfdata}->change_bytes(value => $memory_available); + my ($memory_free_value, $memory_free_unit) = $self->{perfdata}->change_bytes(value => $memory_free); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Memory used: %s (%.2f%%), Size: %s, Free: %s (%.2f%%)", + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Memory used: %s (%.2f%%), Size: %s, Free: %s (%.2f%%)", $memory_used_value . " " . $memory_used_unit, $prct_used, $memory_available_value . " " . $memory_available_unit, $memory_free_value . " " . $memory_free_unit, $prct_free)); - - $self->{output}->perfdata_add(label => "used", unit => 'B', + + $self->{output}->perfdata_add(label => "used", unit => 'B', value => $memory_used, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $memory_available, cast_int => 1), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $memory_available, cast_int => 1), diff --git a/centreon-plugins/cloud/aws/elasticache/mode/replication.pm b/centreon-plugins/cloud/aws/elasticache/mode/replication.pm index a714703e4..23cc75cb2 100644 --- a/centreon-plugins/cloud/aws/elasticache/mode/replication.pm +++ b/centreon-plugins/cloud/aws/elasticache/mode/replication.pm @@ -63,12 +63,13 @@ sub custom_metric_perfdata { my $extra_label = ''; $extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0); - $self->{output}->perfdata_add(label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label, - unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'B/s' : 'B', - value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})), - ); + $self->{output}->perfdata_add( + label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label, + unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'B/s' : 'B', + value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})), + ); } sub custom_metric_output { @@ -94,27 +95,29 @@ sub set_counters { foreach my $statistic ('minimum', 'maximum', 'average', 'sum') { foreach my $metric ('ReplicationBytes') { - my $entry = { label => lc($metric) . '-' . lc($statistic), set => { - key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' }, { name => 'timeframe' } ], - closure_custom_calc => $self->can('custom_metric_calc'), - closure_custom_calc_extra_options => { metric => $metric, stat => $statistic }, - closure_custom_output => $self->can('custom_metric_output'), - closure_custom_perfdata => $self->can('custom_metric_perfdata'), - closure_custom_threshold_check => $self->can('custom_metric_threshold'), - } - }; + my $entry = { + label => lc($metric) . '-' . lc($statistic), set => { + key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' }, { name => 'timeframe' } ], + closure_custom_calc => $self->can('custom_metric_calc'), + closure_custom_calc_extra_options => { metric => $metric, stat => $statistic }, + closure_custom_output => $self->can('custom_metric_output'), + closure_custom_perfdata => $self->can('custom_metric_perfdata'), + closure_custom_threshold_check => $self->can('custom_metric_threshold'), + } + }; push @{$self->{maps_counters}->{metric}}, $entry; } foreach my $metric ('ReplicationLag') { - my $entry = { label => lc($metric) . '-' . lc($statistic), set => { - key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' }, { name => 'timeframe' } ], - output_template => $metric . ': %.2f s', - perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }; + my $entry = { + label => lc($metric) . '-' . lc($statistic), set => { + key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' }, { name => 'timeframe' } ], + output_template => $metric . ': %.2f s', + perfdatas => [ + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', + template => '%.2f', unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }; push @{$self->{maps_counters}->{metric}}, $entry; } } @@ -126,10 +129,10 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "name:s@" => { name => 'name' }, - "node-id:s" => { name => 'node_id' }, - "filter-metric:s" => { name => 'filter_metric' }, - "per-sec" => { name => 'per_sec' }, + 'name:s@' => { name => 'name' }, + 'node-id:s' => { name => 'node_id' }, + 'filter-metric:s' => { name => 'filter_metric' }, + 'per-sec' => { name => 'per_sec' }, }); return $self;