Fix #1461
This commit is contained in:
parent
8740044677
commit
847799a1b2
|
@ -41,12 +41,15 @@ sub new {
|
|||
"force-oid:s" => { name => 'force_oid' },
|
||||
"check-overload" => { name => 'check_overload' },
|
||||
"reboot-window:s" => { name => 'reboot_window', default => 5000 },
|
||||
"unit:s" => { name => 'unit', default => 's' },
|
||||
});
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
return $self;
|
||||
}
|
||||
|
||||
my $unitdiv = { s => 1, w => 604800, d => 86400, h => 3600, m => 60 };
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
@ -59,6 +62,9 @@ sub check_options {
|
|||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{option_results}->{unit} eq '' || !defined($unitdiv->{$self->{option_results}->{unit}})) {
|
||||
$self->{option_results}->{unit} = 's';
|
||||
}
|
||||
|
||||
$self->{statefile_cache}->check_options(%options);
|
||||
}
|
||||
|
@ -118,10 +124,10 @@ sub run {
|
|||
$value = $self->check_overload(timeticks => $value);
|
||||
$value = floor($value / 100);
|
||||
|
||||
my $exit_code = $self->{perfdata}->threshold_check(value => $value,
|
||||
my $exit_code = $self->{perfdata}->threshold_check(value => floor($value / $unitdiv->{$self->{option_results}->{unit}}),
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->perfdata_add(label => 'uptime', unit => 's',
|
||||
value => $value,
|
||||
$self->{output}->perfdata_add(label => 'uptime', unit => $self->{option_results}->{unit},
|
||||
value => floor($value / $unitdiv->{$self->{option_results}->{unit}}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0);
|
||||
|
@ -166,6 +172,11 @@ With that option, we manage the counter going back. But there is a few chance we
|
|||
To be used with check-overload option. Time in milliseconds (Default: 5000)
|
||||
You increase the chance of not missing a reboot if you decrease that value.
|
||||
|
||||
=item B<--unit>
|
||||
|
||||
Select the unit for performance data and thresholds. May be 's' for seconds, 'm' for minutes,
|
||||
'h' for hours, 'd' for days, 'w' for weeks. Default is seconds
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
Loading…
Reference in New Issue