Fix #5635
This commit is contained in:
parent
f2a4b18c09
commit
445d3a41fe
|
@ -61,7 +61,9 @@ sub new {
|
||||||
"command-options:s" => { name => 'command_options', default => '/proc/meminfo 2>&1' },
|
"command-options:s" => { name => 'command_options', default => '/proc/meminfo 2>&1' },
|
||||||
"warning:s" => { name => 'warning', },
|
"warning:s" => { name => 'warning', },
|
||||||
"critical:s" => { name => 'critical', },
|
"critical:s" => { name => 'critical', },
|
||||||
|
"no-swap:s" => { name => 'no_swap' },
|
||||||
});
|
});
|
||||||
|
$self->{no_swap} = 'critical';
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +79,13 @@ sub check_options {
|
||||||
$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();
|
||||||
}
|
}
|
||||||
|
if (defined($self->{option_results}->{no_swap}) && $self->{option_results}->{no_swap} ne '') {
|
||||||
|
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{no_swap}) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong --no-swap status '" . $self->{option_results}->{no_swap} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
$self->{no_swap} = $self->{option_results}->{no_swap};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
|
@ -102,6 +111,12 @@ sub run {
|
||||||
$self->{output}->add_option_msg(short_msg => "Some informations missing.");
|
$self->{output}->add_option_msg(short_msg => "Some informations missing.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
if ($total_size == 0) {
|
||||||
|
$self->{output}->output_add(severity => $self->{no_swap},
|
||||||
|
short_msg => 'No active swap.');
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
my $swap_used = $total_size - $swap_free;
|
my $swap_used = $total_size - $swap_free;
|
||||||
|
|
||||||
|
@ -146,6 +161,10 @@ Threshold warning in percent.
|
||||||
|
|
||||||
Threshold critical in percent.
|
Threshold critical in percent.
|
||||||
|
|
||||||
|
=item B<--no-swap>
|
||||||
|
|
||||||
|
Threshold if no active swap (default: 'critical').
|
||||||
|
|
||||||
=item B<--remote>
|
=item B<--remote>
|
||||||
|
|
||||||
Execute command remotely in 'ssh'.
|
Execute command remotely in 'ssh'.
|
||||||
|
|
|
@ -50,11 +50,12 @@ sub new {
|
||||||
{
|
{
|
||||||
"warning:s" => { name => 'warning' },
|
"warning:s" => { name => 'warning' },
|
||||||
"critical:s" => { name => 'critical' },
|
"critical:s" => { name => 'critical' },
|
||||||
"swap:s" => { name => 'check_swap' },
|
"swap" => { name => 'check_swap' },
|
||||||
"warning-swap:s" => { name => 'warning_swap' },
|
"warning-swap:s" => { name => 'warning_swap' },
|
||||||
"critical-swap:s" => { name => 'critical_swap' },
|
"critical-swap:s" => { name => 'critical_swap' },
|
||||||
|
"no-swap:s" => { name => 'no_swap' },
|
||||||
});
|
});
|
||||||
|
$self->{no_swap} = 'critical';
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +80,13 @@ sub check_options {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-swap threshold '" . $self->{option_results}->{critical_swap} . "'.");
|
$self->{output}->add_option_msg(short_msg => "Wrong critical-swap threshold '" . $self->{option_results}->{critical_swap} . "'.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
if (defined($self->{option_results}->{no_swap}) && $self->{option_results}->{no_swap} ne '') {
|
||||||
|
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{no_swap}) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong --no-swap status '" . $self->{option_results}->{no_swap} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
$self->{no_swap} = $self->{option_results}->{no_swap};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +147,13 @@ sub run {
|
||||||
min => 0, max => $total_size);
|
min => 0, max => $total_size);
|
||||||
|
|
||||||
if (defined($self->{option_results}->{check_swap})) {
|
if (defined($self->{option_results}->{check_swap})) {
|
||||||
|
if ($result->{$oid_memTotalSwap} == 0) {
|
||||||
|
$self->{output}->output_add(severity => $self->{no_swap},
|
||||||
|
short_msg => 'No active swap.');
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
$total_size = $result->{$oid_memTotalSwap} * 1024;
|
$total_size = $result->{$oid_memTotalSwap} * 1024;
|
||||||
my $swap_used = ($result->{$oid_memTotalSwap} - $result->{$oid_memAvailSwap}) * 1024;
|
my $swap_used = ($result->{$oid_memTotalSwap} - $result->{$oid_memAvailSwap}) * 1024;
|
||||||
|
|
||||||
|
@ -196,6 +211,10 @@ Threshold warning in percent.
|
||||||
|
|
||||||
Threshold critical in percent.
|
Threshold critical in percent.
|
||||||
|
|
||||||
|
=item B<--no-swap>
|
||||||
|
|
||||||
|
Threshold if no active swap (default: 'critical').
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
|
@ -50,8 +50,9 @@ sub new {
|
||||||
{
|
{
|
||||||
"warning:s" => { name => 'warning' },
|
"warning:s" => { name => 'warning' },
|
||||||
"critical:s" => { name => 'critical' },
|
"critical:s" => { name => 'critical' },
|
||||||
|
"no-swap:s" => { name => 'no_swap' },
|
||||||
});
|
});
|
||||||
|
$self->{no_swap} = 'critical';
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +67,14 @@ sub check_options {
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
if (defined($self->{option_results}->{no_swap}) && $self->{option_results}->{no_swap} ne '') {
|
||||||
|
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{no_swap}) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong --no-swap status '" . $self->{option_results}->{no_swap} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
$self->{no_swap} = $self->{option_results}->{no_swap};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
|
@ -78,6 +86,13 @@ sub run {
|
||||||
my $oid_memAvailSwap = '.1.3.6.1.4.1.2021.4.4.0'; # KB
|
my $oid_memAvailSwap = '.1.3.6.1.4.1.2021.4.4.0'; # KB
|
||||||
my $result = $self->{snmp}->get_leef(oids => [$oid_memTotalSwap, $oid_memAvailSwap], nothing_quit => 1);
|
my $result = $self->{snmp}->get_leef(oids => [$oid_memTotalSwap, $oid_memAvailSwap], nothing_quit => 1);
|
||||||
|
|
||||||
|
if ($result->{$oid_memTotalSwap} == 0) {
|
||||||
|
$self->{output}->output_add(severity => $self->{no_swap},
|
||||||
|
short_msg => 'No active swap.');
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
my $total_size = $result->{$oid_memTotalSwap} * 1024;
|
my $total_size = $result->{$oid_memTotalSwap} * 1024;
|
||||||
my $swap_used = ($result->{$oid_memTotalSwap} - $result->{$oid_memAvailSwap}) * 1024;
|
my $swap_used = ($result->{$oid_memTotalSwap} - $result->{$oid_memAvailSwap}) * 1024;
|
||||||
|
|
||||||
|
@ -122,6 +137,10 @@ Threshold warning in percent.
|
||||||
|
|
||||||
Threshold critical in percent.
|
Threshold critical in percent.
|
||||||
|
|
||||||
|
=item B<--no-swap>
|
||||||
|
|
||||||
|
Threshold if no active swap (default: 'critical').
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
Loading…
Reference in New Issue