zabbix-agent2/src/libs/zbxdbcache/dbconfig.c
/*******************************************************************************
 *                                                                             *
 * Function: DCget_interfaces_availability                                     *
 *                                                                             *
 * Purpose: gets availability data for interfaces with availability data       *
 *          changed in period from last availability update to the specified   *
 *          timestamp                                                          *
 *                                                                             *
 * Parameters: interfaces - [OUT] changed interfaces availability data         *
 *             ts    - [OUT] the availability diff timestamp                   *
 *                                                                             *
 * Return value: SUCCEED - availability was changed for at least one interface *
 *               FAIL    - no interface availability was changed               *
 *                                                                             *
 *******************************************************************************/
DCget_interfaces_availability

Purpose: gets availability data for interfaces with availability data
changed in period from last availability update to the specified
timestamp

Parameters: interfaces - [OUT] changed interfaces availability data
ts    - [OUT] the availability diff timestamp

Return value: SUCCEED - availability was changed for at least one interface
FAIL    - no interface availability was changed
DCget_interfaces_availability Purpose : gets availability data for interfaces with availability data changed in period from last availability update to the specified timestamp Parameters : interfaces - [ OUT ] changed interfaces availability data ts - [ OUT ] the availability diff timestamp Return value : SUCCEED - availability was changed for at least one interface FAIL - no interface availability was changed
int	DCget_interfaces_availability(zbx_vector_ptr_t *interfaces, int *ts)
{
	const ZBX_DC_INTERFACE		*interface;
	zbx_hashset_iter_t		iter;
	zbx_interface_availability_t	*ia = NULL;
	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
	RDLOCK_CACHE;
	*ts = time(NULL);
	zbx_hashset_iter_reset(&config->interfaces, &iter);
	while (NULL != (interface = (const ZBX_DC_INTERFACE *)zbx_hashset_iter_next(&iter)))
	{
		if (config->availability_diff_ts <= interface->availability_ts && interface->availability_ts < *ts)
		{
			ia = (zbx_interface_availability_t *)zbx_malloc(NULL, sizeof(zbx_interface_availability_t));
			zbx_interface_availability_init(ia, interface->interfaceid);
			zbx_agent_availability_init(&ia->agent, interface->available, interface->error,
					interface->errors_from, interface->disable_until);
			zbx_vector_ptr_append(interfaces, ia);
		}
	}
	UNLOCK_CACHE;
	zbx_vector_ptr_sort(interfaces, ZBX_DEFAULT_UINT64_PTR_COMPARE_FUNC);
	zabbix_log(LOG_LEVEL_DEBUG, "End of %s() interfaces:%d", __func__, interfaces->values_num);
	return 0 == interfaces->values_num ? FAIL : SUCCEED;
}
int DCget_interfaces_availability ( zbx_vector_ptr_t * interfaces , int * ts ) { const ZBX_DC_INTERFACE * interface ; zbx_hashset_iter_t iter ; zbx_interface_availability_t * ia = NULL ; zabbix_log ( LOG_LEVEL_DEBUG , " " , __func__ ) ; RDLOCK_CACHE ; * ts = time ( NULL ) ; zbx_hashset_iter_reset ( & config -> interfaces , & iter ) ; while ( NULL != ( interface = ( const ZBX_DC_INTERFACE * ) zbx_hashset_iter_next ( & iter ) ) ) { if ( config -> availability_diff_ts <= interface -> availability_ts && interface -> availability_ts < * ts ) { ia = ( zbx_interface_availability_t * ) zbx_malloc ( NULL , sizeof ( zbx_interface_availability_t ) ) ; zbx_interface_availability_init ( ia , interface -> interfaceid ) ; zbx_agent_availability_init ( & ia -> agent , interface -> available , interface -> error , interface -> errors_from , interface -> disable_until ) ; zbx_vector_ptr_append ( interfaces , ia ) ; } } UNLOCK_CACHE ; zbx_vector_ptr_sort ( interfaces , ZBX_DEFAULT_UINT64_PTR_COMPARE_FUNC ) ; zabbix_log ( LOG_LEVEL_DEBUG , " " , __func__ , interfaces -> values_num ) ; return 0 == interfaces -> values_num ? FAIL : SUCCEED ; }
Function: DCget_interfaces_availability                                     
                                                                             
 Purpose: gets availability data for interfaces with availability data       
          changed in period from last availability update to the specified   
          timestamp                                                          
                                                                             
 Parameters: interfaces - [OUT] changed interfaces availability data         
             ts    - [OUT] the availability diff timestamp                   
                                                                             
 Return value: SUCCEED - availability was changed for at least one interface 
               FAIL    - no interface availability was changed
Function : DCget_interfaces_availability Purpose : gets availability data for interfaces with availability data changed in period from last availability update to the specified timestamp Parameters : interfaces - [ OUT ] changed interfaces availability data ts - [ OUT ] the availability diff timestamp Return value : SUCCEED - availability was changed for at least one interface FAIL - no interface availability was changed