Contact Info

Crumbtrail

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

Win32_PerfFormattedData_Tcpip 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_Tcpip 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_Tcpip_ICMP')

for obj in objWMI:
	if obj.Caption != None:
		print("Caption:" + str(obj.Caption))
	if obj.Description != None:
		print("Description:" + str(obj.Description))
	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.MessagesOutboundErrors != None:
		print("MessagesOutboundErrors:" + str(obj.MessagesOutboundErrors))
	if obj.MessagesPersec != None:
		print("MessagesPersec:" + str(obj.MessagesPersec))
	if obj.MessagesReceivedErrors != None:
		print("MessagesReceivedErrors:" + str(obj.MessagesReceivedErrors))
	if obj.MessagesReceivedPersec != None:
		print("MessagesReceivedPersec:" + str(obj.MessagesReceivedPersec))
	if obj.MessagesSentPersec != None:
		print("MessagesSentPersec:" + str(obj.MessagesSentPersec))
	if obj.Name != None:
		print("Name:" + str(obj.Name))
	if obj.ReceivedAddressMask != None:
		print("ReceivedAddressMask:" + str(obj.ReceivedAddressMask))
	if obj.ReceivedAddressMaskReply != None:
		print("ReceivedAddressMaskReply:" + str(obj.ReceivedAddressMaskReply))
	if obj.ReceivedDestUnreachable != None:
		print("ReceivedDestUnreachable:" + str(obj.ReceivedDestUnreachable))
	if obj.ReceivedEchoPersec != None:
		print("ReceivedEchoPersec:" + str(obj.ReceivedEchoPersec))
	if obj.ReceivedEchoReplyPersec != None:
		print("ReceivedEchoReplyPersec:" + str(obj.ReceivedEchoReplyPersec))
	if obj.ReceivedParameterProblem != None:
		print("ReceivedParameterProblem:" + str(obj.ReceivedParameterProblem))
	if obj.ReceivedRedirectPersec != None:
		print("ReceivedRedirectPersec:" + str(obj.ReceivedRedirectPersec))
	if obj.ReceivedSourceQuench != None:
		print("ReceivedSourceQuench:" + str(obj.ReceivedSourceQuench))
	if obj.ReceivedTimeExceeded != None:
		print("ReceivedTimeExceeded:" + str(obj.ReceivedTimeExceeded))
	if obj.ReceivedTimestampPersec != None:
		print("ReceivedTimestampPersec:" + str(obj.ReceivedTimestampPersec))
	if obj.ReceivedTimestampReplyPersec != None:
		print("ReceivedTimestampReplyPersec:" + str(obj.ReceivedTimestampReplyPersec))
	if obj.SentAddressMask != None:
		print("SentAddressMask:" + str(obj.SentAddressMask))
	if obj.SentAddressMaskReply != None:
		print("SentAddressMaskReply:" + str(obj.SentAddressMaskReply))
	if obj.SentDestinationUnreachable != None:
		print("SentDestinationUnreachable:" + str(obj.SentDestinationUnreachable))
	if obj.SentEchoPersec != None:
		print("SentEchoPersec:" + str(obj.SentEchoPersec))
	if obj.SentEchoReplyPersec != None:
		print("SentEchoReplyPersec:" + str(obj.SentEchoReplyPersec))
	if obj.SentParameterProblem != None:
		print("SentParameterProblem:" + str(obj.SentParameterProblem))
	if obj.SentRedirectPersec != None:
		print("SentRedirectPersec:" + str(obj.SentRedirectPersec))
	if obj.SentSourceQuench != None:
		print("SentSourceQuench:" + str(obj.SentSourceQuench))
	if obj.SentTimeExceeded != None:
		print("SentTimeExceeded:" + str(obj.SentTimeExceeded))
	if obj.SentTimestampPersec != None:
		print("SentTimestampPersec:" + str(obj.SentTimestampPersec))
	if obj.SentTimestampReplyPersec != None:
		print("SentTimestampReplyPersec:" + str(obj.SentTimestampReplyPersec))
	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("")