diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index ecd757189e..9a93f9cf6e 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2010-10-21 Junichi Satoh + + * lib/PandoraFMS/NetworkServer.pm: Deleted FreeBSD specific SNMPGET + definition. It is the same as Linux. + + * lib/PandoraFMS/Tools.pm: Added FreeBSD specific Ping function. + 2010-10-20 Ramon Novoa * lib/PandoraFMS/ReconServer.pm: Pass the recon task group_id and diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index 674e9220ba..caa543e60d 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -274,12 +274,7 @@ sub pandora_snmp_get_command ($$$$$$$$$) { $output = ""; } - # Need to implement - elsif ($OSNAME eq "freebsd"){ - $output = ""; - } - - # by default LINUX calls + # by default LINUX/FreeBSD calls else { if ($snmp_version ne "3"){ $output = `$snmpget_cmd -v $snmp_version -r $snmp_retries -t $snmp_timeout -OUevqt -c '$snmp_community' $snmp_target $snmp_oid 2>/dev/null`; diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 8db2355e3a..b49c3741b6 100644 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -586,9 +586,16 @@ sub pandora_ping ($$) { $output = ""; } - # Need to implement elsif ($OSNAME eq "freebsd"){ - $output = ""; + my $ping_command = "ping"; + + if ($host =~ /\d+:|:\d+/ ) { + $ping_command = "ping6"; + } + + # Ping the host + `$ping_command -q -i $pa_config->{'networktimeout'} -n -c $pa_config->{'icmp_checks'} $host >/dev/null 2>&1`; + return ($? == 0) ? 1 : 0; } # by default LINUX calls @@ -650,9 +657,23 @@ sub pandora_ping_latency ($$) { $output = ""; } - # Need to implement elsif ($OSNAME eq "freebsd"){ - $output = ""; + my $ping_command = "ping"; + + if ($host =~ /\d+:|:\d+/ ) { + $ping_command = "ping6"; + } + + # Ping the host + my @output = `$ping_command -q -i $pa_config->{'networktimeout'} -n -c $pa_config->{'icmp_checks'} $host 2>/dev/null`; + + # Something went wrong + return 0 if ($? != 0); + + # Parse the output + my $stats = pop (@output); + return 0 unless ($stats =~ m/([\d\.]+)\/([\d\.]+)\/([\d\.]+)\/([\d\.]+) +ms/); + return $2; } # by default LINUX calls