zabbix-agent2/src/libs/zbxdbcache/dbconfig.c
/******************************************************************************
 *                                                                            *
 * Function: dc_trigger_items_hosts_enabled                                   *
 *                                                                            *
 * Purpose: check that functionids in trigger (recovery) expression           *
 *                                                                            *
 * Parameters: expression - [IN] trigger (recovery) expression                *
 *             data       - [IN] parsed and serialized expression             *
 *                                                                            *
 * Return value: SUCCEED - all functionids correspond to enabled items and    *
 *                           enabled hosts                                    *
 *               FAIL    - at least one item or host is disabled              *
 *                                                                            *
 ******************************************************************************/
dc_trigger_items_hosts_enabled

Purpose: check that functionids in trigger (recovery) expression

Parameters: expression - [IN] trigger (recovery) expression
data       - [IN] parsed and serialized expression

Return value: SUCCEED - all functionids correspond to enabled items and
enabled hosts
FAIL    - at least one item or host is disabled
dc_trigger_items_hosts_enabled Purpose : check that functionids in trigger ( recovery ) expression Parameters : expression - [ IN ] trigger ( recovery ) expression data - [ IN ] parsed and serialized expression Return value : SUCCEED - all functionids correspond to enabled items and enabled hosts FAIL - at least one item or host is disabled
static int	dc_trigger_items_hosts_enabled(const char *expression, const unsigned char *data)
{
	zbx_uint64_t		functionid;
	const ZBX_DC_ITEM	*dc_item;
	const ZBX_DC_FUNCTION	*dc_function;
	const ZBX_DC_HOST	*dc_host;
	int			i, ret = FAIL;
	zbx_vector_uint64_t	functionids;
	zbx_vector_uint64_create(&functionids);
	zbx_get_serialized_expression_functionids(expression, data, &functionids);
	for (i = 0; i < functionids.values_num; i++)
	{
		functionid = functionids.values[i];
		if (NULL == (dc_function = (ZBX_DC_FUNCTION *)zbx_hashset_search(&config->functions, &functionid)))
			goto out;
		if (NULL == (dc_item = (ZBX_DC_ITEM *)zbx_hashset_search(&config->items, &dc_function->itemid)))
			goto out;
		if (ITEM_STATUS_ACTIVE != dc_item->status)
			goto out;
		if (NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_search(&config->hosts, &dc_item->hostid)))
			goto out;
		if (HOST_STATUS_MONITORED != dc_host->status)
			goto out;
	}
	ret = SUCCEED;
out:
	zbx_vector_uint64_destroy(&functionids);
	return ret;
}
static int dc_trigger_items_hosts_enabled ( const char * expression , const unsigned char * data ) { zbx_uint64_t functionid ; const ZBX_DC_ITEM * dc_item ; const ZBX_DC_FUNCTION * dc_function ; const ZBX_DC_HOST * dc_host ; int i , ret = FAIL ; zbx_vector_uint64_t functionids ; zbx_vector_uint64_create ( & functionids ) ; zbx_get_serialized_expression_functionids ( expression , data , & functionids ) ; for ( i = 0 ; i < functionids . values_num ; i ++ ) { functionid = functionids . values [ i ] ; if ( NULL == ( dc_function = ( ZBX_DC_FUNCTION * ) zbx_hashset_search ( & config -> functions , & functionid ) ) ) goto out ; if ( NULL == ( dc_item = ( ZBX_DC_ITEM * ) zbx_hashset_search ( & config -> items , & dc_function -> itemid ) ) ) goto out ; if ( ITEM_STATUS_ACTIVE != dc_item -> status ) goto out ; if ( NULL == ( dc_host = ( ZBX_DC_HOST * ) zbx_hashset_search ( & config -> hosts , & dc_item -> hostid ) ) ) goto out ; if ( HOST_STATUS_MONITORED != dc_host -> status ) goto out ; } ret = SUCCEED ; out : zbx_vector_uint64_destroy ( & functionids ) ; return ret ; }
Function: dc_trigger_items_hosts_enabled                                   
                                                                            
 Purpose: check that functionids in trigger (recovery) expression           
                                                                            
 Parameters: expression - [IN] trigger (recovery) expression                
             data       - [IN] parsed and serialized expression             
                                                                            
 Return value: SUCCEED - all functionids correspond to enabled items and    
                           enabled hosts                                    
               FAIL    - at least one item or host is disabled
Function : dc_trigger_items_hosts_enabled Purpose : check that functionids in trigger ( recovery ) expression Parameters : expression - [ IN ] trigger ( recovery ) expression data - [ IN ] parsed and serialized expression Return value : SUCCEED - all functionids correspond to enabled items and enabled hosts FAIL - at least one item or host is disabled