fix(hp/p2000): ntp mode - wrong perfdata and value (#3121)

This commit is contained in:
qgarnier 2021-09-17 14:06:27 +02:00 committed by GitHub
parent f10ce9212a
commit 641dd69fee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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 {

View File

@ -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',