From 641dd69feee85299895a0d8eb4cffeca75cb9a20 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Fri, 17 Sep 2021 14:06:27 +0200 Subject: [PATCH] fix(hp/p2000): ntp mode - wrong perfdata and value (#3121) --- centreon/plugins/misc.pm | 9 +++++++-- storage/hp/p2000/xmlapi/mode/ntp.pm | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/centreon/plugins/misc.pm b/centreon/plugins/misc.pm index d76f347c2..ecde05994 100644 --- a/centreon/plugins/misc.pm +++ b/centreon/plugins/misc.pm @@ -372,7 +372,12 @@ sub change_seconds { { unit => 's', value => 1 }, ]; my %values = ('y' => 1, 'M' => 2, 'w' => 3, 'd' => 4, 'h' => 5, 'm' => 6, 's' => 7); - + my $sign = ''; + if ($options{value} <= 0) { + $sign = '-'; + $options{value} = abs($options{value}); + } + foreach (@$periods) { next if (defined($options{start}) && $values{$_->{unit}} < $values{$options{start}}); my $count = int($options{value} / $_->{value}); @@ -387,7 +392,7 @@ sub change_seconds { $str = $options{value}; $str .= $options{start} if (defined($options{start})); } - return $str; + return $sign . $str; } sub scale_bytesbit { diff --git a/storage/hp/p2000/xmlapi/mode/ntp.pm b/storage/hp/p2000/xmlapi/mode/ntp.pm index 8e3cf8924..8bdc789cb 100644 --- a/storage/hp/p2000/xmlapi/mode/ntp.pm +++ b/storage/hp/p2000/xmlapi/mode/ntp.pm @@ -97,7 +97,7 @@ sub set_counters { ]; $self->{maps_counters}->{contact} = [ - { label => 'contact-last-time', nlabel => 'ntp.contact.last.time.', set => { + { label => 'contact-last-time', nlabel => 'ntp.contact.last.time', set => { key_values => [ { name => 'contact_seconds' }, { name => 'contact_human' } ], output_template => 'last server contact: %s', output_use => 'contact_human',