enhance gorgone nodes mode

This commit is contained in:
garnier-quentin 2021-02-04 10:14:23 +01:00
parent 448a1ffb36
commit ae97c81611

View File

@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
use centreon::plugins::misc;
sub prefix_node_output { sub prefix_node_output {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -52,8 +53,9 @@ sub set_counters {
$self->{maps_counters}->{nodes} = [ $self->{maps_counters}->{nodes} = [
{ label => 'ping-received-lasttime', nlabel => 'node.ping.received.lasttime.seconds', set => { { label => 'ping-received-lasttime', nlabel => 'node.ping.received.lasttime.seconds', set => {
key_values => [ { name => 'last_ping_recv' }, { name => 'display' }, ], key_values => [ { name => 'last_ping_recv' }, { name => 'last_ping_recv_human' }, { name => 'display' } ],
output_template => 'last ping received: %s s', output_template => 'last ping received: %s',
output_use => 'last_ping_recv_human',
perfdatas => [ perfdatas => [
{ template => '%d', min => -1, unit => 's', label_extra_instance => 1 } { template => '%d', min => -1, unit => 's', label_extra_instance => 1 }
] ]
@ -88,10 +90,12 @@ sub manage_selection {
next; next;
} }
my $last_ping_recv = defined($nodes->{data}->{$node_id}->{last_ping_recv}) && $nodes->{data}->{$node_id}->{last_ping_recv} != 0 ?
time() - $nodes->{data}->{$node_id}->{last_ping_recv} : -1;
$self->{nodes}->{ $node_id } = { $self->{nodes}->{ $node_id } = {
display => $node_id, display => $node_id,
last_ping_recv => defined($nodes->{data}->{$node_id}->{last_ping_recv}) ? last_ping_recv => $last_ping_recv,
time() - $nodes->{data}->{$node_id}->{last_ping_recv} : -1 last_ping_recv_human => $last_ping_recv != -1 ? centreon::plugins::misc::change_seconds(value => $last_ping_recv) : $last_ping_recv
}; };
$self->{global}->{total}++; $self->{global}->{total}++;
} }