Win32_PerfRawData_TermService 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_TermService 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_TermService_TerminalServicesSession')
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.HandleCount != None:
print("HandleCount:" + str(obj.HandleCount))
if obj.Name != None:
print("Name:" + str(obj.Name))
if obj.PageFaultsPersec != None:
print("PageFaultsPersec:" + str(obj.PageFaultsPersec))
if obj.PageFileBytes != None:
print("PageFileBytes:" + str(obj.PageFileBytes))
if obj.PageFileBytesPeak != None:
print("PageFileBytesPeak:" + str(obj.PageFileBytesPeak))
if obj.PercentPrivilegedTime != None:
print("PercentPrivilegedTime:" + str(obj.PercentPrivilegedTime))
if obj.PercentProcessorTime != None:
print("PercentProcessorTime:" + str(obj.PercentProcessorTime))
if obj.PercentUserTime != None:
print("PercentUserTime:" + str(obj.PercentUserTime))
if obj.PoolNonpagedBytes != None:
print("PoolNonpagedBytes:" + str(obj.PoolNonpagedBytes))
if obj.PoolPagedBytes != None:
print("PoolPagedBytes:" + str(obj.PoolPagedBytes))
if obj.PrivateBytes != None:
print("PrivateBytes:" + str(obj.PrivateBytes))
if obj.ThreadCount != None:
print("ThreadCount:" + str(obj.ThreadCount))
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.VirtualBytes != None:
print("VirtualBytes:" + str(obj.VirtualBytes))
if obj.VirtualBytesPeak != None:
print("VirtualBytesPeak:" + str(obj.VirtualBytesPeak))
if obj.WorkingSet != None:
print("WorkingSet:" + str(obj.WorkingSet))
if obj.WorkingSetPeak != None:
print("WorkingSetPeak:" + str(obj.WorkingSetPeak))
print("")
print("########")
print("")
