示例#1
0
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);
	}
}
示例#2
0
void	main_housekeeper_loop(void)
{
    int	now, d_history_and_trends, d_cleanup, d_events, d_sessions, d_services, d_audit;
    double	sec;

    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);

        DCconfig_get_config_hk(&hk_config);

        zbx_setproctitle("%s [removing old history and trends]", get_process_type_string(process_type));
        sec = zbx_time();
        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 sessions]", get_process_type_string(process_type));
        d_sessions = housekeeping_sessions(now);

        zbx_setproctitle("%s [removing old service alarms]", get_process_type_string(process_type));
        d_services = housekeeping_services(now);

        zbx_setproctitle("%s [removing old audit log items]", get_process_type_string(process_type));
        d_audit = housekeeping_audit(now);

        sec = zbx_time() - sec;

        zabbix_log(LOG_LEVEL_WARNING, "%s [deleted %d hist/trends, %d items, %d events, %d sessions, %d alarms,"
                   " %d audit items in " ZBX_FS_DBL " sec, idle %d hour(s)]",
                   get_process_type_string(process_type), d_history_and_trends, d_cleanup, d_events,
                   d_sessions, d_services, d_audit, sec, CONFIG_HOUSEKEEPING_FREQUENCY);
        DBclose();

        zbx_setproctitle("%s [deleted %d hist/trends, %d items, %d events, %d sessions, %d alarms, %d audit "
                         "items in " ZBX_FS_DBL " sec, idle %d hour(s)]",
                         get_process_type_string(process_type), d_history_and_trends, d_cleanup, d_events,
                         d_sessions, d_services, d_audit, sec, CONFIG_HOUSEKEEPING_FREQUENCY);

        zbx_sleep_loop(CONFIG_HOUSEKEEPING_FREQUENCY * SEC_PER_HOUR);
    }
}
示例#3
0
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);
	}
}