Skip to content

Commit

Permalink
Fixing #5661: Ping6 Not found
Browse files Browse the repository at this point in the history
On Linux and *NIX variants Cacti is unable to find ping6 as it's not in the path
  • Loading branch information
TheWitness committed Feb 3, 2024
1 parent d31314e commit 60043cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Cacti CHANGELOG
-issue#5648: Fractional time offsets can cause huge webserver error-logs
-issue#5649: Inapprorpiate use of PHP_OS in lib/ping.php on Windows Platform
-issue#5655: Function get_allowed_devices can returns incorrect device list if session user_id variable is not set
-issue#5661: On Linux and *NIX variants Cacti is unable to find ping6 as it's not in the path

1.2.26
-issue#5464: PHP warning when view Data Source Info mode with new Data Source
Expand Down
8 changes: 4 additions & 4 deletions lib/ping.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function ping_icmp() {
$result = shell_exec('ping -t ' . ceil($this->timeout / 1000) . ' -c ' . $this->retries . ' ' . $this->host['hostname']);
} elseif (substr_count(strtolower(PHP_OS), 'freebsd')) {
if (strpos($this->host['hostname'], ':') !== false) {
$result = shell_exec('ping6 -X ' . ceil($this->timeout / 1000) . ' -c ' . $this->retries . ' ' . $this->host['hostname']);
$result = shell_exec('/usr/sbin/ping6 -X ' . ceil($this->timeout / 1000) . ' -c ' . $this->retries . ' ' . $this->host['hostname']);
} else {
$result = shell_exec('ping -t ' . ceil($this->timeout / 1000) . ' -c ' . $this->retries . ' ' . $this->host['hostname']);
}
Expand All @@ -211,12 +211,12 @@ function ping_icmp() {
* as it now tries to open an ICMP socket and fails
* $result will be empty, then. */
if (strpos($host_ip, ':') !== false) {
$result = shell_exec('ping6 -W ' . ceil($this->timeout / 1000) . ' -c ' . $this->retries . ' -p ' . $pattern . ' ' . $this->host['hostname']);
$result = shell_exec('/usr/sbin/ping6 -W ' . ceil($this->timeout / 1000) . ' -c ' . $this->retries . ' -p ' . $pattern . ' ' . $this->host['hostname']);
} else {
$result = shell_exec('ping -W ' . ceil($this->timeout / 1000) . ' -c ' . $this->retries . ' -p ' . $pattern . ' ' . $this->host['hostname'] . ' 2>&1');

if ((strpos($result, 'unknown host') !== false || strpos($result, 'Address family') !== false) && file_exists('/bin/ping6')) {
$result = shell_exec('ping6 -W ' . ceil($this->timeout / 1000) . ' -c ' . $this->retries . ' -p ' . $pattern . ' ' . $this->host['hostname']);
if ((strpos($result, 'unknown host') !== false || strpos($result, 'Address family') !== false) && file_exists('/usr/sbin/ping6')) {
$result = shell_exec('/usr/sbin/ping6 -W ' . ceil($this->timeout / 1000) . ' -c ' . $this->retries . ' -p ' . $pattern . ' ' . $this->host['hostname']);
}
}
}
Expand Down

0 comments on commit 60043cb

Please sign in to comment.