2017年3月22日水曜日

Zabbix Housekeeper 手動実行

Zabbix Housekeeper に関して
http://naiggy.blogspot.com/2017/03/zabbixhousekeeper.html
参考ください。

手動実行は
僕の場合は60日以前のデータを削除するスクリプトです。
60のところだけを修正して必要な数字を入れてください。

Mysql

delete from history where clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));
delete from history_str where clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));
delete from history_log where clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));
delete from history_uint where clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));
delete from history_text where clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));
delete from trends where clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));
delete from trends_uint where clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));
delete from service_alarms where clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));
delete from auditlog where clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));
delete from events where clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));
delete from sessions where lastaccess < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 day));

PostgreSQL

delete from history where clock < extract('epoch' from current_timestamp - interval'60 days') ;
delete from history_str where clock < extract('epoch' from current_timestamp - interval'60 days') ;
delete from history_log where clock < extract('epoch' from current_timestamp - interval'60 days') ;
delete from history_uint where clock < extract('epoch' from current_timestamp - interval'60 days') ;
delete from history_text where clock < extract('epoch' from current_timestamp - interval'60 days') ;
delete from trends where clock < extract('epoch' from current_timestamp - interval'60 days') ;
delete from trends_uint where clock < extract('epoch' from current_timestamp - interval'60 days') ;
delete from service_alarms where clock < extract('epoch' from current_timestamp - interval'60 days') ;
delete from auditlog where clock < extract('epoch' from current_timestamp - interval'60 days') ;
delete from events where clock < extract('epoch' from current_timestamp - interval'60 days') ;
delete from sessions where lastaccess < extract('epoch' from current_timestamp - interval'60 days') ;

0 件のコメント: