ICMP ping does not work after update to 0.8.7d
Moderators: Developers, Moderators
-
- Cacti User
- Posts: 151
- Joined: Mon Feb 05, 2007 3:57 am
- Location: Munich, Germany
-
- Cacti User
- Posts: 151
- Joined: Mon Feb 05, 2007 3:57 am
- Location: Munich, Germany
Do ping.php and host.php use the same method to detect host up/down? I crawled the code a bit (allthough I'm not an php expert) and found that host.php seems to use pear-Net_Ping, is that correct? Maybe here's the problem?!
Again:
- ICMP works for host detection at the device detail page.
- At the device list the host is considered as down.
- Switching to TCP or UDP ping solves the issue.
Again:
- ICMP works for host detection at the device detail page.
- At the device list the host is considered as down.
- Switching to TCP or UDP ping solves the issue.
- Attachments
-
- ICMP4.JPG (65.44 KiB) Viewed 2470 times
-
- ICMP3.JPG (52.77 KiB) Viewed 2470 times
I noticed a similar situation when cacti is running on Solaris. The issue here is that with ping.php in 0.8.7.d and e, the ping command that is used will only return the string "<hostname> is alive!". This is not acceptable to the subsequent conditional checks in the script. To fix this issue I made a change to ping.php.
Change this:
To this:
Notice that I also changed "sun" to "sunos" as this is what Cacti was reporting as the PHP_OS value on the tech support page under PHP info.
Change this:
Code: Select all
if (substr_count(strtolower(PHP_OS), "sun")) {
$result = shell_exec("ping " . $this->host["hostname"]);
Code: Select all
if (substr_count(strtolower(PHP_OS), "sunos")) {
$result = shell_exec("ping -s " . $this->host["hostname"] . " 56 1");
I'm gentoo user
<?php echo PHP_OS; ?> displaye: Linux
I add in lib/ping.php code:
turned:
and ping ICMP works well
ps:
<?php echo PHP_OS; ?> displaye: Linux
I add in lib/ping.php code:
Code: Select all
}else if (substr_count(strtolower(PHP_OS), "Linux")) {
$result = shell_exec("ping -t " . ceil($this->timeout/1000) . " -c " . $this->retries . " " . $this->host["hostname"]);
Code: Select all
if (substr_count(strtolower(PHP_OS), "sun")) {
$result = shell_exec("ping " . $this->host["hostname"]);
}else if (substr_count(strtolower(PHP_OS), "hpux")) {
$result = shell_exec("ping -m " . ceil($this->timeout/1000) . " -n " . $this->retries . " " . $this->host["hostname"]);
}else if (substr_count(strtolower(PHP_OS), "mac")) {
$result = shell_exec("ping -t " . ceil($this->timeout/1000) . " -c " . $this->retries . " " . $this->host["hostname"]);
}else if (substr_count(strtolower(PHP_OS), "freebsd")) {
$result = shell_exec("ping -t " . ceil($this->timeout/1000) . " -c " . $this->retries . " " . $this->host["hostname"]);
}else if (substr_count(strtolower(PHP_OS), "darwin")) {
$result = shell_exec("ping -t " . ceil($this->timeout/1000) . " -c " . $this->retries . " " . $this->host["hostname"]);
}else if (substr_count(strtolower(PHP_OS), "bsd")) {
$result = shell_exec("ping -w " . ceil($this->timeout/1000) . " -c " . $this->retries . " " . $this->host["hostname"]);
}else if (substr_count(strtolower(PHP_OS), "aix")) {
$result = shell_exec("ping -i " . ceil($this->timeout/1000) . " -c " . $this->retries . " " . $this->host["hostname"]);
}else if (substr_count(strtolower(PHP_OS), "winnt")) {
$result = shell_exec("ping -w " . $this->timeout . " -n " . $this->retries . " " . $this->host["hostname"]);
}else if (substr_count(strtolower(PHP_OS), "Linux")) {
$result = shell_exec("ping -t " . ceil($this->timeout/1000) . " -c " . $this->retries . " " . $this->host["hostname"]);
ps:
Code: Select all
webstream ~ # uname -r
2.6.32-gentoo-r7
PHP 5.2.13-pl0-gentoo (cli) (built: Jul 8 2010 08:40:35)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
* net-analyzer/cacti Latest version available: 0.8.7e-r2
Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]
[-p pattern] [-s packetsize] [-t ttl] [-I interface or address]
[-M mtu discovery hint] [-S sndbuf]
[ -T timestamp option ] [ -Q tos ] [hop1 ...] destination
- gandalf
- Developer
- Posts: 22383
- Joined: Thu Dec 02, 2004 2:46 am
- Location: Muenster, Germany
- Contact:
I wonder how this should match. "strtolower" should not match any string containing a capital letter.Vasilich wrote:Code: Select all
}else if (substr_count(strtolower(PHP_OS), "Linux")) { $result = shell_exec("ping -t " . ceil($this->timeout/1000) . " -c " . $this->retries . " " . $this->host["hostname"]);
R.
- gandalf
- Developer
- Posts: 22383
- Joined: Thu Dec 02, 2004 2:46 am
- Location: Muenster, Germany
- Contact:
Net_Ping is supposed to be taken from ./lib/ping.php which defines this method.Helmut Schneider wrote:Do ping.php and host.php use the same method to detect host up/down? I crawled the code a bit (allthough I'm not an php expert) and found that host.php seems to use pear-Net_Ping, is that correct? Maybe here's the problem?!
R.
- gandalf
- Developer
- Posts: 22383
- Joined: Thu Dec 02, 2004 2:46 am
- Location: Muenster, Germany
- Contact:
That should change anything, as "substr_count" will match even if the search string is "sun" only.commoboy wrote:Notice that I also changed "sun" to "sunos" as this is what Cacti was reporting as the PHP_OS value on the tech support page under PHP info.
What does SunOS say related to "ping -s"? What's the meaning of that cli switch and the numbers you've appended? For which exact version does this apply?
R.
Who is online
Users browsing this forum: No registered users and 2 guests