Skip to main content

Posts

Showing posts from March, 2023

How to "safely" truncate history tables in Zabbix 6 before enabling timescale.

The script was tested against Zabbix 6.0 and 6.2. I'll add a proper introduction soon. If you don't fully understand every single line better don't run it in production. --RECREATING HISTORY TABLES WITH DATA. INSTEAD OF "WHERE FALSE" YOU CAN USE "WHERE CLOCK > X" IF YOU WANT TO PRESERVE SOME DATA ALTER TABLE history RENAME TO history_big; CREATE TABLE history as SELECT * FROM history_big where false; ALTER TABLE history_uint RENAME TO history_uint_big; CREATE TABLE history_uint as SELECT * FROM history_uint_big where false; ALTER TABLE history_str RENAME TO history_str_big; CREATE TABLE history_str as SELECT * FROM history_str_big where false; ALTER TABLE history_log RENAME TO history_log_big; CREATE TABLE history_log as SELECT * FROM history_log_big where false; ALTER TABLE history_text RENAME TO history_text_big; CREATE TABLE history_text as SELECT * FROM history_text_big where false; ALTER TABLE history_text RENAME TO history_text_big; CREATE TABLE...