fix some indents

This commit is contained in:
garnier-quentin 2019-11-14 10:46:54 +01:00
parent 58a70c0c2c
commit 4eb7912fff
14 changed files with 156 additions and 155 deletions

View File

@ -80,7 +80,7 @@ sub manage_selection {
next; next;
} }
if ($$row[3] == 0) { if ($$row[3] == 0) {
$self->{output}->output_add(severity => 'CRITICAL', $self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("%s is not running", $$row[1])); short_msg => sprintf("%s is not running", $$row[1]));
next; next;

View File

@ -25,17 +25,17 @@ use warnings;
use base qw(centreon::plugins::script_simple); use base qw(centreon::plugins::script_simple);
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'temperature' => 'apps::hddtemp::remote::mode::temperature', 'temperature' => 'apps::hddtemp::remote::mode::temperature',
'list-drives' => 'apps::hddtemp::remote::mode::listdrives', 'list-drives' => 'apps::hddtemp::remote::mode::listdrives',
); );
return $self; return $self;
} }
1; 1;

View File

@ -29,12 +29,12 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'sensors' => 'apps::lmsensors::snmp::mode::sensors', 'sensors' => 'apps::lmsensors::snmp::mode::sensors',
); );
return $self; return $self;
} }
1; 1;

View File

@ -25,18 +25,18 @@ use warnings;
use base qw(centreon::plugins::script_simple); use base qw(centreon::plugins::script_simple);
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'connections' => 'apps::nginx::serverstatus::mode::connections', 'connections' => 'apps::nginx::serverstatus::mode::connections',
'responsetime' => 'apps::nginx::serverstatus::mode::responsetime', 'responsetime' => 'apps::nginx::serverstatus::mode::responsetime',
'requests' => 'apps::nginx::serverstatus::mode::requests', 'requests' => 'apps::nginx::serverstatus::mode::requests',
); );
return $self; return $self;
} }
1; 1;

View File

@ -25,17 +25,17 @@ use warnings;
use base qw(centreon::plugins::script_simple); use base qw(centreon::plugins::script_simple);
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'file-cache' => 'apps::php::apc::web::mode::filecache', 'file-cache' => 'apps::php::apc::web::mode::filecache',
'memory' => 'apps::php::apc::web::mode::memory', 'memory' => 'apps::php::apc::web::mode::memory',
); );
return $self; return $self;
} }
1; 1;

View File

@ -25,16 +25,16 @@ use warnings;
use base qw(centreon::plugins::script_simple); use base qw(centreon::plugins::script_simple);
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'usage' => 'apps::php::fpm::web::mode::usage', 'usage' => 'apps::php::fpm::web::mode::usage',
); );
return $self; return $self;
} }
1; 1;

View File

@ -25,19 +25,19 @@ use warnings;
use base qw(centreon::plugins::script_simple); use base qw(centreon::plugins::script_simple);
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'expected-content' => 'apps::protocols::http::mode::expectedcontent', 'expected-content' => 'apps::protocols::http::mode::expectedcontent',
'json-content' => 'apps::protocols::http::mode::jsoncontent', 'json-content' => 'apps::protocols::http::mode::jsoncontent',
'response' => 'apps::protocols::http::mode::response', 'response' => 'apps::protocols::http::mode::response',
'soap-content' => 'apps::protocols::http::mode::soapcontent', 'soap-content' => 'apps::protocols::http::mode::soapcontent',
); );
return $self; return $self;
} }
1; 1;

View File

@ -25,17 +25,17 @@ use warnings;
use base qw(centreon::plugins::script_simple); use base qw(centreon::plugins::script_simple);
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'offset' => 'apps::protocols::ntp::mode::offset', 'offset' => 'apps::protocols::ntp::mode::offset',
'response-time' => 'apps::protocols::ntp::mode::responsetime', 'response-time' => 'apps::protocols::ntp::mode::responsetime',
); );
return $self; return $self;
} }
1; 1;

View File

@ -25,16 +25,16 @@ use warnings;
use base qw(centreon::plugins::script_simple); use base qw(centreon::plugins::script_simple);
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'scenario' => 'apps::sahipro::restapi::mode::scenario', 'scenario' => 'apps::sahipro::restapi::mode::scenario',
); );
return $self; return $self;
} }
1; 1;

View File

@ -25,19 +25,19 @@ use warnings;
use base qw(centreon::plugins::script_simple); use base qw(centreon::plugins::script_simple);
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'applications' => 'apps::tomcat::web::mode::applications', 'applications' => 'apps::tomcat::web::mode::applications',
'connectors' => 'apps::tomcat::web::mode::connectors', 'connectors' => 'apps::tomcat::web::mode::connectors',
'list-application' => 'apps::tomcat::web::mode::listapplication', 'list-application' => 'apps::tomcat::web::mode::listapplication',
'memory' => 'apps::tomcat::web::mode::memory', 'memory' => 'apps::tomcat::web::mode::memory',
); );
return $self; return $self;
} }
1; 1;

View File

