zabbix-agent2/src/libs/zbxwin32/perfmon.c
/******************************************************************************
 *                                                                            *
 * Function: validate_object_counter                                          *
 *                                                                            *
 * Purpose: checks if specified counter is valid successor of the object      *
 *                                                                            *
 * Parameters: object  - [IN] PDH object index                                *
 *             counter - [IN] PDH counter index                               *
 *                                                                            *
 * Return value: SUCCEED if object - counter combination is valid,            *
 *               FAIL otherwise                                               *
 *                                                                            *
 ******************************************************************************/
validate_object_counter

Purpose: checks if specified counter is valid successor of the object

Parameters: object  - [IN] PDH object index
counter - [IN] PDH counter index

Return value: SUCCEED if object - counter combination is valid,
FAIL otherwise
validate_object_counter Purpose : checks if specified counter is valid successor of the object Parameters : object - [ IN ] PDH object index counter - [ IN ] PDH counter index Return value : SUCCEED if object - counter combination is valid FAIL otherwise
static int	validate_object_counter(DWORD object, DWORD counter)
{
	PDH_COUNTER_PATH_ELEMENTS	*cpe;
	int				ret = SUCCEED;
	cpe = (PDH_COUNTER_PATH_ELEMENTS *)zbx_malloc(NULL, sizeof(PDH_COUNTER_PATH_ELEMENTS));
	memset(cpe, 0, sizeof(PDH_COUNTER_PATH_ELEMENTS));
	cpe->szObjectName = zbx_malloc(NULL, sizeof(wchar_t) * PDH_MAX_COUNTER_NAME);
	cpe->szCounterName = zbx_malloc(NULL, sizeof(wchar_t) * PDH_MAX_COUNTER_NAME);
	if (SUCCEED != get_perf_name_by_index(object, cpe->szObjectName, PDH_MAX_COUNTER_NAME) ||
			SUCCEED != get_perf_name_by_index(counter, cpe->szCounterName, PDH_MAX_COUNTER_NAME))
	{
		ret = FAIL;
		goto out;
	}
	if (SUCCEED != validate_counter_path(cpe))
	{
		cpe->szInstanceName = L"*";
		if (SUCCEED != validate_counter_path(cpe))
			ret = FAIL;
	}
out:
	zbx_free(cpe->szCounterName);
	zbx_free(cpe->szObjectName);
	zbx_free(cpe);
	return ret;
}
static int validate_object_counter ( DWORD object , DWORD counter ) { PDH_COUNTER_PATH_ELEMENTS * cpe ; int ret = SUCCEED ; cpe = ( PDH_COUNTER_PATH_ELEMENTS * ) zbx_malloc ( NULL , sizeof ( PDH_COUNTER_PATH_ELEMENTS ) ) ; memset ( cpe , 0 , sizeof ( PDH_COUNTER_PATH_ELEMENTS ) ) ; cpe -> szObjectName = zbx_malloc ( NULL , sizeof ( wchar_t ) * PDH_MAX_COUNTER_NAME ) ; cpe -> szCounterName = zbx_malloc ( NULL , sizeof ( wchar_t ) * PDH_MAX_COUNTER_NAME ) ; if ( SUCCEED != get_perf_name_by_index ( object , cpe -> szObjectName , PDH_MAX_COUNTER_NAME ) || SUCCEED != get_perf_name_by_index ( counter , cpe -> szCounterName , PDH_MAX_COUNTER_NAME ) ) { ret = FAIL ; goto out ; } if ( SUCCEED != validate_counter_path ( cpe ) ) { cpe -> szInstanceName = L" " ; if ( SUCCEED != validate_counter_path ( cpe ) ) ret = FAIL ; } out : zbx_free ( cpe -> szCounterName ) ; zbx_free ( cpe -> szObjectName ) ; zbx_free ( cpe ) ; return ret ; }
Function: validate_object_counter                                          
                                                                            
 Purpose: checks if specified counter is valid successor of the object      
                                                                            
 Parameters: object  - [IN] PDH object index                                
             counter - [IN] PDH counter index                               
                                                                            
 Return value: SUCCEED if object - counter combination is valid,            
               FAIL otherwise
Function : validate_object_counter Purpose : checks if specified counter is valid successor of the object Parameters : object - [ IN ] PDH object index counter - [ IN ] PDH counter index Return value : SUCCEED if object - counter combination is valid FAIL otherwise
/* try with "any" instance name */