From 0347bb2cf4efdbee2af8ef23d26a8442915d2a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Duret?= Date: Thu, 30 Nov 2023 16:21:52 +0100 Subject: [PATCH] (plugin) snmp_standard::mode::uptime - Add 2 decimals to the perfdata (#4731) --- src/snmp_standard/mode/uptime.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/snmp_standard/mode/uptime.pm b/src/snmp_standard/mode/uptime.pm index ea41517fd..1fcb09ba2 100644 --- a/src/snmp_standard/mode/uptime.pm +++ b/src/snmp_standard/mode/uptime.pm @@ -52,7 +52,7 @@ sub custom_uptime_perfdata { $self->{output}->perfdata_add( label => 'uptime', unit => $self->{instance_mode}->{option_results}->{unit}, nlabel => 'system.uptime.' . $unitdiv_long->{ $self->{instance_mode}->{option_results}->{unit} }, - value => floor($self->{result_values}->{uptime} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }), + value => sprintf("%.2f", $self->{result_values}->{uptime} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0 @@ -63,7 +63,7 @@ sub custom_uptime_threshold { my ($self, %options) = @_; return $self->{perfdata}->threshold_check( - value => floor($self->{result_values}->{uptime} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }), + value => sprintf("%.2f", $self->{result_values}->{uptime} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }), threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' },