ICMP ping does not work after update to 0.8.7d

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Helmut Schneider
Cacti User
Posts: 151
Joined: Mon Feb 05, 2007 3:57 am
Location: Munich, Germany

Post by Helmut Schneider »

I switched to spine but the same behavior, no ICMP packets watched by tcpdump. I'm running nagios on the same machines and it *does* send ICMP pakets. Any ideas highly appreciated...
Helmut Schneider
Cacti User
Posts: 151
Joined: Mon Feb 05, 2007 3:57 am
Location: Munich, Germany

Post by Helmut Schneider »

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.
Attachments
ICMP4.JPG
ICMP4.JPG (65.44 KiB) Viewed 2468 times
ICMP3.JPG
ICMP3.JPG (52.77 KiB) Viewed 2468 times
commoboy
Posts: 6
Joined: Mon Mar 21, 2005 1:46 pm
Location: Seattle
Contact:

Post by commoboy »

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:

Code: Select all

if (substr_count(strtolower(PHP_OS), "sun")) {
                                        $result = shell_exec("ping " . $this->host["hostname"]);
To this:

Code: Select all

 if (substr_count(strtolower(PHP_OS), "sunos")) {
                                        $result = shell_exec("ping -s " . $this->host["hostname"] . " 56 1");
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.
Vasilich
Posts: 3
Joined: Wed Feb 04, 2009 10:05 am

Post by Vasilich »

I'm gentoo user

<?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"]);
turned:

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"]);
and ping ICMP works well

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
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

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"]);
I wonder how this should match. "strtolower" should not match any string containing a capital letter.
R.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

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?!
Net_Ping is supposed to be taken from ./lib/ping.php which defines this method.
R.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

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.
That should change anything, as "substr_count" will match even if the search string is "sun" only.
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.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests