Skip to content

Commit 40d6fcb

Browse files
fix: address Copilot review - sql.php double-print, missing awk parsing, typos
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent 921de64 commit 40d6fcb

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

lib/boost.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ function boost_get_arch_table_names($latest_table = '') {
669669
* 5) Process the entire result set
670670
*
671671
* @param (int) local_data_id - the local data id to update
672-
* @param (resourse) rrdtool_pipe - a pointer to the rrdtool process
672+
* @param (resource) rrdtool_pipe - a pointer to the rrdtool process
673673
*
674674
* @return (void)
675675
*/

lib/rrd.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,7 +2972,7 @@ function rrdtool_cacti_compare($data_source_id, &$info) {
29722972
}
29732973

29742974
/**
2975-
* Accomodate a Cacti bug where the heartbeat was not
2975+
* Accommodate a Cacti bug where the heartbeat was not
29762976
* propagated.
29772977
*/
29782978
if ($data_source['minimal_heartbeat'] != $profile_heartbeat) {
@@ -3072,7 +3072,7 @@ function rrdtool_cacti_compare($data_source_id, &$info) {
30723072
$file_rra['pdp_per_row'] = 0;
30733073
}
30743074

3075-
/* corrrect issue with older rrdtools */
3075+
/* correct issue with older rrdtools */
30763076
$file_rra['cf'] = trim($file_rra['cf'], '"');
30773077

30783078
if ($cacti_rra['cf'] == $file_rra['cf'] && $cacti_rra_id == $file_rra_id) {

scripts/sql.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@
1212
$cmd .= ' -p' . cacti_escapeshellarg($database_password);
1313
}
1414

15-
print trim($sql);
15+
$cmd .= ' status';
1616

17-
$sql = shell_exec($cmd);
17+
$output = shell_exec($cmd);
1818

19-
// Cacti expects 'U' on error, not empty string or 0.
20-
print trim($sql ?? '') ?: 'U';
19+
if ($output === null || $output === '') {
20+
print 'U';
21+
} else {
22+
// Extract the 6th field (Queries per second avg), matching original awk '{print $6}'
23+
$parts = preg_split('/\s+/', trim($output));
24+
print isset($parts[5]) ? $parts[5] : 'U';
25+
}

0 commit comments

Comments
 (0)