I've been noticing a substantial increase in storage usage in the /var directory, specifically in /var/lib/mysql/nagios, which is currently occupying nearly 5GB. It appears that historical data is taking up the most space, with specific files standing out:
Code: Select all
250M ./nagios_downtimehistory.MYI
286M ./nagios_statehistory.MYI
407M ./nagios_commenthistory.MYI
424M ./nagios_downtimehistory.MYD
1011M ./nagios_statehistory.MYD
1.4G ./nagios_commenthistory.MYDAdditionally, I’d like to know if it's safe to clean up some older data manually. I noticed we have a high volume of records in nagios_downtimehistory:
Code: Select all
MariaDB [nagios]> SELECT COUNT(*) FROM nagios_downtimehistory;
+----------+
| COUNT(*) |
+----------+
| 3617508 |
+----------+Code: Select all
MariaDB [nagios]> SELECT MIN(actual_start_time) AS oldest_downtime, MAX(actual_end_time) AS newest_downtime FROM nagios_downtimehistory;
+---------------------+---------------------+
| oldest_downtime | newest_downtime |
+---------------------+---------------------+
| 0000-00-00 00:00:00 | 2024-10-30 08:00:00 |
+---------------------+---------------------+Code: Select all
MariaDB [nagios]> SELECT COUNT(*) FROM nagios_downtimehistory WHERE was_started = '0' AND actual_end_time < DATE_SUB(NOW(), INTERVAL 1 MONTH);
+----------+
| COUNT(*) |
+----------+
| 23675 |
+----------+- Are the following commands safe to execute in order to delete older, incomplete downtime records and free up space?
Code: Select all
DELETE FROM nagios_downtimehistory WHERE was_started = 0 AND actual_end_time < DATE_SUB(NOW(), INTERVAL 1 YEAR); OPTIMIZE TABLE nagios_downtimehistory; - Is there a configuration setting in Nagios that can limit the storage of downtimes, comments, and other historical data to only the past year? This would help keep the database lean without manually pruning data periodically.