zabbix-agent2/src/libs/zbxdbhigh/template_item.c
/******************************************************************************
 *                                                                            *
 * Function: calculate_template_lld_rule_conditionids                         *
 *                                                                            *
 * Purpose: calculate identifiers for new item conditions                     *
 *                                                                            *
 * Parameters: rules - [IN] the lld rule mapping                              *
 *                                                                            *
 * Return value: The number of new item conditions to be inserted.            *
 *                                                                            *
 ******************************************************************************/
calculate_template_lld_rule_conditionids

Purpose: calculate identifiers for new item conditions

Parameters: rules - [IN] the lld rule mapping

Return value: The number of new item conditions to be inserted.
calculate_template_lld_rule_conditionids Purpose : calculate identifiers for new item conditions Parameters : rules - [ IN ] the lld rule mapping Return value : The number of new item conditions to be inserted .
static int	calculate_template_lld_rule_conditionids(zbx_vector_ptr_t *rules)
{
	zbx_lld_rule_map_t	*rule;
	int			i, conditions_num = 0;
	zbx_uint64_t		conditionid;
	for (i = 0; i < rules->values_num; i++)
	{
		rule = (zbx_lld_rule_map_t *)rules->values[i];
		if (rule->conditions.values_num > rule->conditionids.values_num)
			conditions_num += rule->conditions.values_num - rule->conditionids.values_num;
	}
	if (0 == conditions_num)
		goto out;
	conditionid = DBget_maxid_num("item_condition", conditions_num);
	for (i = 0; i < rules->values_num; i++)
	{
		rule = (zbx_lld_rule_map_t *)rules->values[i];
		if (rule->conditions.values_num <= rule->conditionids.values_num)
			continue;
		rule->conditionid = conditionid;
		conditionid += rule->conditions.values_num - rule->conditionids.values_num;
	}
out:
	return conditions_num;
}
static int calculate_template_lld_rule_conditionids ( zbx_vector_ptr_t * rules ) { zbx_lld_rule_map_t * rule ; int i , conditions_num = 0 ; zbx_uint64_t conditionid ; for ( i = 0 ; i < rules -> values_num ; i ++ ) { rule = ( zbx_lld_rule_map_t * ) rules -> values [ i ] ; if ( rule -> conditions . values_num > rule -> conditionids . values_num ) conditions_num += rule -> conditions . values_num - rule -> conditionids . values_num ; } if ( 0 == conditions_num ) goto out ; conditionid = DBget_maxid_num ( " " , conditions_num ) ; for ( i = 0 ; i < rules -> values_num ; i ++ ) { rule = ( zbx_lld_rule_map_t * ) rules -> values [ i ] ; if ( rule -> conditions . values_num <= rule -> conditionids . values_num ) continue ; rule -> conditionid = conditionid ; conditionid += rule -> conditions . values_num - rule -> conditionids . values_num ; } out : return conditions_num ; }
Function: calculate_template_lld_rule_conditionids                         
                                                                            
 Purpose: calculate identifiers for new item conditions                     
                                                                            
 Parameters: rules - [IN] the lld rule mapping                              
                                                                            
 Return value: The number of new item conditions to be inserted.
Function : calculate_template_lld_rule_conditionids Purpose : calculate identifiers for new item conditions Parameters : rules - [ IN ] the lld rule mapping Return value : The number of new item conditions to be inserted .
/* calculate the number of new conditions to be inserted */ /* reserve ids for the new conditions to be inserted and assign to lld rules */