zabbix-agent2/src/libs/zbxwin32/perfmon.c
/******************************************************************************
 *                                                                            *
 * Function: validate_counter_path                                            *
 *                                                                            *
 * Purpose: checks if a specified counter path data is pointing to a valid    *
 *          counter                                                           *
 *                                                                            *
 * Parameters: cpe - [IN] PDH counter path data                               *
 *                                                                            *
 * Return value: SUCCEED if counter data is valid,                            *
 *               FAIL otherwise                                               *
 *                                                                            *
 ******************************************************************************/
validate_counter_path

Purpose: checks if a specified counter path data is pointing to a valid
counter

Parameters: cpe - [IN] PDH counter path data

Return value: SUCCEED if counter data is valid,
FAIL otherwise
validate_counter_path Purpose : checks if a specified counter path data is pointing to a valid counter Parameters : cpe - [ IN ] PDH counter path data Return value : SUCCEED if counter data is valid FAIL otherwise
static int	validate_counter_path(PDH_COUNTER_PATH_ELEMENTS	*cpe)
{
	int		ret = FAIL;
	DWORD		s = 0;
	PDH_STATUS	pdh_status;
	wchar_t		*path = NULL;
	if (PDH_MORE_DATA == (pdh_status = PdhMakeCounterPath(cpe, NULL, &s, 0)))
	{
		path = zbx_malloc(path, sizeof(wchar_t) * s);
		if (ERROR_SUCCESS != (pdh_status = PdhMakeCounterPath(cpe, path, &s, 0)))
		{
			zabbix_log(LOG_LEVEL_WARNING, "PdhMakeCounterPath() failed: %s",
					strerror_from_module(pdh_status, L"PDH.DLL"));
		}
		else if (ERROR_SUCCESS != (pdh_status = PdhValidatePath(path)))
		{
			if (PDH_CSTATUS_NO_COUNTER != pdh_status && PDH_CSTATUS_NO_INSTANCE != pdh_status)
			{
				zabbix_log(LOG_LEVEL_DEBUG, "PdhValidatePath() szObjectName:%s szCounterName:%s"
						" failed: %s", cpe->szObjectName, cpe->szCounterName,
						strerror_from_module(pdh_status, L"PDH.DLL"));
			}
		}
		else
		{
			ret = SUCCEED;
		}
		zbx_free(path);
	}
	else
	{
		zabbix_log(LOG_LEVEL_DEBUG, "PdhMakeCounterPath() failed: %s",
				strerror_from_module(pdh_status, L"PDH.DLL"));
	}
	return ret;
}
static int validate_counter_path ( PDH_COUNTER_PATH_ELEMENTS * cpe ) { int ret = FAIL ; DWORD s = 0 ; PDH_STATUS pdh_status ; wchar_t * path = NULL ; if ( PDH_MORE_DATA == ( pdh_status = PdhMakeCounterPath ( cpe , NULL , & s , 0 ) ) ) { path = zbx_malloc ( path , sizeof ( wchar_t ) * s ) ; if ( ERROR_SUCCESS != ( pdh_status = PdhMakeCounterPath ( cpe , path , & s , 0 ) ) ) { zabbix_log ( LOG_LEVEL_WARNING , " " , strerror_from_module ( pdh_status , L" " ) ) ; } else if ( ERROR_SUCCESS != ( pdh_status = PdhValidatePath ( path ) ) ) { if ( PDH_CSTATUS_NO_COUNTER != pdh_status && PDH_CSTATUS_NO_INSTANCE != pdh_status ) { zabbix_log ( LOG_LEVEL_DEBUG , " " " " , cpe -> szObjectName , cpe -> szCounterName , strerror_from_module ( pdh_status , L" " ) ) ; } } else { ret = SUCCEED ; } zbx_free ( path ) ; } else { zabbix_log ( LOG_LEVEL_DEBUG , " " , strerror_from_module ( pdh_status , L" " ) ) ; } return ret ; }
Function: validate_counter_path                                            
                                                                            
 Purpose: checks if a specified counter path data is pointing to a valid    
          counter                                                           
                                                                            
 Parameters: cpe - [IN] PDH counter path data                               
                                                                            
 Return value: SUCCEED if counter data is valid,                            
               FAIL otherwise
Function : validate_counter_path Purpose : checks if a specified counter path data is pointing to a valid counter Parameters : cpe - [ IN ] PDH counter path data Return value : SUCCEED if counter data is valid FAIL otherwise