/****************************************************************************** * * * Function: main_pinger_loop * * * * Purpose: periodically perform ICMP pings * * * * Parameters: * * * * Return value: * * * * Author: Alexei Vladishev * * * * Comments: never returns * * * ******************************************************************************/ void main_pinger_loop(void) { int nextcheck, sleeptime; double sec; static icmpitem_t *items = NULL; static int items_alloc = 4; int items_count = 0, itc; if (NULL == items) items = zbx_malloc(items, sizeof(icmpitem_t) * items_alloc); for (;;) { zbx_setproctitle("%s #%d [getting values]", get_process_type_string(process_type), process_num); sec = zbx_time(); get_pinger_hosts(&items, &items_alloc, &items_count); process_pinger_hosts(items, items_count); sec = zbx_time() - sec; itc = items_count; free_hosts(&items, &items_count); nextcheck = DCconfig_get_poller_nextcheck(ZBX_POLLER_TYPE_PINGER); sleeptime = calculate_sleeptime(nextcheck, POLLER_DELAY); zbx_setproctitle("%s #%d [got %d values in " ZBX_FS_DBL " sec, idle %d sec]", get_process_type_string(process_type), process_num, itc, sec, sleeptime); zbx_sleep_loop(sleeptime); } }
/****************************************************************************** * * * Function: main_pinger_loop * * * * Purpose: periodically perform ICMP pings * * * * Parameters: * * * * Return value: * * * * Author: Alexei Vladishev * * * * Comments: never returns * * * ******************************************************************************/ ZBX_THREAD_ENTRY(pinger_thread, args) { int nextcheck, sleeptime, items_count = 0, itc; double sec; static icmpitem_t *items = NULL; static int items_alloc = 4; process_type = ((zbx_thread_args_t *)args)->process_type; server_num = ((zbx_thread_args_t *)args)->server_num; process_num = ((zbx_thread_args_t *)args)->process_num; zabbix_log(LOG_LEVEL_INFORMATION, "%s #%d started [%s #%d]", get_daemon_type_string(daemon_type), server_num, get_process_type_string(process_type), process_num); if (NULL == items) items = zbx_malloc(items, sizeof(icmpitem_t) * items_alloc); for (;;) { zbx_setproctitle("%s #%d [getting values]", get_process_type_string(process_type), process_num); sec = zbx_time(); get_pinger_hosts(&items, &items_alloc, &items_count); process_pinger_hosts(items, items_count); sec = zbx_time() - sec; itc = items_count; free_hosts(&items, &items_count); nextcheck = DCconfig_get_poller_nextcheck(ZBX_POLLER_TYPE_PINGER); sleeptime = calculate_sleeptime(nextcheck, POLLER_DELAY); zbx_setproctitle("%s #%d [got %d values in " ZBX_FS_DBL " sec, idle %d sec]", get_process_type_string(process_type), process_num, itc, sec, sleeptime); zbx_sleep_loop(sleeptime); } }
/****************************************************************************** * * * Function: main_pinger_loop * * * * Purpose: periodically perform ICMP pings * * * * Parameters: * * * * Return value: * * * * Author: Alexei Vladishev * * * * Comments: never returns * * * ******************************************************************************/ void main_pinger_loop() { int nextcheck, sleeptime; double sec; static icmpitem_t *items = NULL; static int items_alloc = 4; int items_count = 0; zabbix_log(LOG_LEVEL_DEBUG, "In main_pinger_loop() process_num:%d", process_num); if (NULL == items) items = zbx_malloc(items, sizeof(icmpitem_t) * items_alloc); zbx_setproctitle("%s [connecting to the database]", get_process_type_string(process_type)); DBconnect(ZBX_DB_CONNECT_NORMAL); for (;;) { zbx_setproctitle("%s [getting values]", get_process_type_string(process_type)); sec = zbx_time(); get_pinger_hosts(&items, &items_alloc, &items_count); process_pinger_hosts(items, items_count); sec = zbx_time() - sec; zabbix_log(LOG_LEVEL_DEBUG, "%s #%d spent " ZBX_FS_DBL " seconds while processing %d items", get_process_type_string(process_type), process_num, sec, items_count); free_hosts(&items, &items_count); nextcheck = DCconfig_get_poller_nextcheck(ZBX_POLLER_TYPE_PINGER); sleeptime = calculate_sleeptime(nextcheck, POLLER_DELAY); zbx_sleep_loop(sleeptime); } }