]> git.pld-linux.org Git - packages/cacti.git/blame - fix_icmp_on_windows_iis_servers.patch
- Add patch from date 2010/07/27 more info http://www.cacti.net/download_patches.php
[packages/cacti.git] / fix_icmp_on_windows_iis_servers.patch
CommitLineData
8514c08f
ER
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
3@@ -156,10 +156,9 @@
4 }
5 socket_set_block($this->socket);
6
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";
11- return false;
12+ break;
13 }
14
15 /* set socket receive timeout as appropriate */
16@@ -234,8 +233,9 @@
17 break;
18 }
19 }
20- }else{
21- /* we have to use the real ping */
22+ }
23+
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
26
27 /* host timeout given in ms, recalculate to sec, but make it an integer */
28@@ -253,10 +253,13 @@
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"]);
34 }else{
35 $result = shell_exec("ping -W " . ceil($this->timeout/1000) . " -c " . $this->retries . " -p " . $pattern . " " . $this->host["hostname"]);
36 }
37
38+ if (strtolower(PHP_OS) != "winnt") {
39 $position = strpos($result, "min/avg/max");
40
41 if ($position > 0) {
42@@ -274,6 +277,24 @@
43
44 return false;
45 }
46+ }else{
47+ $position = strpos($result, "Minimum");
48+
49+ if ($position > 0) {
50+ $output = trim(substr($result, $position));
51+ $pieces = explode(",", $output);
52+ $results = explode("=", $pieces[2]);
53+
54+ $this->ping_status = trim(str_replace("ms", "", $results[1]));
55+ $this->ping_response = "ICMP Ping Success (" . $this->ping_status . " ms)";
56+
57+ return true;
58+ }else{
59+ $this->status = "down";
60+ $this->ping_response = "ICMP ping Timed out";
61+
62+ return false;
63+ }
64 }
65 }else{
66 $this->ping_status = "down";
67@@ -642,7 +663,7 @@
68 /* snmp test */
69 if (($avail_method == AVAIL_SNMP_OR_PING) && ($ping_result == true)) {
70 $snmp_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)) {
74 $snmp_result = false;
75 }else if (($avail_method == AVAIL_SNMP) || ($avail_method == AVAIL_SNMP_AND_PING)) {
76@@ -650,7 +671,7 @@
77 /* snmp version 1/2 without community string assume SNMP test to be successful
78 due to backward compatibility issues */
79 $snmp_result = true;
80- $snmp_status = 0.000;
81+ $this->snmp_status = 0.000;
82 }else{
83 $snmp_result = $this->ping_snmp();
84 }
This page took 0.056794 seconds and 4 git commands to generate.