Win32_PerfRawData_TermService_TerminalServicesSession - WMI sample in Python

The foundations for Manageability in Windows 7/2008/Vista/XP/2000 and Millennium Edition/'98 are 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.

On this site, you can find many WMI samples.


Win32_PerfRawData_TermService_TerminalServicesSession

Description

The Win32_PerfRawData_TermService_TerminalServicesSession raw data performance counter class represents raw data terminal services per-session resource monitoring. This class is shown as the Terminal Services Session object in System Monitor. The WMI source of its data is the high-performance Performance Counter Provider. The original data source is the TermService performance library. The corresponding formatted data class is Win32_PerfFormattedData_TermService_TerminalServicesSession. This class was added for Windows 2000.

Example(s)

import win32com.client
def WMIDateStringToDate(dtmDate):
    strDateTime = ""
    if (dtmDate[4] == 0):
        strDateTime = dtmDate[5] + '/'
    else:
        strDateTime = dtmDate[4] + dtmDate[5] + '/'
    if (dtmDate[6] == 0):
        strDateTime = strDateTime + dtmDate[7] + '/'
    else:
        strDateTime = strDateTime + dtmDate[6] + dtmDate[7] + '/'
        strDateTime = strDateTime + dtmDate[0] + dtmDate[1] + dtmDate[2] + dtmDate[3] + " " + dtmDate[8] + dtmDate[9] + ":" + dtmDate[10] + dtmDate[11] +':' + dtmDate[12] + dtmDate[13]
    return strDateTime

