Пример #1
0
	pdh_error ThreadedSafePDH::PdhValidatePath(LPCWSTR szFullPathBuffer, bool force_reload) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhValidatePath");
		if (pPdhValidatePath == NULL)
			throw pdh_exception("Failed to initialize PdhValidatePath :(");
		pdh_error status = pdh_error(pPdhValidatePath(szFullPathBuffer));
		if (status.is_error() && force_reload) {
			reload_unsafe();
			status = pdh_error(pPdhValidatePath(szFullPathBuffer));
		}
		return status;
	}
Пример #2
0
	pdh_error ThreadedSafePDH::PdhAddCounter(PDH::PDH_HQUERY hQuery, LPCWSTR szFullCounterPath, DWORD_PTR dwUserData, PDH::PDH_HCOUNTER * phCounter) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhAddCounter");
		if (pPdhAddCounter == NULL)
			throw pdh_exception("Failed to initialize PdhAddCounter :(");
		return pdh_error(pPdhAddCounter(hQuery,szFullCounterPath,dwUserData,phCounter));
	}
Пример #3
0
	pdh_error ThreadedSafePDH::PdhGetCounterInfo(PDH::PDH_HCOUNTER hCounter, BOOLEAN bRetrieveExplainText, LPDWORD pdwBufferSize, PDH_COUNTER_INFO *lpBuffer) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhGetCounterInfo");
		if (pPdhGetCounterInfo == NULL)
			throw pdh_exception("Failed to initialize PdhGetCounterInfo :(");
		return pdh_error(pPdhGetCounterInfo(hCounter,bRetrieveExplainText,pdwBufferSize,lpBuffer));
	}
Пример #4
0
	pdh_error ThreadedSafePDH::PdhExpandCounterPath(LPCTSTR szWildCardPath, LPTSTR mszExpandedPathList, LPDWORD pcchPathListLength) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhExpandCounterPath");
		if (pPdhExpandCounterPath == NULL)
			throw pdh_exception("Failed to initialize PdhLookupPerfNameByIndex :(");
		return pdh_error(pPdhExpandCounterPath(szWildCardPath,mszExpandedPathList,pcchPathListLength));
	}
Пример #5
0
	pdh_error ThreadedSafePDH::PdhLookupPerfNameByIndex(LPCTSTR szMachineName,DWORD dwNameIndex,LPTSTR szNameBuffer,LPDWORD pcchNameBufferSize) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhLookupPerfNameByIndex");
		if (pPdhLookupPerfNameByIndex == NULL)
			throw pdh_exception("Failed to initialize PdhLookupPerfNameByIndex :(");
		return pdh_error(pPdhLookupPerfNameByIndex(szMachineName,dwNameIndex,szNameBuffer,pcchNameBufferSize));
	}
Пример #6
0
	pdh_error ThreadedSafePDH::PdhLookupPerfIndexByName(LPCTSTR szMachineName,LPCTSTR szName,DWORD *dwIndex) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhLookupPerfIndexByName");
		if (pPdhLookupPerfIndexByName == NULL)
			throw pdh_exception("Failed to initialize PdhLookupPerfIndexByName");
		return pdh_error(pPdhLookupPerfIndexByName(szMachineName,szName,dwIndex));
	}
Пример #7
0
	pdh_error ThreadedSafePDH::PdhEnumObjectItems(LPCWSTR szDataSource, LPCWSTR szMachineName, LPCWSTR szObjectName, LPWSTR mszCounterList, LPDWORD pcchCounterListLength, LPWSTR mszInstanceList, LPDWORD pcchInstanceListLength, DWORD dwDetailLevel, DWORD dwFlags) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhEnumObjectItems");
		if (pPdhEnumObjectItems == NULL)
			throw pdh_exception("Failed to initialize PdhEnumObjectItems :(");
		return pdh_error(pPdhEnumObjectItems(szDataSource, szMachineName, szObjectName, mszCounterList, pcchCounterListLength, mszInstanceList, pcchInstanceListLength, dwDetailLevel, dwFlags));
	}
Пример #8
0
	pdh_error ThreadedSafePDH::PdhEnumObjects(LPCWSTR szDataSource, LPCWSTR szMachineName, LPWSTR mszObjectList, LPDWORD pcchBufferSize, DWORD dwDetailLevel, BOOL bRefresh) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhEnumObjects");
		if (pPdhEnumObjects == NULL)
			throw pdh_exception("Failed to initialize PdhEnumObjects :(");
		return pdh_error(pPdhEnumObjects(szDataSource, szMachineName, mszObjectList, pcchBufferSize, dwDetailLevel, bRefresh));
	}
Пример #9
0
	pdh_error ThreadedSafePDH::PdhCollectQueryData(PDH_HQUERY hQuery) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhCollectQueryData");
		if (pPdhCollectQueryData == NULL)
			throw pdh_exception("Failed to initialize PdhCollectQueryData :(");
		return pdh_error(pPdhCollectQueryData(hQuery));
	}
Пример #10
0
	pdh_error ThreadedSafePDH::PdhOpenQuery(LPCWSTR szDataSource, DWORD_PTR dwUserData, PDH::PDH_HQUERY * phQuery) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhOpenQuery");
		if (pPdhOpenQuery == NULL)
			throw pdh_exception("Failed to initialize PdhOpenQuery :(");
		return pdh_error(pPdhOpenQuery(szDataSource, dwUserData, phQuery));
	}
Пример #11
0
	pdh_error ThreadedSafePDH::PdhGetFormattedCounterValue(PDH_HCOUNTER hCounter, DWORD dwFormat, LPDWORD lpdwType, PPDH_FMT_COUNTERVALUE pValue) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhGetFormattedCounterValue");
		if (pPdhGetFormattedCounterValue == NULL)
			throw pdh_exception("Failed to initialize PdhGetFormattedCounterValue :(");
		return pdh_error(pPdhGetFormattedCounterValue(hCounter, dwFormat, lpdwType, pValue));
	}
Пример #12
0
	pdh_error ThreadedSafePDH::PdhRemoveCounter(PDH::PDH_HCOUNTER hCounter) {
		boost::unique_lock<boost::shared_mutex> lock(mutex_);
		if (!lock.owns_lock())
			throw pdh_exception("Failed to get mutex for PdhRemoveCounter");
		if (pPdhRemoveCounter == NULL)
			throw pdh_exception("Failed to initialize PdhRemoveCounter :(");
		return pdh_error(pPdhRemoveCounter(hCounter));
	}
Пример #13
0
pdh_error PDHCounter::collect() {
    pdh_error status;
    if (hCounter_ == NULL)
        return pdh_error(false);
    status = factory::get_impl()->PdhGetFormattedCounterValue(hCounter_, counter_->get_format(), NULL, &data_);
    if (!status.is_error()) {
        counter_->collect(data_);
    }
    return status;
}