zabbix-agent2/src/zabbix_server/actions.c
/******************************************************************************
 *                                                                            *
 * Function: check_areg_proxy_condition                                       *
 *                                                                            *
 * Purpose: check proxy condition for auto registration                       *
 *                                                                            *
 * Parameters: esc_events - [IN] events to check                              *
 *             condition  - [IN/OUT] condition for matching, outputs          *
 *                                   event ids that match condition           *
 *                                                                            *
 * Return value: SUCCEED - supported operator                                 *
 *               NOTSUPPORTED - not supported operator                        *
 *                                                                            *
 ******************************************************************************/
check_areg_proxy_condition

Purpose: check proxy condition for auto registration

Parameters: esc_events - [IN] events to check
condition  - [IN/OUT] condition for matching, outputs
event ids that match condition

Return value: SUCCEED - supported operator
NOTSUPPORTED - not supported operator
check_areg_proxy_condition Purpose : check proxy condition for auto registration Parameters : esc_events - [ IN ] events to check condition - [ IN / OUT ] condition for matching outputs event ids that match condition Return value : SUCCEED - supported operator NOTSUPPORTED - not supported operator
static int	check_areg_proxy_condition(const zbx_vector_ptr_t *esc_events, zbx_condition_t *condition)
{
	char			*sql = NULL;
	size_t			sql_alloc = 0, sql_offset = 0;
	DB_RESULT		result;
	DB_ROW			row;
	int			object = EVENT_OBJECT_ZABBIX_ACTIVE;
	zbx_vector_uint64_t	objectids;
	zbx_uint64_t		condition_value;
	ZBX_STR2UINT64(condition_value, condition->value);
	if (CONDITION_OPERATOR_EQUAL != condition->op && CONDITION_OPERATOR_NOT_EQUAL != condition->op)
		return NOTSUPPORTED;
	zbx_vector_uint64_create(&objectids);
	get_object_ids(esc_events, &objectids);
	zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset,
			"select autoreg_hostid,proxy_hostid"
			" from autoreg_host"
			" where");
	DBadd_condition_alloc(&sql, &sql_alloc, &sql_offset, "autoreg_hostid",
			objectids.values, objectids.values_num);
	result = DBselect("%s", sql);
	while (NULL != (row = DBfetch(result)))
	{
		zbx_uint64_t	id;
		zbx_uint64_t	objectid;
		ZBX_STR2UINT64(objectid, row[0]);
		ZBX_DBROW2UINT64(id, row[1]);
		switch (condition->op)
		{
			case CONDITION_OPERATOR_EQUAL:
				if (id == condition_value)
					add_condition_match(esc_events, condition, objectid, object);
				break;
			case CONDITION_OPERATOR_NOT_EQUAL:
				if (id != condition_value)
					add_condition_match(esc_events, condition, objectid, object);
				break;
		}
	}
	DBfree_result(result);
	zbx_vector_uint64_destroy(&objectids);
	zbx_free(sql);
	return SUCCEED;
}
static int check_areg_proxy_condition ( const zbx_vector_ptr_t * esc_events , zbx_condition_t * condition ) { char * sql = NULL ; size_t sql_alloc = 0 , sql_offset = 0 ; DB_RESULT result ; DB_ROW row ; int object = EVENT_OBJECT_ZABBIX_ACTIVE ; zbx_vector_uint64_t objectids ; zbx_uint64_t condition_value ; ZBX_STR2UINT64 ( condition_value , condition -> value ) ; if ( CONDITION_OPERATOR_EQUAL != condition -> op && CONDITION_OPERATOR_NOT_EQUAL != condition -> op ) return NOTSUPPORTED ; zbx_vector_uint64_create ( & objectids ) ; get_object_ids ( esc_events , & objectids ) ; zbx_snprintf_alloc ( & sql , & sql_alloc , & sql_offset , " " " " " " ) ; DBadd_condition_alloc ( & sql , & sql_alloc , & sql_offset , " " , objectids . values , objectids . values_num ) ; result = DBselect ( " " , sql ) ; while ( NULL != ( row = DBfetch ( result ) ) ) { zbx_uint64_t id ; zbx_uint64_t objectid ; ZBX_STR2UINT64 ( objectid , row [ 0 ] ) ; ZBX_DBROW2UINT64 ( id , row [ 1 ] ) ; switch ( condition -> op ) { case CONDITION_OPERATOR_EQUAL : if ( id == condition_value ) add_condition_match ( esc_events , condition , objectid , object ) ; break ; case CONDITION_OPERATOR_NOT_EQUAL : if ( id != condition_value ) add_condition_match ( esc_events , condition , objectid , object ) ; break ; } } DBfree_result ( result ) ; zbx_vector_uint64_destroy ( & objectids ) ; zbx_free ( sql ) ; return SUCCEED ; }
Function: check_areg_proxy_condition                                       
                                                                            
 Purpose: check proxy condition for auto registration                       
                                                                            
 Parameters: esc_events - [IN] events to check                              
             condition  - [IN/OUT] condition for matching, outputs          
                                   event ids that match condition           
                                                                            
 Return value: SUCCEED - supported operator                                 
               NOTSUPPORTED - not supported operator
Function : check_areg_proxy_condition Purpose : check proxy condition for auto registration Parameters : esc_events - [ IN ] events to check condition - [ IN / OUT ] condition for matching outputs event ids that match condition Return value : SUCCEED - supported operator NOTSUPPORTED - not supported operator