Cleaning up the Zabbix database

Jurjen Bokma

May 2010

We've got Zabbix monitoring our machines, but some even more important databases on the same DBMS, and Zabbix is using 16GB and hogging the disk under /var. Cleanup time.

  1. zabbix=# SELECT pg_size_pretty(pg_database_size('zabbix')) As fulldbsize;
    16765 MB
    (1 row)

  2. (According to this thread on the Zabbix forum, history is a good acandidate to save some space:

    zabbix=# SELECT pg_size_pretty(pg_total_relation_size('history')) As fulltblsize, pg_size_pretty(pg_relation_size('history')) As justthetblsize;
    fulltblsize | justthetblsize
    6123 GB  | 12298 GB
    (1 row)

    (The numbers seem to be the wrong way around, but they're large anyway, so I can save space removing them.)

  3. zabbix=# truncate table history;

  4. zabbix=# vacuum analyze;