fix 0 uptime value

This commit is contained in:
garnier-quentin 2020-02-13 14:28:41 +01:00
parent 13a4f415b0
commit 14c194723f
2 changed files with 19 additions and 13 deletions

View File

@ -392,6 +392,10 @@ sub change_seconds {
$str_append = ' '; $str_append = ' ';
} }
if ($str eq '') {
$str = $options{value};
$str .= $options{start} if (defined($options{start}));
}
return $str; return $str;
} }

View File

@ -35,12 +35,12 @@ sub new {
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' },
"force-oid:s" => { name => 'force_oid' }, 'force-oid:s' => { name => 'force_oid' },
"check-overload" => { name => 'check_overload' }, 'check-overload' => { name => 'check_overload' },
"reboot-window:s" => { name => 'reboot_window', default => 5000 }, 'reboot-window:s' => { name => 'reboot_window', default => 5000 },
"unit:s" => { name => 'unit', default => 's' }, 'unit:s' => { name => 'unit', default => 's' },
}); });
$self->{statefile_cache} = centreon::plugins::statefile->new(%options); $self->{statefile_cache} = centreon::plugins::statefile->new(%options);
@ -123,8 +123,10 @@ sub run {
$value = $self->check_overload(timeticks => $value); $value = $self->check_overload(timeticks => $value);
$value = floor($value / 100); $value = floor($value / 100);
my $exit_code = $self->{perfdata}->threshold_check(value => floor($value / $unitdiv->{$self->{option_results}->{unit}}), my $exit_code = $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); value => floor($value / $unitdiv->{$self->{option_results}->{unit}}),
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]
);
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => 'uptime', unit => $self->{option_results}->{unit}, label => 'uptime', unit => $self->{option_results}->{unit},
value => floor($value / $unitdiv->{$self->{option_results}->{unit}}), value => floor($value / $unitdiv->{$self->{option_results}->{unit}}),