Merged Junichi's patch and added support for setting the number of ICMP

packets.
This commit is contained in:
Ramon Novoa 2015-03-18 16:21:39 +01:00
parent 554fb7aa2c
commit d4f8af2a56
6 changed files with 50 additions and 17 deletions

View File

@ -159,7 +159,11 @@ network_threads 4
# icmp_checks x : defines number of pings for each icmp_proc module type. at least one of
# that ping should be 1 to report 1. Setting this to 1 will make all icmp montioring faster but
# with more probability of failure.
icmp_checks 3
icmp_checks 3
# Number of ICMP packets to send per request.
icmp_packets 1
# tcp specific options :
# tcp_checks: number of tcp retries if first attempt fails.

View File

@ -162,6 +162,9 @@ network_threads 4
icmp_checks 3
# Number of ICMP packets to send per request.
icmp_packets 1
# tcp specific options :
# tcp_checks: number of tcp retries if first attempt fails.
# tcp_timeout: specific timeout for tcp connections

View File

@ -158,6 +158,9 @@ network_threads 4
icmp_checks 3
# Number of ICMP packets to send per request.
icmp_packets 1
# tcp specific options :
# tcp_checks: number of tcp retries if first attempt fails.
# tcp_timeout: specific timeout for tcp connections

View File

@ -131,7 +131,10 @@ network_threads 5
# that ping should be 1 to report 1. Lower value have better performance, but more probability
# of false positives
icmp_checks 3.
icmp_checks 3
# Number of ICMP packets to send per request.
icmp_packets 1
# tcp specific options :
# tcp_checks: number of tcp retries if first attempt fails.

View File

@ -208,6 +208,7 @@ sub pandora_load_config {
$pa_config->{"keepalive"} = 60; # 60 Seconds initially for server keepalive
$pa_config->{"keepalive_orig"} = $pa_config->{"keepalive"};
$pa_config->{"icmp_checks"} = 1; # Introduced on 1.3.1
$pa_config->{"icmp_packets"} = 1; # > 5.1SP2
$pa_config->{"alert_recovery"} = 0; # Introduced on 1.3.1
$pa_config->{"snmp_checks"} = 1; # Introduced on 1.3.1
$pa_config->{"snmp_timeout"} = 8; # Introduced on 1.3.1
@ -565,6 +566,9 @@ sub pandora_load_config {
elsif ($parametro =~ m/^icmp_checks\s([0-9]*)/i) {
$pa_config->{"icmp_checks"} = clean_blank($1);
}
elsif ($parametro =~ m/^icmp_packets\s([0-9]*)/i) {
$pa_config->{"icmp_packets"} = clean_blank($1);
}
elsif ($parametro =~ m/^snmpconsole\s([0-9]*)/i) {
$pa_config->{"snmpconsole"} = clean_blank($1);
}

View File

@ -852,6 +852,7 @@ sub pandora_ping ($$$$) {
if ($retries == 0) {
$retries = $pa_config->{'icmp_checks'};
}
my $packets = defined($pa_config->{'icmp_packets'}) ? $pa_config->{'icmp_packets'} : 1;
my $output = 0;
my $i;
@ -862,10 +863,13 @@ sub pandora_ping ($$$$) {
# Windows XP .. Windows 7
if (($OSNAME eq "MSWin32") || ($OSNAME eq "MSWin32-x64") || ($OSNAME eq "cygwin")){
my $ms_timeout = $timeout * 1000;
$output = `ping -n $retries -w $ms_timeout $host`;
for ($i=0; $i < $retries; $i++) {
$output = `ping -n $packets -w $ms_timeout $host`;
if ($output =~ /TTL/){
return 1;
}
sleep 1;
}
return 0;
}
@ -880,10 +884,13 @@ sub pandora_ping ($$$$) {
# 'networktimeout' is not used by ping on Solaris.
# Ping the host
`$ping_command -s -n $host 56 $retries >$DEVNULL 2>&1`;
for ($i=0; $i < $retries; $i++) {
`$ping_command -s -n $host 56 $packets >$DEVNULL 2>&1`;
if ($? == 0) {
return 1;
}
sleep 1;
}
return 0;
}
@ -898,10 +905,13 @@ sub pandora_ping ($$$$) {
# 'networktimeout' is not used by ping6 on FreeBSD.
# Ping the host
`$ping_command -q -n -c $retries $host >$DEVNULL 2>&1`;
for ($i=0; $i < $retries; $i++) {
`$ping_command -q -n -c $packets $host >$DEVNULL 2>&1`;
if ($? == 0) {
return 1;
}
sleep 1;
}
return 0;
}
@ -916,10 +926,13 @@ sub pandora_ping ($$$$) {
# 'networktimeout' is not used by ping6 on NetBSD.
# Ping the host
`$ping_command -q -n -c $retries $host >$DEVNULL 2>&1`;
for ($i=0; $i < $retries; $i++) {
`$ping_command -q -n -c $packets $host >$DEVNULL 2>&1`;
if ($? == 0) {
return 1;
}
sleep 1;
}
return 0;
}
@ -933,10 +946,13 @@ sub pandora_ping ($$$$) {
}
# Ping the host
`$ping_command -q -W $timeout -n -c $retries $host >$DEVNULL 2>&1`;
for ($i=0; $i < $retries; $i++) {
`$ping_command -q -W $timeout -n -c $packets $host >$DEVNULL 2>&1`;
if ($? == 0) {
return 1;
}
sleep 1;
}
return 0;
}