indent
This commit is contained in:
parent
67015b8a38
commit
119b917f0e
|
@ -29,16 +29,16 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"swap" => { name => 'check_swap' },
|
||||
"warning-swap:s" => { name => 'warning_swap' },
|
||||
"critical-swap:s" => { name => 'critical_swap' },
|
||||
"no-swap:s" => { name => 'no_swap' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"swap" => { name => 'check_swap' },
|
||||
"warning-swap:s" => { name => 'warning_swap' },
|
||||
"critical-swap:s" => { name => 'critical_swap' },
|
||||
"no-swap:s" => { name => 'no_swap' }
|
||||
});
|
||||
|
||||
$self->{no_swap} = 'critical';
|
||||
return $self;
|
||||
}
|
||||
|
@ -93,8 +93,10 @@ sub run {
|
|||
push @$oids, ($oid_memTotalSwap, $oid_memAvailSwap);
|
||||
}
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => $oids,
|
||||
nothing_quit => 1);
|
||||
my $result = $self->{snmp}->get_leef(
|
||||
oids => $oids,
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
my $cached_used = $result->{$oid_memCached} * 1024;
|
||||
my $physical_used = ($result->{$oid_memTotalReal} * 1024) - ($result->{$oid_memAvailReal} * 1024);
|
||||
|
@ -112,32 +114,42 @@ sub run {
|
|||
my ($nobuf_value, $nobuf_unit) = $self->{perfdata}->change_bytes(value => $nobuf_used);
|
||||
my ($cached_value, $cached_unit) = $self->{perfdata}->change_bytes(value => $cached_used);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Ram Total: %s, Used (-cache): %s (%.2f%%), Cached: %s",
|
||||
$total_value . " " . $total_unit,
|
||||
$nobuf_value . " " . $nobuf_unit, $prct_used,
|
||||
$cached_value . " " . $cached_unit));
|
||||
|
||||
$self->{output}->perfdata_add(label => "cached", nlabel => 'memory.cached.bytes', unit => 'B',
|
||||
value => $cached_used,
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(label => "used", nlabel => 'memory.usage.bytes', unit => 'B',
|
||||
value => $nobuf_used,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),
|
||||
min => 0, max => $total_size);
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Ram Total: %s, Used (-cache): %s (%.2f%%), Cached: %s",
|
||||
$total_value . " " . $total_unit,
|
||||
$nobuf_value . " " . $nobuf_unit, $prct_used,
|
||||
$cached_value . " " . $cached_unit
|
||||
)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => "cached", nlabel => 'memory.cached.bytes', unit => 'B',
|
||||
value => $cached_used,
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => "used", nlabel => 'memory.usage.bytes', unit => 'B',
|
||||
value => $nobuf_used,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),
|
||||
min => 0, max => $total_size
|
||||
);
|
||||
|
||||
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}->output_add(
|
||||
severity => $self->{no_swap},
|
||||
short_msg => 'No active swap.'
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
|
||||
$total_size = $result->{$oid_memTotalSwap} * 1024;
|
||||
my $swap_used = ($result->{$oid_memTotalSwap} - $result->{$oid_memAvailSwap}) * 1024;
|
||||
|
||||
|
||||
$prct_used = $swap_used * 100 / $total_size;
|
||||
$exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical-swap', 'exit_litteral' => 'critical' }, { label => 'warning-swap', exit_litteral => 'warning' } ]);
|
||||
|
||||
|
@ -145,19 +157,25 @@ sub run {
|
|||
my ($swap_used_value, $swap_used_unit) = $self->{perfdata}->change_bytes(value => $swap_used);
|
||||
my ($swap_free_value, $swap_free_unit) = $self->{perfdata}->change_bytes(value => ($total_size - $swap_used));
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Swap Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||
$total_value . " " . $total_unit,
|
||||
$swap_used_value . " " . $swap_used_unit, $prct_used,
|
||||
$swap_free_value . " " . $swap_free_unit, (100 - $prct_used)));
|
||||
|
||||
$self->{output}->perfdata_add(label => "swap", nlabel => 'swap.usage.bytes', unit => 'B',
|
||||
value => $swap_used,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-swap', total => $total_size, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-swap', total => $total_size, cast_int => 1),
|
||||
min => 0, max => $total_size);
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Swap Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||
$total_value . " " . $total_unit,
|
||||
$swap_used_value . " " . $swap_used_unit, $prct_used,
|
||||
$swap_free_value . " " . $swap_free_unit, (100 - $prct_used)
|
||||
)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => "swap", nlabel => 'swap.usage.bytes', unit => 'B',
|
||||
value => $swap_used,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-swap', total => $total_size, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-swap', total => $total_size, cast_int => 1),
|
||||
min => 0, max => $total_size
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
$self->{modes} = {
|
||||
'cpu' => 'snmp_standard::mode::cpu',
|
||||
'cpu-detailed' => 'snmp_standard::mode::cpudetailed',
|
||||
'diskio' => 'snmp_standard::mode::diskio',
|
||||
|
@ -48,8 +48,8 @@ sub new {
|
|||
'swap' => 'snmp_standard::mode::swap',
|
||||
'time' => 'snmp_standard::mode::ntp',
|
||||
'tcpcon' => 'snmp_standard::mode::tcpcon',
|
||||
'uptime' => 'snmp_standard::mode::uptime',
|
||||
);
|
||||
'uptime' => 'snmp_standard::mode::uptime'
|
||||
};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -46,11 +46,15 @@ sub set_counters {
|
|||
];
|
||||
|
||||
$self->{maps_counters}->{mountpoints} = [
|
||||
{ label => 'status', set => {
|
||||
{
|
||||
label => 'status',
|
||||
type => 2,
|
||||
critical_default => '%{options} !~ /^rw/i && %{type} !~ /tmpfs|squashfs/i',
|
||||
set => {
|
||||
key_values => [ { name => 'display' }, { name => 'options' }, { name => 'type' } ],
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -64,21 +68,12 @@ sub new {
|
|||
$options{options}->add_options(arguments => {
|
||||
'filter-device:s' => { name => 'filter_device' },
|
||||
'filter-mountpoint:s' => { name => 'filter_mountpoint' },
|
||||
'filter-type:s' => { name => 'filter_type' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{options} !~ /^rw/i && %{type} !~ /tmpfs|squashfs/i' }
|
||||
'filter-type:s' => { name => 'filter_type' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -114,12 +109,12 @@ sub manage_selection {
|
|||
$self->{mountpoints}->{$mountpoint} = {
|
||||
display => $mountpoint,
|
||||
type => $type,
|
||||
options => $options,
|
||||
options => $options
|
||||
};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{mountpoints}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No mount points found");
|
||||
$self->{output}->add_option_msg(short_msg => 'No mount points found');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
my %state_map_ntpq = (
|
||||
'<sp>' => 'discarded due to high stratum and/or failed sanity checks',
|
||||
|
@ -149,12 +149,12 @@ sub set_counters {
|
|||
];
|
||||
|
||||
$self->{maps_counters}->{peers} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
{ label => 'status', type => 2, set => {
|
||||
key_values => [ { name => 'state' }, { name => 'type' }, { name => 'reach' }, { name => 'display' } ],
|
||||
closure_custom_calc => $self->can('custom_status_calc'),
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'offset', display_ok => 0, set => {
|
||||
|
@ -190,12 +190,9 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'ntp-mode:s' => { name => 'ntp_mode', default => 'ntpq' },
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'filter-state:s' => { name => 'filter_state' },
|
||||
'unknown-status:s' => { name => 'unknown_status', default => '' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '' },
|
||||
'ntp-mode:s' => { name => 'ntp_mode', default => 'ntpq' },
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'filter-state:s' => { name => 'filter_state' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -216,9 +213,7 @@ sub check_options {
|
|||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "ntp mode '" . $self->{option_results}->{ntp_mode} . "' not implemented" );
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
|
|
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub custom_status_output {
|
||||
|
@ -68,11 +68,11 @@ sub set_counters {
|
|||
];
|
||||
|
||||
$self->{maps_counters}->{interface} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
{ label => 'status', type => 2, critical_default => '%{status} ne "RU"', set => {
|
||||
key_values => [ { name => 'status' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'in-discard', set => {
|
||||
|
@ -130,10 +130,7 @@ sub new {
|
|||
$options{options}->add_options(arguments => {
|
||||
'filter-state:s' => { name => 'filter_state', },
|
||||
'filter-interface:s' => { name => 'filter_interface' },
|
||||
'no-loopback' => { name => 'no_loopback', },
|
||||
'unknown-status:s' => { name => 'unknown_status', default => '' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{status} ne "RU"' }
|
||||
'no-loopback' => { name => 'no_loopback' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -145,13 +142,6 @@ sub prefix_interface_output {
|
|||
return "Interface '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub do_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -82,11 +82,11 @@ sub set_counters {
|
|||
}
|
||||
];
|
||||
$self->{maps_counters}->{sc} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
{ label => 'status', type => 2, critical_default => '%{active} =~ /failed/i', set => {
|
||||
key_values => [ { name => 'load' }, { name => 'active' }, { name => 'sub' }, { name => 'boot' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -98,21 +98,12 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{active} =~ /failed/i' }
|
||||
'filter-name:s' => { name => 'filter_name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub prefix_sc_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub custom_status_output {
|
||||
|
@ -104,11 +104,11 @@ sub set_counters {
|
|||
];
|
||||
|
||||
$self->{maps_counters}->{interface} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
{ label => 'status', type => 2, critical_default => '%{status} ne "RU"', set => {
|
||||
key_values => [ { name => 'status' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'in', set => {
|
||||
|
@ -140,10 +140,7 @@ sub new {
|
|||
'filter-interface:s' => { name => 'filter_interface' },
|
||||
'units:s' => { name => 'units', default => 'b/s' },
|
||||
'speed:s' => { name => 'speed' },
|
||||
'no-loopback' => { name => 'no_loopback', },
|
||||
'unknown-status:s' => { name => 'unknown_status', default => '' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{status} ne "RU"' },
|
||||
'no-loopback' => { name => 'no_loopback' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -172,8 +169,6 @@ sub check_options {
|
|||
$self->{output}->add_option_msg(short_msg => "To use percent, you need to set --speed option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub do_selection {
|
||||
|
|
Loading…
Reference in New Issue