Contact Info

Crumbtrail

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

Win32_PerfFormattedData_ftpsvc 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_ftpsvc 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_ftpsvc_MicrosoftFTPService')

for obj in objWMI:
	if obj.BytesReceivedPersec != None:
		print("BytesReceivedPersec:" + str(obj.BytesReceivedPersec))
	if obj.BytesSentPersec != None:
		print("BytesSentPersec:" + str(obj.BytesSentPersec))
	if obj.BytesTotalPersec != None:
		print("BytesTotalPersec:" + str(obj.BytesTotalPersec))
	if obj.Caption != None:
		print("Caption:" + str(obj.Caption))
	if obj.CurrentAnonymousUsers != None:
		print("CurrentAnonymousUsers:" + str(obj.CurrentAnonymousUsers))
	if obj.CurrentConnections != None:
		print("CurrentConnections:" + str(obj.CurrentConnections))
	if obj.CurrentNonAnonymousUsers != None:
		print("CurrentNonAnonymousUsers:" + str(obj.CurrentNonAnonymousUsers))
	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.MaximumAnonymousUsers != None:
		print("MaximumAnonymousUsers:" + str(obj.MaximumAnonymousUsers))
	if obj.MaximumConnections != None:
		print("MaximumConnections:" + str(obj.MaximumConnections))
	if obj.MaximumNonAnonymousUsers != None:
		print("MaximumNonAnonymousUsers:" + str(obj.MaximumNonAnonymousUsers))
	if obj.MicrosoftFTPServiceUptime != None:
		print("MicrosoftFTPServiceUptime:" + str(obj.MicrosoftFTPServiceUptime))
	if obj.Name != None:
		print("Name:" + str(obj.Name))
	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.TotalAnonymousUsers != None:
		print("TotalAnonymousUsers:" + str(obj.TotalAnonymousUsers))
	if obj.TotalConnectionAttempts != None:
		print("TotalConnectionAttempts:" + str(obj.TotalConnectionAttempts))
	if obj.TotalFilesReceived != None:
		print("TotalFilesReceived:" + str(obj.TotalFilesReceived))
	if obj.TotalFilesSent != None:
		print("TotalFilesSent:" + str(obj.TotalFilesSent))
	if obj.TotalFilesTransferred != None:
		print("TotalFilesTransferred:" + str(obj.TotalFilesTransferred))
	if obj.TotalLogonAttempts != None:
		print("TotalLogonAttempts:" + str(obj.TotalLogonAttempts))
	if obj.TotalNonAnonymousUsers != None:
		print("TotalNonAnonymousUsers:" + str(obj.TotalNonAnonymousUsers))
	print("")
	print("########")
	print("")