Cleaning up the Zabbix database

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. Determine the size of the database

  2. Determine the size of history

    (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. Cull the table

    zabbix=# truncate table history;

  4. Reclaim the space won

    zabbix=# vacuum analyze;
      VACUUM