Cleaning up Zabbix database

Zabbix database can grow quite considerably over time. Expecially if you use default templates where many items are checked at interval of 30 and aren’t even used in the triggers.

The biggest database I had to manage so far was about 80Gb. And when I tried to upgrade, it took a day or two to run all the scripts. Of course, having to backup 80Gb of SQL data does not add to my enjoyment as well.

So, there it goes – a few scripts, some stolen copied from another person’s repo, some written by myself: github link

With that, the database shrinked from 80Gb to 15Gb, quite an improvement. And the upgrade was finished in a few hours.

NOTE: due to the way the databases work (Mysql in particular), running these scripts won’t reduce Zabbix db size if it’s already bloated. You will have to dump and reload the db after that. What the scripts do is keep its size more or less constant if you run them regularly.