Skip to content

Commit

Permalink
Fixing #5475 - Issue with ss_fping.php and PHP8 strict typing (#5477)
Browse files Browse the repository at this point in the history
* QA: Broken Function

* QA: Two additional QA Items

- Do a check for IP address as dns_get_records() does not have a timeout and I don't use DNS
- Properly display information about MariaDB 11.

* Fixing #5475 - Ping Issues with Advanced Ping an PHP8

PHP 8.x error - Unsupported operand types: float + string

* QA: Fix two typos
  • Loading branch information
TheWitness authored Sep 3, 2023
1 parent 67a2649 commit c59b6b9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Cacti CHANGELOG
-issue#5462: Package preview aparantely making changes to Cacti Templates or there is a Caching issue
-issue#5466: When enabling boost on a fresh install, we get a single error in the Cacti log
-issue#5467: Cacti logging throws error when attempting to generate a log message from empty log string in PHP 8.x
-issue#5475: PHP 8.x error - Unsupported operand types: float + string
-feature#5375: Add template for Fortinet firewall and Aruba Instant cluster
-feature#5393: Add template for SNMP printer
-feature#5418: Display device class before package import
Expand Down
4 changes: 2 additions & 2 deletions include/global_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2289,12 +2289,12 @@
)
),
'extended_paths_header' => array(
'friendly_name' => __('Structured RRDfile Paths'),
'friendly_name' => __('Structure RRDfile Paths'),
'method' => 'spacer',
'collapsible' => 'true'
),
'extended_paths' => array(
'friendly_name' => __('Method'),
'friendly_name' => __('Enable Structured Paths'),
'description' => __('Use a separate subfolder for each hosts RRD files. The naming of the RRDfiles will be one of the following:<br><ul><li>&lt;path_cacti&gt;/rra/host_id/local_data_id.rrd,</li><li>&lt;path_cacti&gt;/rra/device_id/data_query_id/local_data_id.rrd,</li><li>&lt;path_cacti&gt;/rra/device_hash/device_id/local_data_id.rrd,</li><li>&lt;path_cacti&gt;/rra/device_hash/device_id/data_query_id/local_data_id.rrd.</li></ul><br>You can make this change after install by running the CLI script <b>structure_rra_paths.php</b> after you make the change. NOTE: If you change Max Directories value to decrease the number of directories, or if you change the Directory Pattern, empty directories will not be pruned after you rerun the <b>structure_rra_paths.php</b> script.'),
'method' => 'checkbox'
),
Expand Down
Binary file modified install/templates/PING_Advanced_Ping.xml.gz
Binary file not shown.
25 changes: 21 additions & 4 deletions scripts/ss_fping.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,32 @@ function ss_fping($hostname = '', $ping_sweeps = 6, $ping_type = 'ICMP', $port =

$i = 0;
while ($i < $ping_sweeps) {
$start = microtime(true);
$result = $ping->ping(AVAIL_PING, $method, $ping_timeout, 1);
$end = microtime(true);

if (!$result) {
// Error response
$failed_results++;
} else {
$time[$i] = $ping->ping_status;

$time[$i] = $end - $start;
$total_time += $end - $start;
} elseif (is_numeric($ping->ping_status)) {
$time[$i] = $ping->ping_status;
$total_time += $ping->ping_status;
if ($ping->ping_status < $min) $min = $ping->ping_status;
if ($ping->ping_status > $max) $max = $ping->ping_status;
if ($ping->ping_status < $min) {
$min = $ping->ping_status;
}

if ($ping->ping_status > $max) {
$max = $ping->ping_status;
}
} else {
// Down response
$failed_results++;

$time[$i] = $end - $start;
$total_time += $end - $start;
}

$i++;
Expand Down

0 comments on commit c59b6b9

Please sign in to comment.