From d0d95cbca5eb1603365df29d33a80e78fe8725ef Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 28 Jan 2019 20:02:58 +0100 Subject: [PATCH] added pandora_block_ping to check response of multiple addresses Former-commit-id: a2202f029e0fae80f3156a1a10afca0fe18c7ac2 --- pandora_server/lib/PandoraFMS/Tools.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 5c9f974efb..1146e8ce92 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -112,6 +112,7 @@ our @EXPORT = qw( md5_init pandora_ping pandora_ping_latency + pandora_block_ping resolve_hostname ticks_totime safe_input @@ -1273,6 +1274,24 @@ sub pandora_ping_latency ($$$$) { return $output; } +######################################################################## +=head2 C<< pandora_block_ping (I<$pa_config>, I<$hosts>) >> + +Ping all given hosts. Returns an array with all hosts detected as alive. + +=cut +######################################################################## +sub pandora_block_ping($@) { + my ($pa_config, @hosts) = @_; + + # fping timeout in milliseconds + my $cmd = $pa_config->{'fping'} . " -a -q -t " . (1000 * $pa_config->{'networktimeout'}) . " " . (join (' ', @hosts)); + + my @output = `$cmd 2>$DEVNULL`; + + return @output; +} + ######################################################################## =head2 C<< month_have_days (I<$month>, I<$year>) >>