zabbix-agent2/src/libs/zbxdbcache/dbconfig.c
/******************************************************************************
 *                                                                            *
 * Function: zbx_dc_get_trigger_dependencies                                  *
 *                                                                            *
 * Purpose: checks/returns trigger dependencies for a set of triggers         *
 *                                                                            *
 * Parameter: triggerids  - [IN] the currently processing trigger ids         *
 *            deps        - [OUT] list of dependency check results for failed *
 *                                or unresolved dependencies                  *
 *                                                                            *
 * Comments: This function returns list of zbx_trigger_dep_t structures       *
 *           for failed or unresolved dependency checks.                      *
 *           Dependency check is failed if any of the master triggers that    *
 *           are not being processed in this batch (present in triggerids     *
 *           vector) has a problem value.                                     *
 *           Dependency check is unresolved if a master trigger is being      *
 *           processed in this batch (present in triggerids vector) and no    *
 *           other master triggers have problem value.                        *
 *           Dependency check is successful if all master triggers (if any)   *
 *           have OK value and are not being processed in this batch.         *
 *                                                                            *
 ******************************************************************************/
zbx_dc_get_trigger_dependencies

Purpose: checks/returns trigger dependencies for a set of triggers

Parameter: triggerids  - [IN] the currently processing trigger ids
deps        - [OUT] list of dependency check results for failed
or unresolved dependencies

Comments: This function returns list of zbx_trigger_dep_t structures
for failed or unresolved dependency checks.
Dependency check is failed if any of the master triggers that
are not being processed in this batch (present in triggerids
vector) has a problem value.
Dependency check is unresolved if a master trigger is being
processed in this batch (present in triggerids vector) and no
other master triggers have problem value.
Dependency check is successful if all master triggers (if any)
have OK value and are not being processed in this batch.
zbx_dc_get_trigger_dependencies Purpose : checks / returns trigger dependencies for a set of triggers Parameter : triggerids - [ IN ] the currently processing trigger ids deps - [ OUT ] list of dependency check results for failed or unresolved dependencies Comments : This function returns list of zbx_trigger_dep_t structures for failed or unresolved dependency checks . Dependency check is failed if any of the master triggers that are not being processed in this batch ( present in triggerids vector ) has a problem value . Dependency check is unresolved if a master trigger is being processed in this batch ( present in triggerids vector ) and no other master triggers have problem value . Dependency check is successful if all master triggers ( if any ) have OK value and are not being processed in this batch .
void	zbx_dc_get_trigger_dependencies(const zbx_vector_uint64_t *triggerids, zbx_vector_ptr_t *deps)
{
	int				i, ret;
	const ZBX_DC_TRIGGER_DEPLIST	*trigdep;
	zbx_vector_uint64_t		masterids;
	zbx_trigger_dep_t		*dep;
	zbx_vector_uint64_create(&masterids);
	zbx_vector_uint64_reserve(&masterids, 64);
	RDLOCK_CACHE;
	for (i = 0; i < triggerids->values_num; i++)
	{
		if (NULL == (trigdep = (ZBX_DC_TRIGGER_DEPLIST *)zbx_hashset_search(&config->trigdeps, &triggerids->values[i])))
			continue;
		if (FAIL == (ret = DCconfig_check_trigger_dependencies_rec(trigdep, 0, triggerids, &masterids)) ||
				0 != masterids.values_num)
		{
			dep = (zbx_trigger_dep_t *)zbx_malloc(NULL, sizeof(zbx_trigger_dep_t));
			dep->triggerid = triggerids->values[i];
			zbx_vector_uint64_create(&dep->masterids);
			if (SUCCEED == ret)
			{
				dep->status = ZBX_TRIGGER_DEPENDENCY_UNRESOLVED;
				zbx_vector_uint64_append_array(&dep->masterids, masterids.values, masterids.values_num);
			}
			else
				dep->status = ZBX_TRIGGER_DEPENDENCY_FAIL;
			zbx_vector_ptr_append(deps, dep);
		}
		zbx_vector_uint64_clear(&masterids);
	}
	UNLOCK_CACHE;
	zbx_vector_uint64_destroy(&masterids);
}
void zbx_dc_get_trigger_dependencies ( const zbx_vector_uint64_t * triggerids , zbx_vector_ptr_t * deps ) { int i , ret ; const ZBX_DC_TRIGGER_DEPLIST * trigdep ; zbx_vector_uint64_t masterids ; zbx_trigger_dep_t * dep ; zbx_vector_uint64_create ( & masterids ) ; zbx_vector_uint64_reserve ( & masterids , 64 ) ; RDLOCK_CACHE ; for ( i = 0 ; i < triggerids -> values_num ; i ++ ) { if ( NULL == ( trigdep = ( ZBX_DC_TRIGGER_DEPLIST * ) zbx_hashset_search ( & config -> trigdeps , & triggerids -> values [ i ] ) ) ) continue ; if ( FAIL == ( ret = DCconfig_check_trigger_dependencies_rec ( trigdep , 0 , triggerids , & masterids ) ) || 0 != masterids . values_num ) { dep = ( zbx_trigger_dep_t * ) zbx_malloc ( NULL , sizeof ( zbx_trigger_dep_t ) ) ; dep -> triggerid = triggerids -> values [ i ] ; zbx_vector_uint64_create ( & dep -> masterids ) ; if ( SUCCEED == ret ) { dep -> status = ZBX_TRIGGER_DEPENDENCY_UNRESOLVED ; zbx_vector_uint64_append_array ( & dep -> masterids , masterids . values , masterids . values_num ) ; } else dep -> status = ZBX_TRIGGER_DEPENDENCY_FAIL ; zbx_vector_ptr_append ( deps , dep ) ; } zbx_vector_uint64_clear ( & masterids ) ; } UNLOCK_CACHE ; zbx_vector_uint64_destroy ( & masterids ) ; }
Function: zbx_dc_get_trigger_dependencies                                  
                                                                            
 Purpose: checks/returns trigger dependencies for a set of triggers         
                                                                            
 Parameter: triggerids  - [IN] the currently processing trigger ids         
            deps        - [OUT] list of dependency check results for failed 
                                or unresolved dependencies                  
                                                                            
 Comments: This function returns list of zbx_trigger_dep_t structures       
           for failed or unresolved dependency checks.
Function : zbx_dc_get_trigger_dependencies Purpose : checks / returns trigger dependencies for a set of triggers Parameter : triggerids - [ IN ] the currently processing trigger ids deps - [ OUT ] list of dependency check results for failed or unresolved dependencies Comments : This function returns list of zbx_trigger_dep_t structures for failed or unresolved dependency checks .