void main_housekeeper_loop() { int d, now; set_child_signal_handler(); for (;;) { zabbix_log(LOG_LEVEL_WARNING, "Executing housekeeper"); now = time(NULL); zbx_setproctitle("%s [connecting to the database]", get_process_type_string(process_type)); DBconnect(ZBX_DB_CONNECT_NORMAL); /* Transaction is not required here. It causes timeouts under MySQL. */ /* DBbegin();*/ zbx_setproctitle("%s [removing old history]", get_process_type_string(process_type)); d = housekeeping_history_and_trends(now); zabbix_log(LOG_LEVEL_WARNING, "Deleted %d records from history and trends", d); zbx_setproctitle("%s [removing old history]", get_process_type_string(process_type)); housekeeping_process_log(now); zbx_setproctitle("%s [removing old events]", get_process_type_string(process_type)); housekeeping_events(now); zbx_setproctitle("%s [removing old alerts]", get_process_type_string(process_type)); housekeeping_alerts(now); zbx_setproctitle("%s [removing old sessions]", get_process_type_string(process_type)); housekeeping_sessions(now); /* Transaction is not required here. It causes timeouts under MySQL. */ /* DBcommit();*/ /* zbx_setproctitle("housekeeper [vacuuming database]");*/ /* DBvacuum();*/ DBclose(); zbx_sleep_loop(SEC_PER_HOUR * CONFIG_HOUSEKEEPING_FREQUENCY); } }
void main_housekeeper_loop() { int now, d_history_and_trends, d_cleanup, d_events, d_alerts, d_sessions; for (;;) { zabbix_log(LOG_LEVEL_WARNING, "executing housekeeper"); now = time(NULL); zbx_setproctitle("%s [connecting to the database]", get_process_type_string(process_type)); DBconnect(ZBX_DB_CONNECT_NORMAL); zbx_setproctitle("%s [removing old history and trends]", get_process_type_string(process_type)); d_history_and_trends = housekeeping_history_and_trends(now); zbx_setproctitle("%s [removing deleted items data]", get_process_type_string(process_type)); d_cleanup = housekeeping_cleanup(); zbx_setproctitle("%s [removing old events]", get_process_type_string(process_type)); d_events = housekeeping_events(now); zbx_setproctitle("%s [removing old alerts]", get_process_type_string(process_type)); d_alerts = housekeeping_alerts(now); zbx_setproctitle("%s [removing old sessions]", get_process_type_string(process_type)); d_sessions = housekeeping_sessions(now); zabbix_log(LOG_LEVEL_WARNING, "housekeeper deleted: %d records from history and trends," " %d records of deleted items, %d events, %d alerts, %d sessions", d_history_and_trends, d_cleanup, d_events, d_alerts, d_sessions); DBclose(); zbx_sleep_loop(CONFIG_HOUSEKEEPING_FREQUENCY * SEC_PER_HOUR); } }
int main_housekeeper_loop() { int now; int d; if(CONFIG_DISABLE_HOUSEKEEPING == 1) { for(;;) { /* Do nothing */ zbx_setproctitle("do nothing"); sleep(3600); } } for(;;) { zabbix_log( LOG_LEVEL_WARNING, "Executing housekeeper"); now = time(NULL); zbx_setproctitle("connecting to the database"); DBconnect(ZBX_DB_CONNECT_NORMAL); /* Transaction is not required here. It causes timeouts under MySQL */ /* DBbegin();*/ /* zbx_setproctitle("housekeeper [removing deleted hosts]");*/ /* housekeeping_hosts();*/ /* zbx_setproctitle("housekeeper [removing deleted items]");*/ /* housekeeping_items();*/ /* zbx_setproctitle("housekeeper [removing old history]");*/ /* d = housekeeping_history_and_trends(now); */ /* zabbix_log( LOG_LEVEL_WARNING, "Deleted %d records from history and trends", */ /* d); */ /* zbx_setproctitle("housekeeper [removing old history]"); */ /* housekeeping_process_log(now); */ /* zbx_setproctitle("housekeeper [removing old events]"); */ /* housekeeping_events(now); */ zbx_setproctitle("housekeeper [removing old alerts]"); housekeeping_alerts(now); zbx_setproctitle("housekeeper [removing old sessions]"); housekeeping_sessions(now); zbx_setproctitle("housekeeper [vacuuming database]"); /* Transaction is not required here. It causes timeouts under MySQL */ /* DBcommit();*/ /* DBvacuum(); */ zabbix_log( LOG_LEVEL_DEBUG, "Sleeping for %d hours", CONFIG_HOUSEKEEPING_FREQUENCY); zbx_setproctitle("housekeeper [sleeping for %d hour(s)]", CONFIG_HOUSEKEEPING_FREQUENCY); DBclose(); zabbix_log( LOG_LEVEL_DEBUG, "Next housekeeper run is after %dh", CONFIG_HOUSEKEEPING_FREQUENCY); sleep(3660*CONFIG_HOUSEKEEPING_FREQUENCY); } }