Zabbix Free disk space is less than 20% on volume /var/lib/mysql CentOS8 mysql

Got the below disk space message and needed to free up some space.  Truncate history table and deleted trends,events and alerts data for 90 days. Warning! (This should not be done in none production enviroment and if you need the data in my case I need real time data and historical data is not of importance to me)

Problem name: Free disk space is less than 20% on volume /var/lib/mysql
Host: Zabbix server
Severity: Warning
Operational data: 19.94 %

First I stopped the service.

#service zabbix-server stop

The logged into mysql

#mysql

Selected the db with the issue

use zabbix;

Truncate history
truncate table history;
truncate table history_log;
truncate table history_str;
truncate table history_uint;
truncate table history_text ;

deleted trends,events and alerts data for 90 days

DELETE FROM history WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 90 DAY));
DELETE FROM trends_uint WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 90 DAY));
DELETE FROM trends WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 90 DAY));
DELETE FROM events WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 90 DAY));
DELETE FROM alerts WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 90 DAY));
exit;

Restared Zabbix Server
#service zabbix-server start

Checked status and logged onto dashboard to confirm it was working.

 

PS: Please, do not follow these kinds of suggestions to delete data in a production environment this is for test environments and cases where you dont historical data. Good luck lol,”

 

 

Leave a Comment