WMI and Perfmon discrepancy
Hi all, I am writing a monitoring script for my IIS servers. I want to display the memory and CPU consuption by application pool. My script receives the AppPool name as input and returns the values I need using WMI. The problem is that the values I receive from my script are completely different from the ones I have on Perfmon or TaskManager. I am using the Win32_Process and Win32_PerfFormattedData_PerfOS_Processor classes. I am using the % processor time property to retrieve the information. If you need more information please let me know. Best regards, Igor
September 28th, 2010 12:05pm

I just would like to add some information on this. On my script I can easily see the values reach 100% while on Perfmon the spikes never reach the 100% line for the processes I am monitoring. The values can also bee seen on a tool that I use to query WMI classes. In case it helps, below is the code I am running: Dim apoolID, PID Dim oProviderObj Dim W3WPList, W3WP Dim strPoolName Dim Matches, Submatches Dim re Dim argObj Dim ValorPerf Dim pidfound Dim objRefresher Dim objItem, colitems Dim MsgRetorno Set argObj = WScript.Arguments strPoolName = argObj(1) Err.Clear 'checa se o app pool existe dim objAppPools, objAppPoolSet, PoolEncontrado set objAppPools = GetObject("IIS://localhost/W3SVC/AppPools") for Each objAppPool in objAppPools If strPoolName = objAppPool.Name then PoolEncontrado = 1 End If Next If PoolEncontrado <> 1 Then ValorPerf = -1 MsgRetorno = "Application Pool não existe" else Set oProviderObj = GetObject("winmgmts://localhost/root/cimv2") Set W3WPList = oProviderObj.ExecQuery("select * from Win32_Process where Name='w3wp.exe'") ValorPerf=0 pidfound=-0 For Each W3WP In W3WPList Set re = New RegExp re.Pattern = "-ap ""(.+)""" re.IgnoreCase = True Set Matches = re.Execute(W3WP.CommandLine) Set SubMatches = Matches(0).Submatches If (UCase(Submatches(0)) = UCase(strPoolName)) Then Set objRefresher = CreateObject("WbemScripting.SWbemRefresher") Set colItems = objRefresher.AddEnum(oProviderObj, "Win32_PerfFormattedData_PerfProc_Process").objectSet objRefresher.Refresh Wscript.Sleep 300 objRefresher.Refresh For Each objItem in colItems If objItem.IDProcess = W3WP.ProcessID Then ValorPerf=objItem.PercentProcessorTime Next pidfound = W3WP.ProcessId End If Next If PidFound = 0 then MsgRetorno = "Nao ha nenhum processo W3WP.exe sendo executado para esse Application Pool!" ValorPerf = 0 Else Msgretorno = "Nome: " & strPoolName & " PID: " & pidfound End If End If 'sending output on the propper format for my application Wscript.Echo "<ED>" & ValorPerf & "</ED>" Wscript.Echo "<ECO>" & MsgRetorno & "</ECO>" Wscript.Echo "<ECE></ECE>" WScript.Quit
Free Windows Admin Tool Kit Click here and download it now
September 28th, 2010 12:58pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics