Contact Info

Crumbtrail

ActiveXperts.com » Administration » Scripts » WMI » python sample

Win32_PerfRawData_MSRS2008WindowsService python sample code

The foundations for Manageability in Windows is Windows Management Instrumentation (WMI; formerly WBEM) and WMI extensions for Windows Driver Model (WDM).

ActiveXperts Network Monitor provides the ability to build monitor check routines based on WMI. ActiveXperts has collected more than a hundred WMI samples. You can use these samples as a base for new check routines you can write yourself. The Win32_PerfRawData_MSRS2008WindowsService WMI class can be used in ActiveXperts Network Monitor to monitor your servers.


Sample Code

from win32com.client import GetObject
objWMI = GetObject('winmgmts:').InstancesOf('Win32_PerfRawData_MSRS2008WindowsService_MSRS2008WindowsService')

for obj in objWMI:
	if obj.ActiveSessions != None:
		print("ActiveSessions:" + str(obj.ActiveSessions))
	if obj.CacheHitsPerSec != None:
		print("CacheHitsPerSec:" + str(obj.CacheHitsPerSec))
	if obj.CacheHitsPerSecSemanticModels != None:
		print("CacheHitsPerSecSemanticModels:" + str(obj.CacheHitsPerSecSemanticModels))
	if obj.CacheMissesPerSec != None:
		print("CacheMissesPerSec:" + str(obj.CacheMissesPerSec))
	if obj.CacheMissesPerSecSemanticModels != None:
		print("CacheMissesPerSecSemanticModels:" + str(obj.CacheMissesPerSecSemanticModels))
	if obj.Caption != None:
		print("Caption:" + str(obj.Caption))
	if obj.Description != None:
		print("Description:" + str(obj.Description))
	if obj.FirstSessionRequestsPerSec != None:
		print("FirstSessionRequestsPerSec:" + str(obj.FirstSessionRequestsPerSec))
	if obj.Frequency_Object != None:
		print("Frequency_Object:" + str(obj.Frequency_Object))
	if obj.Frequency_PerfTime != None:
		print("Frequency_PerfTime:" + str(obj.Frequency_PerfTime))
	if obj.Frequency_Sys100NS != None:
		print("Frequency_Sys100NS:" + str(obj.Frequency_Sys100NS))
	if obj.MemoryCacheHitsPerSec != None:
		print("MemoryCacheHitsPerSec:" + str(obj.MemoryCacheHitsPerSec))
	if obj.MemoryCacheMissPerSec != None:
		print("MemoryCacheMissPerSec:" + str(obj.MemoryCacheMissPerSec))
	if obj.Name != None:
		print("Name:" + str(obj.Name))
	if obj.NextSessionRequestsPerSec != None:
		print("NextSessionRequestsPerSec:" + str(obj.NextSessionRequestsPerSec))
	if obj.ReportRequests != None:
		print("ReportRequests:" + str(obj.ReportRequests))
	if obj.ReportsExecutedPerSec != None:
		print("ReportsExecutedPerSec:" + str(obj.ReportsExecutedPerSec))
	if obj.RequestsPerSec != None:
		print("RequestsPerSec:" + str(obj.RequestsPerSec))
	if obj.Timestamp_Object != None:
		print("Timestamp_Object:" + str(obj.Timestamp_Object))
	if obj.Timestamp_PerfTime != None:
		print("Timestamp_PerfTime:" + str(obj.Timestamp_PerfTime))
	if obj.Timestamp_Sys100NS != None:
		print("Timestamp_Sys100NS:" + str(obj.Timestamp_Sys100NS))
	if obj.TotalCacheHits != None:
		print("TotalCacheHits:" + str(obj.TotalCacheHits))
	if obj.TotalCacheHitsSemanticModels != None:
		print("TotalCacheHitsSemanticModels:" + str(obj.TotalCacheHitsSemanticModels))
	if obj.TotalCacheMisses != None:
		print("TotalCacheMisses:" + str(obj.TotalCacheMisses))
	if obj.TotalCacheMissesSemanticModels != None:
		print("TotalCacheMissesSemanticModels:" + str(obj.TotalCacheMissesSemanticModels))
	if obj.TotalMemoryCacheHits != None:
		print("TotalMemoryCacheHits:" + str(obj.TotalMemoryCacheHits))
	if obj.TotalMemoryCacheMisses != None:
		print("TotalMemoryCacheMisses:" + str(obj.TotalMemoryCacheMisses))
	if obj.TotalProcessingFailures != None:
		print("TotalProcessingFailures:" + str(obj.TotalProcessingFailures))
	if obj.TotalRejectedThreads != None:
		print("TotalRejectedThreads:" + str(obj.TotalRejectedThreads))
	if obj.TotalReportsExecuted != None:
		print("TotalReportsExecuted:" + str(obj.TotalReportsExecuted))
	if obj.TotalRequests != None:
		print("TotalRequests:" + str(obj.TotalRequests))
	print("")
	print("########")
	print("")