@ -25,16 +25,16 @@ use warnings;
use base qw(centreon::plugins::script_simple); use base qw(centreon::plugins::script_simple);
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'stats' => 'apps::varnish::local::mode::stats', 'stats' => 'apps::varnish::local::mode::stats',
); );
return $self; return $self;
} }
1; 1;

View File

@ -30,11 +30,10 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'warning:s' => { name => 'warning', default => '' },
"warning:s" => { name => 'warning', default => '' }, 'critical:s' => { name => 'critical', default => '' },
"critical:s" => { name => 'critical', default => '' }, });
});
return $self; return $self;
} }
@ -47,28 +46,28 @@ sub check_options {
($self->{crit5s}, $self->{crit1m}, $self->{crit5m}) = split /,/, $self->{option_results}->{critical}; ($self->{crit5s}, $self->{crit1m}, $self->{crit5m}) = split /,/, $self->{option_results}->{critical};
if (($self->{perfdata}->threshold_validate(label => 'warn1s', value => $self->{warn5s})) == 0) { 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}->add_option_msg(short_msg => "Wrong warning (1sec) threshold '" . $self->{warn5s} . "'.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
if (($self->{perfdata}->threshold_validate(label => 'warn1m', value => $self->{warn1m})) == 0) { 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}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1m} . "'.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
if (($self->{perfdata}->threshold_validate(label => 'warn5m', value => $self->{warn5m})) == 0) { 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}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn5m} . "'.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
if (($self->{perfdata}->threshold_validate(label => 'crit1s', value => $self->{crit5s})) == 0) { 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}->add_option_msg(short_msg => "Wrong critical (1sec) threshold '" . $self->{crit5s} . "'.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
if (($self->{perfdata}->threshold_validate(label => 'crit1m', value => $self->{crit1m})) == 0) { 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}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1m} . "'.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
if (($self->{perfdata}->threshold_validate(label => 'crit5m', value => $self->{crit5m})) == 0) { 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}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit5m} . "'.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
} }
@ -77,27 +76,27 @@ sub run {
$self->{snmp} = $options{snmp}; $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_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 ], $self->{result} = $self->{snmp}->get_leef(oids => [ $oid_agentSwitchCpuProcessTotalUtilization1, $oid_agentSwitchCpuProcessTotalUtilization2 ],
nothing_quit => 1); nothing_quit => 1);
my $cpu_usage; my $cpu_usage;
if ((defined($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1})) && ($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1} =~ /sec.*(sec|min).*(sec|min)/i)) { if ((defined($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1})) && ($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1} =~ /sec.*(sec|min).*(sec|min)/i)) {
$cpu_usage = $self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1}; $cpu_usage = $self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization1};
} elsif ((defined($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2})) && ($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2} =~ /sec.*(sec|min).*(sec|min)/i)) { } elsif ((defined($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2})) && ($self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2} =~ /sec.*(sec|min).*(sec|min)/i)) {
$cpu_usage = $self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2}; $cpu_usage = $self->{result}->{$oid_agentSwitchCpuProcessTotalUtilization2};
} else { } else {
$self->{output}->output_add(severity => 'UNKNOWN', $self->{output}->output_add(severity => 'UNKNOWN',
short_msg => sprintf("Can't get CPU information.")); short_msg => sprintf("Can't get CPU information."));
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
} }
if ($cpu_usage =~ /^.*\(\s*(\S+)%\).*\(\s*(\S+)%\).*\(\s*(\S+)%\)/) { if ($cpu_usage =~ /^.*\(\s*(\S+)%\).*\(\s*(\S+)%\).*\(\s*(\S+)%\)/) {
my $cpu5sec = $1; my $cpu5sec = $1;
my $cpu1min = $2; my $cpu1min = $2;
my $cpu5min = $3; 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' } ]); threshold => [ { label => 'crit5s', 'exit_litteral' => 'critical' }, { label => 'warn5s', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $cpu1min, my $exit2 = $self->{perfdata}->threshold_check(value => $cpu1min,
threshold => [ { label => 'crit1m', 'exit_litteral' => 'critical' }, { label => 'warn1m', exit_litteral => 'warning' } ]); 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' } ]); threshold => [ { label => 'crit5m', 'exit_litteral' => 'critical' }, { label => 'warn5m', exit_litteral => 'warning' } ]);
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]); 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)", short_msg => sprintf("CPU Usage: %.2f%% (5sec), %.2f%% (1min), %.2f%% (5min)",
$cpu5sec, $cpu1min, $cpu5min)); $cpu5sec, $cpu1min, $cpu5min));
$self->{output}->perfdata_add(label => "cpu_5s", unit => '%', $self->{output}->perfdata_add(label => "cpu_5s", unit => '%',
value => $cpu5sec, value => $cpu5sec,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5s'), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5s'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5s'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5s'),
@ -124,10 +123,10 @@ sub run {
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'),
min => 0, max => 100); min => 0, max => 100);
} else { } else {
$self->{output}->output_add(severity => 'UNKNOWN', $self->{output}->output_add(severity => 'UNKNOWN',
short_msg => sprintf("Can't parse CPU usage.")); short_msg => sprintf("Can't parse CPU usage."));
} }
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();

