/****************************************************************************** * * * Function: main_escalator_loop * * * * Purpose: periodically check table escalations and generate alerts * * * * Parameters: * * * * Return value: * * * * Author: Alexander Vladishev * * * * Comments: never returns * * * ******************************************************************************/ void main_escalator_loop() { int now; double sec; zabbix_log(LOG_LEVEL_DEBUG, "In main_escalator_loop()"); zbx_setproctitle("%s [connecting to the database]", get_process_type_string(process_type)); DBconnect(ZBX_DB_CONNECT_NORMAL); for (;;) { zbx_setproctitle("%s [processing escalations]", get_process_type_string(process_type)); now = time(NULL); sec = zbx_time(); process_escalations(now); sec = zbx_time() - sec; zabbix_log(LOG_LEVEL_DEBUG, "%s #%d spent " ZBX_FS_DBL " seconds while processing escalations", get_process_type_string(process_type), process_num, sec); zbx_sleep_loop(CONFIG_ESCALATOR_FREQUENCY); } }
/****************************************************************************** * * * Function: main_escalator_loop * * * * Purpose: periodically check table escalations and generate alerts * * * * Parameters: * * * * Return value: * * * * Author: Aleksander Vladishev * * * * Comments: never returns * * * ******************************************************************************/ int main_escalator_loop() { int now/*, nextcheck, sleeptime*/; double sec; struct sigaction phan; zabbix_log(LOG_LEVEL_DEBUG, "In main_escalator_loop()"); /* phan.sa_handler = child_signal_handler;*/ phan.sa_sigaction = child_signal_handler; sigemptyset(&phan.sa_mask); phan.sa_flags = SA_SIGINFO; sigaction(SIGALRM, &phan, NULL); zbx_setproctitle("escalator [connecting to the database]"); DBconnect(ZBX_DB_CONNECT_NORMAL); for (;;) { now = time(NULL); sec = zbx_time(); zbx_setproctitle("escalator [processing escalations]"); process_escalations(now); sec = zbx_time() - sec; /* nextcheck = get_minnextcheck(); if (FAIL == nextcheck) sleeptime = CONFIG_ESCALATOR_FREQUENCY; else { sleeptime = nextcheck - time(NULL); if (sleeptime < 0) sleeptime = 0; else if (sleeptime > CONFIG_ESCALATOR_FREQUENCY) sleeptime = CONFIG_ESCALATOR_FREQUENCY; }*/ zabbix_log(LOG_LEVEL_DEBUG, "Escalator spent " ZBX_FS_DBL " seconds while processing escalation items." " Nextcheck after %d sec.", sec, CONFIG_ESCALATOR_FREQUENCY); zbx_setproctitle("escalator [sleeping for %d seconds]", CONFIG_ESCALATOR_FREQUENCY); sleep(CONFIG_ESCALATOR_FREQUENCY); /* if (sleeptime > 0) { zbx_setproctitle("escalator [sleeping for %d seconds]", sleeptime); sleep(sleeptime); }*/ } /* Never reached */ DBclose(); }