strComputer = "."
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
colItems = objSWbemServices.ExecQuery("SELECT * FROM Win32_PerfRawData_TermService_TerminalServicesSession")
for objItem in colItems:
    if objItem.Caption != None:
        print "Caption:" + ` objItem.Caption`
    if objItem.Description != None:
        print "Description:" + ` objItem.Description`
    if objItem.Frequency_Object != None:
        print "Frequency_Object:" + ` objItem.Frequency_Object`
    if objItem.Frequency_PerfTime != None:
        print "Frequency_PerfTime:" + ` objItem.Frequency_PerfTime`
    if objItem.Frequency_Sys100NS != None:
        print "Frequency_Sys100NS:" + ` objItem.Frequency_Sys100NS`
    if objItem.HandleCount != None:
        print "HandleCount:" + ` objItem.HandleCount`
    if objItem.InputAsyncFrameError != None:
        print "InputAsyncFrameError:" + ` objItem.InputAsyncFrameError`
    if objItem.InputAsyncOverflow != None:
        print "InputAsyncOverflow:" + ` objItem.InputAsyncOverflow`
    if objItem.InputAsyncOverrun != None:
        print "InputAsyncOverrun:" + ` objItem.InputAsyncOverrun`
    if objItem.InputAsyncParityError != None:
        print "InputAsyncParityError:" + ` objItem.InputAsyncParityError`
    if objItem.InputBytes != None:
        print "InputBytes:" + ` objItem.InputBytes`
    if objItem.InputCompressedBytes != None:
        print "InputCompressedBytes:" + ` objItem.InputCompressedBytes`
    if objItem.InputCompressFlushes != None:
        print "InputCompressFlushes:" + ` objItem.InputCompressFlushes`
    if objItem.InputCompressionRatio != None:
        print "InputCompressionRatio:" + ` objItem.InputCompressionRatio`
    if objItem.InputErrors != None:
        print "InputErrors:" + ` objItem.InputErrors`
    if objItem.InputFrames != None:
        print "InputFrames:" + ` objItem.InputFrames`
    if objItem.InputTimeouts != None:
        print "InputTimeouts:" + ` objItem.InputTimeouts`
    if objItem.InputTransportErrors != None:
        print "InputTransportErrors:" + ` objItem.InputTransportErrors`
    if objItem.InputWaitForOutBuf != None:
        print "InputWaitForOutBuf:" + ` objItem.InputWaitForOutBuf`
    if objItem.InputWdBytes != None:
        print "InputWdBytes:" + ` objItem.InputWdBytes`
    if objItem.InputWdFrames != None:
        print "InputWdFrames:" + ` objItem.InputWdFrames`
    if objItem.Name != None:
        print "Name:" + ` objItem.Name`
    if objItem.OutputAsyncFrameError != None:
        print "OutputAsyncFrameError:" + ` objItem.OutputAsyncFrameError`
    if objItem.OutputAsyncOverflow != None:
        print "OutputAsyncOverflow:" + ` objItem.OutputAsyncOverflow`
    if objItem.OutputAsyncOverrun != None:
        print "OutputAsyncOverrun:" + ` objItem.OutputAsyncOverrun`
    if objItem.OutputAsyncParityError != None:
        print "OutputAsyncParityError:" + ` objItem.OutputAsyncParityError`
    if objItem.OutputBytes != None:
        print "OutputBytes:" + ` objItem.OutputBytes`
    if objItem.OutputCompressedBytes != None:
        print "OutputCompressedBytes:" + ` objItem.OutputCompressedBytes`
    if objItem.OutputCompressFlushes != None:
        print "OutputCompressFlushes:" + ` objItem.OutputCompressFlushes`
    if objItem.OutputCompressionRatio != None:
        print "OutputCompressionRatio:" + ` objItem.OutputCompressionRatio`
    if objItem.OutputErrors != None:
        print "OutputErrors:" + ` objItem.OutputErrors`
    if objItem.OutputFrames != None:
        print "OutputFrames:" + ` objItem.OutputFrames`
    if objItem.OutputTimeouts != None:
        print "OutputTimeouts:" + ` objItem.OutputTimeouts`
    if objItem.OutputTransportErrors != None:
        print "OutputTransportErrors:" + ` objItem.OutputTransportErrors`
    if objItem.OutputWaitForOutBuf != None:
        print "OutputWaitForOutBuf:" + ` objItem.OutputWaitForOutBuf`
    if objItem.OutputWdBytes != None:
        print "OutputWdBytes:" + ` objItem.OutputWdBytes`
    if objItem.OutputWdFrames != None:
        print "OutputWdFrames:" + ` objItem.OutputWdFrames`
    if objItem.PageFaultsPersec != None:
        print "PageFaultsPersec:" + ` objItem.PageFaultsPersec`
    if objItem.PageFileBytes != None:
        print "PageFileBytes:" + ` objItem.PageFileBytes`
    if objItem.PageFileBytesPeak != None:
        print "PageFileBytesPeak:" + ` objItem.PageFileBytesPeak`
    if objItem.PercentPrivilegedTime != None:
        print "PercentPrivilegedTime:" + ` objItem.PercentPrivilegedTime`
    if objItem.PercentProcessorTime != None:
        print "PercentProcessorTime:" + ` objItem.PercentProcessorTime`
    if objItem.PercentUserTime != None:
        print "PercentUserTime:" + ` objItem.PercentUserTime`
    if objItem.PoolNonpagedBytes != None:
        print "PoolNonpagedBytes:" + ` objItem.PoolNonpagedBytes`
    if objItem.PoolPagedBytes != None:
        print "PoolPagedBytes:" + ` objItem.PoolPagedBytes`
    if objItem.PrivateBytes != None:
        print "PrivateBytes:" + ` objItem.PrivateBytes`
    if objItem.ProtocolBitmapCacheHitRatio != None:
        print "ProtocolBitmapCacheHitRatio:" + ` objItem.ProtocolBitmapCacheHitRatio`
    if objItem.ProtocolBitmapCacheHits != None:
        print "ProtocolBitmapCacheHits:" + ` objItem.ProtocolBitmapCacheHits`
    if objItem.ProtocolBitmapCacheReads != None:
        print "ProtocolBitmapCacheReads:" + ` objItem.ProtocolBitmapCacheReads`
    if objItem.ProtocolBrushCacheHitRatio != None:
        print "ProtocolBrushCacheHitRatio:" + ` objItem.ProtocolBrushCacheHitRatio`
    if objItem.ProtocolBrushCacheHits != None:
        print "ProtocolBrushCacheHits:" + ` objItem.ProtocolBrushCacheHits`
    if objItem.ProtocolBrushCacheReads != None:
        print "ProtocolBrushCacheReads:" + ` objItem.ProtocolBrushCacheReads`
    if objItem.ProtocolGlyphCacheHitRatio != None:
        print "ProtocolGlyphCacheHitRatio:" + ` objItem.ProtocolGlyphCacheHitRatio`
    if objItem.ProtocolGlyphCacheHits != None:
        print "ProtocolGlyphCacheHits:" + ` objItem.ProtocolGlyphCacheHits`
    if objItem.ProtocolGlyphCacheReads != None:
        print "ProtocolGlyphCacheReads:" + ` objItem.ProtocolGlyphCacheReads`
    if objItem.ProtocolSaveScreenBitmapCacheHitRatio != None:
        print "ProtocolSaveScreenBitmapCacheHitRatio:" + ` objItem.ProtocolSaveScreenBitmapCacheHitRatio`
    if objItem.ProtocolSaveScreenBitmapCacheHits != None:
        print "ProtocolSaveScreenBitmapCacheHits:" + ` objItem.ProtocolSaveScreenBitmapCacheHits`
    if objItem.ProtocolSaveScreenBitmapCacheReads != None:
        print "ProtocolSaveScreenBitmapCacheReads:" + ` objItem.ProtocolSaveScreenBitmapCacheReads`
    if objItem.ThreadCount != None:
        print "ThreadCount:" + ` objItem.ThreadCount`
    if objItem.Timestamp_Object != None:
        print "Timestamp_Object:" + ` objItem.Timestamp_Object`
    if objItem.Timestamp_PerfTime != None:
        print "Timestamp_PerfTime:" + ` objItem.Timestamp_PerfTime`
    if objItem.Timestamp_Sys100NS != None:
        print "Timestamp_Sys100NS:" + ` objItem.Timestamp_Sys100NS`
    if objItem.TotalAsyncFrameError != None:
        print "TotalAsyncFrameError:" + ` objItem.TotalAsyncFrameError`
    if objItem.TotalAsyncOverflow != None:
        print "TotalAsyncOverflow:" + ` objItem.TotalAsyncOverflow`
    if objItem.TotalAsyncOverrun != None:
        print "TotalAsyncOverrun:" + ` objItem.TotalAsyncOverrun`
    if objItem.TotalAsyncParityError != None:
        print "TotalAsyncParityError:" + ` objItem.TotalAsyncParityError`
    if objItem.TotalBytes != None:
        print "TotalBytes:" + ` objItem.TotalBytes`
    if objItem.TotalCompressedBytes != None:
        print "TotalCompressedBytes:" + ` objItem.TotalCompressedBytes`
    if objItem.TotalCompressFlushes != None:
        print "TotalCompressFlushes:" + ` objItem.TotalCompressFlushes`
    if objItem.TotalCompressionRatio != None:
        print "TotalCompressionRatio:" + ` objItem.TotalCompressionRatio`
    if objItem.TotalErrors != None:
        print "TotalErrors:" + ` objItem.TotalErrors`
    if objItem.TotalFrames != None:
        print "TotalFrames:" + ` objItem.TotalFrames`
    if objItem.TotalProtocolCacheHitRatio != None:
        print "TotalProtocolCacheHitRatio:" + ` objItem.TotalProtocolCacheHitRatio`
    if objItem.TotalProtocolCacheHits != None:
        print "TotalProtocolCacheHits:" + ` objItem.TotalProtocolCacheHits`
    if objItem.TotalProtocolCacheReads != None:
        print "TotalProtocolCacheReads:" + ` objItem.TotalProtocolCacheReads`
    if objItem.TotalTimeouts != None:
        print "TotalTimeouts:" + ` objItem.TotalTimeouts`
    if objItem.TotalTransportErrors != None:
        print "TotalTransportErrors:" + ` objItem.TotalTransportErrors`
    if objItem.TotalWaitForOutBuf != None:
        print "TotalWaitForOutBuf:" + ` objItem.TotalWaitForOutBuf`
    if objItem.TotalWdBytes != None:
        print "TotalWdBytes:" + ` objItem.TotalWdBytes`
    if objItem.TotalWdFrames != None:
        print "TotalWdFrames:" + ` objItem.TotalWdFrames`
    if objItem.VirtualBytes != None:
        print "VirtualBytes:" + ` objItem.VirtualBytes`
    if objItem.VirtualBytesPeak != None:
        print "VirtualBytesPeak:" + ` objItem.VirtualBytesPeak`
    if objItem.WorkingSet != None:
        print "WorkingSet:" + ` objItem.WorkingSet`
    if objItem.WorkingSetPeak != None:
        print "WorkingSetPeak:" + ` objItem.WorkingSetPeak`