Contact Info

Crumbtrail

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

Win32_PerfRawData_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_PerfRawData_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_PerfRawData_PerfDisk_LogicalDisk')

for obj in objWMI:
	if obj.AvgDiskBytesPerRead != None:
		print("AvgDiskBytesPerRead:" + str(obj.AvgDiskBytesPerRead))
	if obj.AvgDiskBytesPerRead_Base != None:
		print("AvgDiskBytesPerRead_Base:" + str(obj.AvgDiskBytesPerRead_Base))
	if obj.AvgDiskBytesPerTransfer != None:
		print("AvgDiskBytesPerTransfer:" + str(obj.AvgDiskBytesPerTransfer))
	if obj.AvgDiskBytesPerTransfer_Base != None:
		print("AvgDiskBytesPerTransfer_Base:" + str(obj.AvgDiskBytesPerTransfer_Base))
	if obj.AvgDiskBytesPerWrite != None:
		print("AvgDiskBytesPerWrite:" + str(obj.AvgDiskBytesPerWrite))
	if obj.AvgDiskBytesPerWrite_Base != None:
		print("AvgDiskBytesPerWrite_Base:" + str(obj.AvgDiskBytesPerWrite_Base))
	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.AvgDisksecPerRead_Base != None:
		print("AvgDisksecPerRead_Base:" + str(obj.AvgDisksecPerRead_Base))
	if obj.AvgDisksecPerTransfer != None:
		print("AvgDisksecPerTransfer:" + str(obj.AvgDisksecPerTransfer))
	if obj.AvgDisksecPerTransfer_Base != None:
		print("AvgDisksecPerTransfer_Base:" + str(obj.AvgDisksecPerTransfer_Base))
	if obj.AvgDisksecPerWrite != None:
		print("AvgDisksecPerWrite:" + str(obj.AvgDisksecPerWrite))
	if obj.AvgDisksecPerWrite_Base != None:
		print("AvgDisksecPerWrite_Base:" + str(obj.AvgDisksecPerWrite_Base))
	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.PercentDiskReadTime_Base != None:
		print("PercentDiskReadTime_Base:" + str(obj.PercentDiskReadTime_Base))
	if obj.PercentDiskTime != None:
		print("PercentDiskTime:" + str(obj.PercentDiskTime))
	if obj.PercentDiskTime_Base != None:
		print("PercentDiskTime_Base:" + str(obj.PercentDiskTime_Base))
	if obj.PercentDiskWriteTime != None:
		print("PercentDiskWriteTime:" + str(obj.PercentDiskWriteTime))
	if obj.PercentDiskWriteTime_Base != None:
		print("PercentDiskWriteTime_Base:" + str(obj.PercentDiskWriteTime_Base))
	if obj.PercentFreeSpace != None:
		print("PercentFreeSpace:" + str(obj.PercentFreeSpace))
	if obj.PercentFreeSpace_Base != None:
		print("PercentFreeSpace_Base:" + str(obj.PercentFreeSpace_Base))
	if obj.PercentIdleTime != None:
		print("PercentIdleTime:" + str(obj.PercentIdleTime))
	if obj.PercentIdleTime_Base != None:
		print("PercentIdleTime_Base:" + str(obj.PercentIdleTime_Base))
	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("")