Contact Info

Crumbtrail

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

Win32_PerfFormattedData_PerfDisk 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_PerfFormattedData_PerfDisk 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_PerfFormattedData_PerfDisk_LogicalDisk')

for obj in objWMI:
	if obj.AvgDiskBytesPerRead != None:
		print("AvgDiskBytesPerRead:" + str(obj.AvgDiskBytesPerRead))
	if obj.AvgDiskBytesPerTransfer != None:
		print("AvgDiskBytesPerTransfer:" + str(obj.AvgDiskBytesPerTransfer))
	if obj.AvgDiskBytesPerWrite != None:
		print("AvgDiskBytesPerWrite:" + str(obj.AvgDiskBytesPerWrite))
	if obj.AvgDiskQueueLength != None:
		print("AvgDiskQueueLength:" + str(obj.AvgDiskQueueLength))
	if obj.AvgDiskReadQueueLength != None:
		print("AvgDiskReadQueueLength:" + str(obj.AvgDiskReadQueueLength))
	if obj.AvgDisksecPerRead != None:
		print("AvgDisksecPerRead:" + str(obj.AvgDisksecPerRead))
	if obj.AvgDisksecPerTransfer != None:
		print("AvgDisksecPerTransfer:" + str(obj.AvgDisksecPerTransfer))
	if obj.AvgDisksecPerWrite != None:
		print("AvgDisksecPerWrite:" + str(obj.AvgDisksecPerWrite))
	if obj.AvgDiskWriteQueueLength != None:
		print("AvgDiskWriteQueueLength:" + str(obj.AvgDiskWriteQueueLength))
	if obj.Caption != None:
		print("Caption:" + str(obj.Caption))
	if obj.CurrentDiskQueueLength != None:
		print("CurrentDiskQueueLength:" + str(obj.CurrentDiskQueueLength))
	if obj.Description != None:
		print("Description:" + str(obj.Description))
	if obj.DiskBytesPersec != None:
		print("DiskBytesPersec:" + str(obj.DiskBytesPersec))
	if obj.DiskReadBytesPersec != None:
		print("DiskReadBytesPersec:" + str(obj.DiskReadBytesPersec))
	if obj.DiskReadsPersec != None:
		print("DiskReadsPersec:" + str(obj.DiskReadsPersec))
	if obj.DiskTransfersPersec != None:
		print("DiskTransfersPersec:" + str(obj.DiskTransfersPersec))
	if obj.DiskWriteBytesPersec != None:
		print("DiskWriteBytesPersec:" + str(obj.DiskWriteBytesPersec))
	if obj.DiskWritesPersec != None:
		print("DiskWritesPersec:" + str(obj.DiskWritesPersec))
	if obj.FreeMegabytes != None:
		print("FreeMegabytes:" + str(obj.FreeMegabytes))
	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.Name != None:
		print("Name:" + str(obj.Name))
	if obj.PercentDiskReadTime != None:
		print("PercentDiskReadTime:" + str(obj.PercentDiskReadTime))
	if obj.PercentDiskTime != None:
		print("PercentDiskTime:" + str(obj.PercentDiskTime))
	if obj.PercentDiskWriteTime != None:
		print("PercentDiskWriteTime:" + str(obj.PercentDiskWriteTime))
	if obj.PercentFreeSpace != None:
		print("PercentFreeSpace:" + str(obj.PercentFreeSpace))
	if obj.PercentIdleTime != None:
		print("PercentIdleTime:" + str(obj.PercentIdleTime))
	if obj.SplitIOPerSec != None:
		print("SplitIOPerSec:" + str(obj.SplitIOPerSec))
	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))
	print("")
	print("########")
	print("")