zabbix-agent2/src/zabbix_server/service/service_manager.c
/******************************************************************************
 *                                                                            *
 * Function: service_get_status                                               *
 *                                                                            *
 * Purpose: get service status when calculating parent service status         *
 *                                                                            *
 * Parameters: service - [IN] the service                                     *
 *             status  - [OUT] the service status                             *
 *                                                                            *
 * Return value: SUCCEED - the status is returned                             *
 *               FAIL    - the service must be ignored                        *
 *                                                                            *
 ******************************************************************************/
service_get_status

Purpose: get service status when calculating parent service status

Parameters: service - [IN] the service
status  - [OUT] the service status

Return value: SUCCEED - the status is returned
FAIL    - the service must be ignored
service_get_status Purpose : get service status when calculating parent service status Parameters : service - [ IN ] the service status - [ OUT ] the service status Return value : SUCCEED - the status is returned FAIL - the service must be ignored
int	service_get_status(const zbx_service_t	*service, int *status)
{
	if (ZBX_SERVICE_STATUS_PROPAGATION_IGNORE == service->propagation_rule)
		return FAIL;
	if (ZBX_SERVICE_STATUS_OK == service->status)
	{
		*status = ZBX_SERVICE_STATUS_OK;
		return SUCCEED;
	}
	switch (service->propagation_rule)
	{
		case ZBX_SERVICE_STATUS_PROPAGATION_AS_IS:
			*status = service->status;
			break;
		case ZBX_SERVICE_STATUS_PROPAGATION_INCREASE:
			*status = service->status + service->propagation_value;
			if (TRIGGER_SEVERITY_COUNT <= *status)
				*status = TRIGGER_SEVERITY_COUNT - 1;
			break;
		case ZBX_SERVICE_STATUS_PROPAGATION_DECREASE:
			*status = service->status - service->propagation_value;
			if (ZBX_SERVICE_STATUS_OK >= *status)
				*status = ZBX_SERVICE_STATUS_OK + 1;
			break;
		case ZBX_SERVICE_STATUS_PROPAGATION_FIXED:
			*status = service->propagation_value;
			break;
		default:
			THIS_SHOULD_NEVER_HAPPEN;
			*status = ZBX_SERVICE_STATUS_OK;
			break;
	}
	return SUCCEED;
}
int service_get_status ( const zbx_service_t * service , int * status ) { if ( ZBX_SERVICE_STATUS_PROPAGATION_IGNORE == service -> propagation_rule ) return FAIL ; if ( ZBX_SERVICE_STATUS_OK == service -> status ) { * status = ZBX_SERVICE_STATUS_OK ; return SUCCEED ; } switch ( service -> propagation_rule ) { case ZBX_SERVICE_STATUS_PROPAGATION_AS_IS : * status = service -> status ; break ; case ZBX_SERVICE_STATUS_PROPAGATION_INCREASE : * status = service -> status + service -> propagation_value ; if ( TRIGGER_SEVERITY_COUNT <= * status ) * status = TRIGGER_SEVERITY_COUNT - 1 ; break ; case ZBX_SERVICE_STATUS_PROPAGATION_DECREASE : * status = service -> status - service -> propagation_value ; if ( ZBX_SERVICE_STATUS_OK >= * status ) * status = ZBX_SERVICE_STATUS_OK + 1 ; break ; case ZBX_SERVICE_STATUS_PROPAGATION_FIXED : * status = service -> propagation_value ; break ; default : THIS_SHOULD_NEVER_HAPPEN ; * status = ZBX_SERVICE_STATUS_OK ; break ; } return SUCCEED ; }
Function: service_get_status                                               
                                                                            
 Purpose: get service status when calculating parent service status         
                                                                            
 Parameters: service - [IN] the service                                     
             status  - [OUT] the service status                             
                                                                            
 Return value: SUCCEED - the status is returned                             
               FAIL    - the service must be ignored
Function : service_get_status Purpose : get service status when calculating parent service status Parameters : service - [ IN ] the service status - [ OUT ] the service status Return value : SUCCEED - the status is returned FAIL - the service must be ignored