zabbix-agent2/src/zabbix_server/service/service_manager.c
/******************************************************************************
 *                                                                            *
 * Function: its_itservice_update_status                                      *
 *                                                                            *
 * Purpose: updates service and its parents statuses                          *
 *                                                                            *
 * Parameters: service    - [IN] the service to update                        *
 *             ts         - [IN] the update timestamp                         *
 *             alarms     - [OUT] the alarms update queue                     *
 *                                                                            *
 * Comments: This function recalculates service status according to the       *
 *           algorithm and status of the children services. If the status     *
 *           has been changed, an alarm is generated and parent services      *
 *           (up until the root service) are updated too.                     *
 *                                                                            *
 ******************************************************************************/
its_itservice_update_status

Purpose: updates service and its parents statuses

Parameters: service    - [IN] the service to update
ts         - [IN] the update timestamp
alarms     - [OUT] the alarms update queue

Comments: This function recalculates service status according to the
algorithm and status of the children services. If the status
has been changed, an alarm is generated and parent services
(up until the root service) are updated too.
its_itservice_update_status Purpose : updates service and its parents statuses Parameters : service - [ IN ] the service to update ts - [ IN ] the update timestamp alarms - [ OUT ] the alarms update queue Comments : This function recalculates service status according to the algorithm and status of the children services . If the status has been changed an alarm is generated and parent services ( up until the root service ) are updated too .
static void	its_itservice_update_status(zbx_service_t *itservice, const zbx_timespec_t *ts,
		zbx_vector_ptr_t *alarms, zbx_hashset_t *service_updates, int flags)
{
	int	status, rule_status, i;
	status = service_get_main_status(itservice);
	for (i = 0; i < itservice->status_rules.values_num; i++)
	{
		zbx_service_rule_t	*rule = (zbx_service_rule_t *)itservice->status_rules.values[i];
		if (status < (rule_status = service_get_rule_status(itservice, rule)))
			status = rule_status;
	}
	if (itservice->status != status)
	{
		zbx_service_update_t	*update;
		update = update_service(service_updates, itservice, status, ts);
		update->alarm = its_updates_append(alarms, itservice->serviceid, status, ts->sec);
		for (i = 0; i < itservice->parents.values_num; i++)
		{
			its_itservice_update_status((zbx_service_t *)itservice->parents.values[i], ts, alarms,
					service_updates, flags);
		}
	}
	else if (0 != (ZBX_FLAG_SERVICE_RECALCULATE & flags))
	{
		for (i = 0; i < itservice->parents.values_num; i++)
		{
			its_itservice_update_status((zbx_service_t *)itservice->parents.values[i], ts, alarms,
					service_updates, flags);
		}
	}
}
static void its_itservice_update_status ( zbx_service_t * itservice , const zbx_timespec_t * ts , zbx_vector_ptr_t * alarms , zbx_hashset_t * service_updates , int flags ) { int status , rule_status , i ; status = service_get_main_status ( itservice ) ; for ( i = 0 ; i < itservice -> status_rules . values_num ; i ++ ) { zbx_service_rule_t * rule = ( zbx_service_rule_t * ) itservice -> status_rules . values [ i ] ; if ( status < ( rule_status = service_get_rule_status ( itservice , rule ) ) ) status = rule_status ; } if ( itservice -> status != status ) { zbx_service_update_t * update ; update = update_service ( service_updates , itservice , status , ts ) ; update -> alarm = its_updates_append ( alarms , itservice -> serviceid , status , ts -> sec ) ; for ( i = 0 ; i < itservice -> parents . values_num ; i ++ ) { its_itservice_update_status ( ( zbx_service_t * ) itservice -> parents . values [ i ] , ts , alarms , service_updates , flags ) ; } } else if ( 0 != ( ZBX_FLAG_SERVICE_RECALCULATE & flags ) ) { for ( i = 0 ; i < itservice -> parents . values_num ; i ++ ) { its_itservice_update_status ( ( zbx_service_t * ) itservice -> parents . values [ i ] , ts , alarms , service_updates , flags ) ; } } }
Function: its_itservice_update_status                                      
                                                                            
 Purpose: updates service and its parents statuses                          
                                                                            
 Parameters: service    - [IN] the service to update                        
             ts         - [IN] the update timestamp                         
             alarms     - [OUT] the alarms update queue                     
                                                                            
 Comments: This function recalculates service status according to the       
           algorithm and status of the children services.
Function : its_itservice_update_status Purpose : updates service and its parents statuses Parameters : service - [ IN ] the service to update ts - [ IN ] the update timestamp alarms - [ OUT ] the alarms update queue Comments : This function recalculates service status according to the algorithm and status of the children services .
/* update parent services */ /* update parent services */