Contact Info

Crumbtrail

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

Win32_PerfRawData_ASPNET_114322_ASPNETAppsv114322 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_ASPNET_114322_ASPNETAppsv114322 WMI class can be used in ActiveXperts Network Monitor to monitor your servers.


Sample Code

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_ASPNET_114322_ASPNETAppsv114322")
for objItem in colItems:
    if objItem.AnonymousRequests != None:
        print "AnonymousRequests:" + ` objItem.AnonymousRequests`
    if objItem.AnonymousRequestsPerSec != None:
        print "AnonymousRequestsPerSec:" + ` objItem.AnonymousRequestsPerSec`
    if objItem.CacheAPIEntries != None:
        print "CacheAPIEntries:" + ` objItem.CacheAPIEntries`
    if objItem.CacheAPIHitRatio != None:
        print "CacheAPIHitRatio:" + ` objItem.CacheAPIHitRatio`
    if objItem.CacheAPIHitRatio_Base != None:
        print "CacheAPIHitRatio_Base:" + ` objItem.CacheAPIHitRatio_Base`
    if objItem.CacheAPIHits != None:
        print "CacheAPIHits:" + ` objItem.CacheAPIHits`
    if objItem.CacheAPIMisses != None:
        print "CacheAPIMisses:" + ` objItem.CacheAPIMisses`
    if objItem.CacheAPITurnoverRate != None:
        print "CacheAPITurnoverRate:" + ` objItem.CacheAPITurnoverRate`
    if objItem.CacheTotalEntries != None:
        print "CacheTotalEntries:" + ` objItem.CacheTotalEntries`
    if objItem.CacheTotalHitRatio != None:
        print "CacheTotalHitRatio:" + ` objItem.CacheTotalHitRatio`
    if objItem.CacheTotalHitRatio_Base != None:
        print "CacheTotalHitRatio_Base:" + ` objItem.CacheTotalHitRatio_Base`
    if objItem.CacheTotalHits != None:
        print "CacheTotalHits:" + ` objItem.CacheTotalHits`
    if objItem.CacheTotalMisses != None:
        print "CacheTotalMisses:" + ` objItem.CacheTotalMisses`
    if objItem.CacheTotalTurnoverRate != None:
        print "CacheTotalTurnoverRate:" + ` objItem.CacheTotalTurnoverRate`
    if objItem.Caption != None:
        print "Caption:" + ` objItem.Caption`
    if objItem.CompilationsTotal != None:
        print "CompilationsTotal:" + ` objItem.CompilationsTotal`
    if objItem.DebuggingRequests != None:
        print "DebuggingRequests:" + ` objItem.DebuggingRequests`
    if objItem.Description != None:
        print "Description:" + ` objItem.Description`
    if objItem.ErrorsDuringCompilation != None:
        print "ErrorsDuringCompilation:" + ` objItem.ErrorsDuringCompilation`
    if objItem.ErrorsDuringExecution != None:
        print "ErrorsDuringExecution:" + ` objItem.ErrorsDuringExecution`
    if objItem.ErrorsDuringPreprocessing != None:
        print "ErrorsDuringPreprocessing:" + ` objItem.ErrorsDuringPreprocessing`
    if objItem.ErrorsTotal != None:
        print "ErrorsTotal:" + ` objItem.ErrorsTotal`
    if objItem.ErrorsTotalPerSec != None:
        print "ErrorsTotalPerSec:" + ` objItem.ErrorsTotalPerSec`
    if objItem.ErrorsUnhandledDuringExecution != None:
        print "ErrorsUnhandledDuringExecution:" + ` objItem.ErrorsUnhandledDuringExecution`
    if objItem.ErrorsUnhandledDuringExecutionPerSec != None:
        print "ErrorsUnhandledDuringExecutionPerSec:" + ` objItem.ErrorsUnhandledDuringExecutionPerSec`
    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.Name != None:
        print "Name:" + ` objItem.Name`
    if objItem.OutputCacheEntries != None:
        print "OutputCacheEntries:" + ` objItem.OutputCacheEntries`
    if objItem.OutputCacheHitRatio != None:
        print "OutputCacheHitRatio:" + ` objItem.OutputCacheHitRatio`
    if objItem.OutputCacheHitRatio_Base != None:
        print "OutputCacheHitRatio_Base:" + ` objItem.OutputCacheHitRatio_Base`
    if objItem.OutputCacheHits != None:
        print "OutputCacheHits:" + ` objItem.OutputCacheHits`
    if objItem.OutputCacheMisses != None:
        print "OutputCacheMisses:" + ` objItem.OutputCacheMisses`
    if objItem.OutputCacheTurnoverRate != None:
        print "OutputCacheTurnoverRate:" + ` objItem.OutputCacheTurnoverRate`
    if objItem.PipelineInstanceCount != None:
        print "PipelineInstanceCount:" + ` objItem.PipelineInstanceCount`
    if objItem.RequestBytesInTotal != None:
        print "RequestBytesInTotal:" + ` objItem.RequestBytesInTotal`
    if objItem.RequestBytesOutTotal != None:
        print "RequestBytesOutTotal:" + ` objItem.RequestBytesOutTotal`
    if objItem.RequestsExecuting != None:
        print "RequestsExecuting:" + ` objItem.RequestsExecuting`
    if objItem.RequestsFailed != None:
        print "RequestsFailed:" + ` objItem.RequestsFailed`
    if objItem.RequestsInApplicationQueue != None:
        print "RequestsInApplicationQueue:" + ` objItem.RequestsInApplicationQueue`
    if objItem.RequestsNotAuthorized != None:
        print "RequestsNotAuthorized:" + ` objItem.RequestsNotAuthorized`
    if objItem.RequestsNotFound != None:
        print "RequestsNotFound:" + ` objItem.RequestsNotFound`
    if objItem.RequestsPerSec != None:
        print "RequestsPerSec:" + ` objItem.RequestsPerSec`
    if objItem.RequestsSucceeded != None:
        print "RequestsSucceeded:" + ` objItem.RequestsSucceeded`
    if objItem.RequestsTimedOut != None:
        print "RequestsTimedOut:" + ` objItem.RequestsTimedOut`
    if objItem.RequestsTotal != None:
        print "RequestsTotal:" + ` objItem.RequestsTotal`
    if objItem.SessionsAbandoned != None:
        print "SessionsAbandoned:" + ` objItem.SessionsAbandoned`
    if objItem.SessionsActive != None:
        print "SessionsActive:" + ` objItem.SessionsActive`
    if objItem.SessionSQLServerconnectionstotal != None:
        print "SessionSQLServerconnectionstotal:" + ` objItem.SessionSQLServerconnectionstotal`
    if objItem.SessionStateServerconnectionstotal != None:
        print "SessionStateServerconnectionstotal:" + ` objItem.SessionStateServerconnectionstotal`
    if objItem.SessionsTimedOut != None:
        print "SessionsTimedOut:" + ` objItem.SessionsTimedOut`
    if objItem.SessionsTotal != None:
        print "SessionsTotal:" + ` objItem.SessionsTotal`
    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.TransactionsAborted != None:
        print "TransactionsAborted:" + ` objItem.TransactionsAborted`
    if objItem.TransactionsCommitted != None:
        print "TransactionsCommitted:" + ` objItem.TransactionsCommitted`
    if objItem.TransactionsPending != None:
        print "TransactionsPending:" + ` objItem.TransactionsPending`
    if objItem.TransactionsPerSec != None:
        print "TransactionsPerSec:" + ` objItem.TransactionsPerSec`
    if objItem.TransactionsTotal != None:
        print "TransactionsTotal:" + ` objItem.TransactionsTotal`