Skip to content

Commit 2f3eacf

Browse files
committed
Fixing Cacti#5185 - Orphaned Poller Items
Repair Database does not prune old Poller Item Records
1 parent 71010b9 commit 2f3eacf

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Cacti CHANGELOG
2727
-issue#5181: Poller functions can cause SQL errors in some cases when working with remote data collectors
2828
-issue#5182: Graph Image does not have check for Remote Agent
2929
-issue#5184: Cacti permission checks generate SQL errors is the user has been deleted
30+
-issue#5185: Repair Database does not prune old Poller Item Records
3031

3132
1.2.23
3233
-security#4920: Add .htaccess file to scripts folder

cli/repair_database.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,21 @@
255255
print 'NOTE: Found No Data Input Data hostname or host_id Type Code issues' . PHP_EOL;
256256
}
257257

258+
print 'NOTE: Repairing orphaned Poller Items.' . PHP_EOL;
259+
260+
db_execute('DELETE pi
261+
FROM poller_item AS pi
262+
LEFT JOIN data_local AS dl
263+
ON pi.local_data_id = dl.id
264+
WHERE dl.id IS NULL');
265+
266+
$fixes = db_affected_rows();
267+
if ($fixes) {
268+
printf('NOTE: Found and Repaired %s Poller Items' . PHP_EOL, $fixes);
269+
} else {
270+
print 'NOTE: Found No Problems with orphaned Poller Items' . PHP_EOL;
271+
}
272+
258273
print PHP_EOL . '------------------------------------------------------------------------' . PHP_EOL;
259274
print 'Detailed Checks. Use --force to repair if found.' . PHP_EOL . PHP_EOL;
260275

0 commit comments

Comments
 (0)