1 --- cacti-0.8.7e/lib/ping.php 2009-06-28 12:07:11.000000000 -0400
2 +++ cacti-0.8.7e-patched/lib/ping.php 2009-09-01 16:22:22.000000000 -0400
5 socket_set_block($this->socket);
7 + /* use traditional ping if we can't create a raw socket */
8 if (!(@socket_connect($this->socket, $host_ip, NULL))) {
9 - $this->ping_response = "Cannot connect to host";
10 - $this->ping_status = "down";
15 /* set socket receive timeout as appropriate */
21 - /* we have to use the real ping */
24 + /* we have to use the real ping, in cases where windows failed or while using UNIX/Linux */
25 $pattern = bin2hex("cacti-monitoring-system"); // the actual test data
27 /* host timeout given in ms, recalculate to sec, but make it an integer */
29 $result = shell_exec("ping -w " . ceil($this->timeout/1000) . " -c " . $this->retries . " " . $this->host["hostname"]);
30 }else if (substr_count(strtolower(PHP_OS), "aix")) {
31 $result = shell_exec("ping -i " . ceil($this->timeout/1000) . " -c " . $this->retries . " " . $this->host["hostname"]);
32 + }else if (substr_count(strtolower(PHP_OS), "winnt")) {
33 + $result = shell_exec("ping -w " . $this->timeout . " -n " . $this->retries . " " . $this->host["hostname"]);
35 $result = shell_exec("ping -W " . ceil($this->timeout/1000) . " -c " . $this->retries . " -p " . $pattern . " " . $this->host["hostname"]);
38 + if (strtolower(PHP_OS) != "winnt") {
39 $position = strpos($result, "min/avg/max");
47 + $position = strpos($result, "Minimum");
49 + if ($position > 0) {
50 + $output = trim(substr($result, $position));
51 + $pieces = explode(",", $output);
52 + $results = explode("=", $pieces[2]);
54 + $this->ping_status = trim(str_replace("ms", "", $results[1]));
55 + $this->ping_response = "ICMP Ping Success (" . $this->ping_status . " ms)";
59 + $this->status = "down";
60 + $this->ping_response = "ICMP ping Timed out";
66 $this->ping_status = "down";
69 if (($avail_method == AVAIL_SNMP_OR_PING) && ($ping_result == true)) {
71 - $snmp_status = 0.000;
72 + $this->snmp_status = 0.000;
73 }else if (($avail_method == AVAIL_SNMP_AND_PING) && ($ping_result == false)) {
75 }else if (($avail_method == AVAIL_SNMP) || ($avail_method == AVAIL_SNMP_AND_PING)) {
77 /* snmp version 1/2 without community string assume SNMP test to be successful
78 due to backward compatibility issues */
80 - $snmp_status = 0.000;
81 + $this->snmp_status = 0.000;
83 $snmp_result = $this->ping_snmp();