/****************************************************************************** * * * Function: process_time_functions * * * * Purpose: re-calculate and update values of time-driven functions * * * * Author: Alexei Vladishev, Aleksandrs Saveljevs * * * ******************************************************************************/ static void process_time_functions(int *triggers_count, int *events_count) { const char *__function_name = "process_time_functions"; DC_TRIGGER *trigger_info = NULL; zbx_vector_ptr_t trigger_order; zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name); zbx_vector_ptr_create(&trigger_order); DCconfig_get_time_based_triggers(&trigger_info, &trigger_order, process_num, triggers_count); if (0 == trigger_order.values_num) goto clean; evaluate_expressions(&trigger_order); DBbegin(); process_triggers(&trigger_order); DCfree_triggers(&trigger_order); *events_count = process_events(); DBcommit(); clean: zbx_free(trigger_info); zbx_vector_ptr_destroy(&trigger_order); zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name); }
/****************************************************************************** * * * Function: DCflush_nextchecks * * * * Purpose: update triggers to UNKNOWN and generate events * * * ******************************************************************************/ void DCflush_nextchecks(zbx_vector_ptr_t *trigger_diff) { const char *__function_name = "DCflush_nextchecks"; int i; zbx_uint64_t *itemids = NULL; zbx_timespec_t *timespecs = NULL; char **errors = NULL; zbx_hashset_t trigger_info; zbx_vector_ptr_t trigger_order; DC_TRIGGER *trigger; zabbix_log(LOG_LEVEL_DEBUG, "In %s() nextcheck_num:%d", __function_name, nextcheck_num); if (0 == nextcheck_num) goto exit; itemids = zbx_malloc(itemids, nextcheck_num * sizeof(zbx_uint64_t)); timespecs = zbx_malloc(timespecs, nextcheck_num * sizeof(zbx_timespec_t)); errors = zbx_malloc(errors, nextcheck_num * sizeof(char *)); for (i = 0; i < nextcheck_num; i++) { itemids[i] = nextchecks[i].itemid; timespecs[i] = nextchecks[i].ts; errors[i] = nextchecks[i].error_msg; } zbx_hashset_create(&trigger_info, MAX(100, 2 * nextcheck_num), ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC); zbx_vector_ptr_create(&trigger_order); zbx_vector_ptr_reserve(&trigger_order, nextcheck_num); DCconfig_get_triggers_by_itemids(&trigger_info, &trigger_order, itemids, timespecs, errors, nextcheck_num, 0); zbx_free(errors); zbx_free(timespecs); zbx_free(itemids); for (i = 0; i < trigger_order.values_num; i++) { trigger = (DC_TRIGGER *)trigger_order.values[i]; trigger->new_value = TRIGGER_VALUE_UNKNOWN; } zbx_process_triggers(&trigger_order, trigger_diff); DCfree_triggers(&trigger_order); zbx_hashset_destroy(&trigger_info); zbx_vector_ptr_destroy(&trigger_order); DCclean_nextchecks(); exit: zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name); }