zabbix-agent2/src/libs/zbxdbcache/dbsync.c
/******************************************************************************
 *                                                                            *
 * Function: dbsync_compare_interface                                         *
 *                                                                            *
 * Purpose: compares interface table row with cached configuration data       *
 *                                                                            *
 * Parameter: interface - [IN] the cached interface data                      *
 *            dbrow     - [IN] the database row                               *
 *                                                                            *
 * Return value: SUCCEED - the row matches configuration data                 *
 *               FAIL    - otherwise                                          *
 *                                                                            *
 * Comments: User macros used in ip, dns fields will always make compare to   *
 *           fail.                                                            *
 *                                                                            *
 ******************************************************************************/
dbsync_compare_interface

Purpose: compares interface table row with cached configuration data

Parameter: interface - [IN] the cached interface data
dbrow     - [IN] the database row

Return value: SUCCEED - the row matches configuration data
FAIL    - otherwise

Comments: User macros used in ip, dns fields will always make compare to
fail.
dbsync_compare_interface Purpose : compares interface table row with cached configuration data Parameter : interface - [ IN ] the cached interface data dbrow - [ IN ] the database row Return value : SUCCEED - the row matches configuration data FAIL - otherwise Comments : User macros used in ip dns fields will always make compare to fail .
static int	dbsync_compare_interface(const ZBX_DC_INTERFACE *interface, const DB_ROW dbrow)
{
	ZBX_DC_SNMPINTERFACE *snmp;
	if (FAIL == dbsync_compare_uint64(dbrow[1], interface->hostid))
		return FAIL;
	if (FAIL == dbsync_compare_uchar(dbrow[2], interface->type))
		return FAIL;
	if (FAIL == dbsync_compare_uchar(dbrow[3], interface->main))
		return FAIL;
	if (FAIL == dbsync_compare_uchar(dbrow[4], interface->useip))
		return FAIL;
	if (NULL != strstr(dbrow[5], "{$"))
		return FAIL;
	if (FAIL == dbsync_compare_str(dbrow[5], interface->ip))
		return FAIL;
	if (NULL != strstr(dbrow[6], "{$"))
		return FAIL;
	if (FAIL == dbsync_compare_str(dbrow[6], interface->dns))
		return FAIL;
	if (FAIL == dbsync_compare_str(dbrow[7], interface->port))
		return FAIL;
	if (FAIL == dbsync_compare_uchar(dbrow[8], interface->available))
		return FAIL;
	if (FAIL == dbsync_compare_int(dbrow[9], interface->disable_until))
		return FAIL;
	if (FAIL == dbsync_compare_str(dbrow[10], interface->error))
		return FAIL;
	if (FAIL == dbsync_compare_int(dbrow[11], interface->errors_from))
		return FAIL;
	snmp = (ZBX_DC_SNMPINTERFACE *)zbx_hashset_search(&dbsync_env.cache->interfaces_snmp,
			&interface->interfaceid);
	if (INTERFACE_TYPE_SNMP == interface->type)
	{
		if (NULL == snmp || SUCCEED == DBis_null(dbrow[12]))	
			return FAIL;
		if (FAIL == dbsync_compare_uchar(dbrow[12], snmp->version))
			return FAIL;
		if (FAIL == dbsync_compare_uchar(dbrow[13], snmp->bulk))
			return FAIL;
		if (FAIL == dbsync_compare_str(dbrow[14], snmp->community))
			return FAIL;
		if (FAIL == dbsync_compare_str(dbrow[15], snmp->securityname))
			return FAIL;
		if (FAIL == dbsync_compare_uchar(dbrow[16], snmp->securitylevel))
			return FAIL;
		if (FAIL == dbsync_compare_str(dbrow[17], snmp->authpassphrase))
			return FAIL;
		if (FAIL == dbsync_compare_str(dbrow[18], snmp->privpassphrase))
			return FAIL;
		if (FAIL == dbsync_compare_uchar(dbrow[19], snmp->authprotocol))
			return FAIL;
		if (FAIL == dbsync_compare_uchar(dbrow[20], snmp->privprotocol))
			return FAIL;
		if (FAIL == dbsync_compare_str(dbrow[21], snmp->contextname))
			return FAIL;
	}
	else if (NULL != snmp)
		return FAIL;
	return SUCCEED;
}
static int dbsync_compare_interface ( const ZBX_DC_INTERFACE * interface , const DB_ROW dbrow ) { ZBX_DC_SNMPINTERFACE * snmp ; if ( FAIL == dbsync_compare_uint64 ( dbrow [ 1 ] , interface -> hostid ) ) return FAIL ; if ( FAIL == dbsync_compare_uchar ( dbrow [ 2 ] , interface -> type ) ) return FAIL ; if ( FAIL == dbsync_compare_uchar ( dbrow [ 3 ] , interface -> main ) ) return FAIL ; if ( FAIL == dbsync_compare_uchar ( dbrow [ 4 ] , interface -> useip ) ) return FAIL ; if ( NULL != strstr ( dbrow [ 5 ] , " " ) ) return FAIL ; if ( FAIL == dbsync_compare_str ( dbrow [ 5 ] , interface -> ip ) ) return FAIL ; if ( NULL != strstr ( dbrow [ 6 ] , " " ) ) return FAIL ; if ( FAIL == dbsync_compare_str ( dbrow [ 6 ] , interface -> dns ) ) return FAIL ; if ( FAIL == dbsync_compare_str ( dbrow [ 7 ] , interface -> port ) ) return FAIL ; if ( FAIL == dbsync_compare_uchar ( dbrow [ 8 ] , interface -> available ) ) return FAIL ; if ( FAIL == dbsync_compare_int ( dbrow [ 9 ] , interface -> disable_until ) ) return FAIL ; if ( FAIL == dbsync_compare_str ( dbrow [ 10 ] , interface -> error ) ) return FAIL ; if ( FAIL == dbsync_compare_int ( dbrow [ 11 ] , interface -> errors_from ) ) return FAIL ; snmp = ( ZBX_DC_SNMPINTERFACE * ) zbx_hashset_search ( & dbsync_env . cache -> interfaces_snmp , & interface -> interfaceid ) ; if ( INTERFACE_TYPE_SNMP == interface -> type ) { if ( NULL == snmp || SUCCEED == DBis_null ( dbrow [ 12 ] ) ) return FAIL ; if ( FAIL == dbsync_compare_uchar ( dbrow [ 12 ] , snmp -> version ) ) return FAIL ; if ( FAIL == dbsync_compare_uchar ( dbrow [ 13 ] , snmp -> bulk ) ) return FAIL ; if ( FAIL == dbsync_compare_str ( dbrow [ 14 ] , snmp -> community ) ) return FAIL ; if ( FAIL == dbsync_compare_str ( dbrow [ 15 ] , snmp -> securityname ) ) return FAIL ; if ( FAIL == dbsync_compare_uchar ( dbrow [ 16 ] , snmp -> securitylevel ) ) return FAIL ; if ( FAIL == dbsync_compare_str ( dbrow [ 17 ] , snmp -> authpassphrase ) ) return FAIL ; if ( FAIL == dbsync_compare_str ( dbrow [ 18 ] , snmp -> privpassphrase ) ) return FAIL ; if ( FAIL == dbsync_compare_uchar ( dbrow [ 19 ] , snmp -> authprotocol ) ) return FAIL ; if ( FAIL == dbsync_compare_uchar ( dbrow [ 20 ] , snmp -> privprotocol ) ) return FAIL ; if ( FAIL == dbsync_compare_str ( dbrow [ 21 ] , snmp -> contextname ) ) return FAIL ; } else if ( NULL != snmp ) return FAIL ; return SUCCEED ; }
Function: dbsync_compare_interface                                         
                                                                            
 Purpose: compares interface table row with cached configuration data       
                                                                            
 Parameter: interface - [IN] the cached interface data                      
            dbrow     - [IN] the database row                               
                                                                            
 Return value: SUCCEED - the row matches configuration data                 
               FAIL    - otherwise                                          
                                                                            
 Comments: User macros used in ip, dns fields will always make compare to   
           fail.
Function : dbsync_compare_interface Purpose : compares interface table row with cached configuration data Parameter : interface - [ IN ] the cached interface data dbrow - [ IN ] the database row Return value : SUCCEED - the row matches configuration data FAIL - otherwise Comments : User macros used in ip dns fields will always make compare to fail .
/* reset_availability, items_num and availability_ts are excluded from the comparison */ /* should never happen */