From 08e890229b3198d1317cd0a96796f4a83753710e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 4 Feb 2021 10:14:23 +0100 Subject: [PATCH] enhance gorgone nodes mode --- centreon-plugins/apps/gorgone/restapi/mode/nodes.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/centreon-plugins/apps/gorgone/restapi/mode/nodes.pm b/centreon-plugins/apps/gorgone/restapi/mode/nodes.pm index 8cf901660..36bf83330 100644 --- a/centreon-plugins/apps/gorgone/restapi/mode/nodes.pm +++ b/centreon-plugins/apps/gorgone/restapi/mode/nodes.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use centreon::plugins::misc; sub prefix_node_output { my ($self, %options) = @_; @@ -52,8 +53,9 @@ sub set_counters { $self->{maps_counters}->{nodes} = [ { label => 'ping-received-lasttime', nlabel => 'node.ping.received.lasttime.seconds', set => { - key_values => [ { name => 'last_ping_recv' }, { name => 'display' }, ], - output_template => 'last ping received: %s s', + key_values => [ { name => 'last_ping_recv' }, { name => 'last_ping_recv_human' }, { name => 'display' } ], + output_template => 'last ping received: %s', + output_use => 'last_ping_recv_human', perfdatas => [ { template => '%d', min => -1, unit => 's', label_extra_instance => 1 } ] @@ -88,10 +90,12 @@ sub manage_selection { 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 } = { display => $node_id, - last_ping_recv => defined($nodes->{data}->{$node_id}->{last_ping_recv}) ? - time() - $nodes->{data}->{$node_id}->{last_ping_recv} : -1 + last_ping_recv => $last_ping_recv, + last_ping_recv_human => $last_ping_recv != -1 ? centreon::plugins::misc::change_seconds(value => $last_ping_recv) : $last_ping_recv }; $self->{global}->{total}++; }