View File

@ -30,11 +30,10 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'warning:s' => { name => 'warning' },
"warning:s" => { name => 'warning' }, 'critical:s' => { name => 'critical' },
"critical:s" => { name => 'critical' }, });
});
return $self; return $self;
} }
@ -44,12 +43,12 @@ sub check_options {
$self->SUPER::init(%options); $self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { 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}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { 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}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit(); $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_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 $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, my $result = $self->{snmp}->get_leef(oids => [$oid_agentSwitchCpuProcessMemFree,
$oid_agentSwitchCpuProcessMemAvailable], $oid_agentSwitchCpuProcessMemAvailable],
nothing_quit => 1); nothing_quit => 1);
my $memory_free = $result->{$oid_agentSwitchCpuProcessMemFree} * 1024; my $memory_free = $result->{$oid_agentSwitchCpuProcessMemFree} * 1024;
my $memory_available = $result->{$oid_agentSwitchCpuProcessMemAvailable} * 1024; my $memory_available = $result->{$oid_agentSwitchCpuProcessMemAvailable} * 1024;
my $memory_used = $memory_available - $memory_free; my $memory_used = $memory_available - $memory_free;
my $prct_used = ($memory_used / $memory_available) * 100; my $prct_used = ($memory_used / $memory_available) * 100;
my $prct_free = ($memory_free / $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_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_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_free_value, $memory_free_unit) = $self->{perfdata}->change_bytes(value => $memory_free);
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Memory used: %s (%.2f%%), Size: %s, Free: %s (%.2f%%)", short_msg => sprintf("Memory used: %s (%.2f%%), Size: %s, Free: %s (%.2f%%)",
$memory_used_value . " " . $memory_used_unit, $prct_used, $memory_used_value . " " . $memory_used_unit, $prct_used,
$memory_available_value . " " . $memory_available_unit, $memory_available_value . " " . $memory_available_unit,
$memory_free_value . " " . $memory_free_unit, $prct_free)); $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, value => $memory_used,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $memory_available, cast_int => 1), 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), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $memory_available, cast_int => 1),

View File

@ -63,12 +63,13 @@ sub custom_metric_perfdata {
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . lc($self->{result_values}->{display}) if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $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, $self->{output}->perfdata_add(
unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'B/s' : 'B', label => lc($self->{result_values}->{metric}) . "_" . lc($self->{result_values}->{stat}) . $extra_label,
value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}), unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? 'B/s' : 'B',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})), value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . lc($self->{result_values}->{metric}) . "-" . lc($self->{result_values}->{stat})), 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 { sub custom_metric_output {
@ -94,27 +95,29 @@ sub set_counters {
foreach my $statistic ('minimum', 'maximum', 'average', 'sum') { foreach my $statistic ('minimum', 'maximum', 'average', 'sum') {
foreach my $metric ('ReplicationBytes') { foreach my $metric ('ReplicationBytes') {
my $entry = { label => lc($metric) . '-' . lc($statistic), set => { my $entry = {
key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' }, { name => 'timeframe' } ], label => lc($metric) . '-' . lc($statistic), set => {
closure_custom_calc => $self->can('custom_metric_calc'), key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' }, { name => 'timeframe' } ],
closure_custom_calc_extra_options => { metric => $metric, stat => $statistic }, closure_custom_calc => $self->can('custom_metric_calc'),
closure_custom_output => $self->can('custom_metric_output'), closure_custom_calc_extra_options => { metric => $metric, stat => $statistic },
closure_custom_perfdata => $self->can('custom_metric_perfdata'), closure_custom_output => $self->can('custom_metric_output'),
closure_custom_threshold_check => $self->can('custom_metric_threshold'), closure_custom_perfdata => $self->can('custom_metric_perfdata'),
} closure_custom_threshold_check => $self->can('custom_metric_threshold'),
}; }
};
push @{$self->{maps_counters}->{metric}}, $entry; push @{$self->{maps_counters}->{metric}}, $entry;
} }
foreach my $metric ('ReplicationLag') { foreach my $metric ('ReplicationLag') {
my $entry = { label => lc($metric) . '-' . lc($statistic), set => { my $entry = {
key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' }, { name => 'timeframe' } ], label => lc($metric) . '-' . lc($statistic), set => {
output_template => $metric . ': %.2f s', key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' }, { name => 'timeframe' } ],
perfdatas => [ output_template => $metric . ': %.2f s',
{ label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', perfdatas => [
template => '%.2f', unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, { 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; push @{$self->{maps_counters}->{metric}}, $entry;
} }
} }
@ -126,10 +129,10 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"name:s@" => { name => 'name' }, 'name:s@' => { name => 'name' },
"node-id:s" => { name => 'node_id' }, 'node-id:s' => { name => 'node_id' },
"filter-metric:s" => { name => 'filter_metric' }, 'filter-metric:s' => { name => 'filter_metric' },
"per-sec" => { name => 'per_sec' }, 'per-sec' => { name => 'per_sec' },
}); });
return $self; return $self;