2014-10-23 5 views
1

당신이 잘 지내기를 바랍니다.SELECT PercentTimeinGC FR32 Win32_PerfRawData_NETFramework_NETCLRMemory

목표 :

환경 IIS 7 작업자 프로세스 가든 (4) (ASP .NET4.0 앱 "GC에 .NET CLR 메모리/% 시간"= 성능 모니터에 도시 된 바와 같이, Win32_PerfRawData_NETFramework_NETCLRMemory PercentTimeinGC FROM WMI 데이터를 추출 풀) (4xw3wp.exe 프로세스)

이야기 : 로컬 perfmon에서 w3wp.exe의 4 인스턴스가 가비지 수집에 사용하는 시간을 로컬에서 모니터링 할 수 있으며이 데이터를 PRTG 또는 집에서 만든 외부 모니터링으로 내보내려고합니다 워치 독 소프트웨어.

그물을 검색하고 wql 스크립트와 WMI 쿼리에 대해 배우면 우리는 이것이 간단 할 것이라고 생각하게 만듭니다. 그러나 이것은 사실이 아닙니다.

"SELECT PercentTimeinGC FROM Win32_PerfRawData_NETFramework_NETCLRMemory"문을 추가하면 wmi 테스트 도구 나 스크립트에 관계없이 항상 "0"값을 반환하지만 다른 문을 검색하는 데는 올바른 문이 여러 번 표시됩니다.

그래서 우리는 뭔가를 놓치고 있거나 단순히 믿을 수 없다. 여기

희망의 사람이 우리의 짧은 commings ;-)

감사의 우리를 계몽하고, 좋은 하루 수 있습니다.

마이크

답변

0

이 코드는 코드를 사용합니다. 이것은 splunk가 섭취하도록 만들어졌습니다.

On Error Resume Next 

Set objWMISvc = GetObject("winmgmts:\\.\root\cimv2") 
Set colItems = objWMISvc.ExecQuery("Select * from Win32_ComputerSystem", , 48) 
For Each objItem in colItems 
    strComputerName = objItem.Name 
Next 

CommandLine = "c:\windows\system32\inetsrv\w3wp.exe" 
processName = "w3wp.exe" 

QueryLine = "select * from win32_process where Name = " & """" & processName & """" 
Computer = "." 
Set WMIService = GetObject("winmgmts:\\" & Computer & "\root\cimv2") 
Set Items = WMIService.ExecQuery(QueryLine, , 48) 
For Each SubItems In Items 

If inStr(SubItems.CommandLine, "0") Then 
    WScript.Echo "New Event:" 
    w3wpRunningCount = w3wpRunningCount + 1 
    WScript.Echo "CommandLine=" & SubItems.CommandLine 
    creationdate = SubItems.CreationDate 
    creationyear = Left(creationdate, 4) 
    creationmonth = Mid(creationdate, 5, 2) 
    creationday = Mid(creationdate, 7, 2) 


    WScript.Echo "CreationDate=" & creationmonth & "-" & creationday & "-" & creationyear 
    WScript.Echo "ProcessId=" & SubItems.ProcessId 
    WScript.Echo "ThreadCount=" & SubItems.ThreadCount 
    WScript.Echo "WorkingSetSizeMbytes=" & SubItems.WorkingSetSize/1024/1024 
    WScript.Echo "PeakWorkingSetSizeMbytes=" & SubItems.PeakWorkingSetSize/1024 
    WScript.Echo "PageFaults=" & SubItems.PageFaults 
    WScript.Echo "EstAddedLatencyInSec=" & SubItems.PageFaults*8/1000 
    WScript.Echo "PageFileUsageMbytes=" & SubItems.PageFileUsage/1024 
    WScript.Echo "PeakPageFileUsageMbytes=" & SubItems.PeakPageFileUsage/1024 

checkProcessorTime(SubItems.ProcessId) 
     getclrmemoryobjectproperties(SubItems.ProcessId) 
     getclrexceptionsobjects(objectName) 
     getclrjitobjects(objectName) 
     getclrlocksandthreadsobjects(objectName) 
     getclrinteropobjects(objectName) 
     getclrloadingobjects(objectName) 
     getdpforsqlobjects(SubItems.ProcessId) 

Next 
WScript.Echo "New Event:" 
wscript.Echo "w3wpRunningCount=" & w3wpRunningCount 
machineinterrogationstart() 


Function checkProcessorTime(PID) 
set objService = getobject("winmgmts:") 
Set objProcess = GetObject("winmgmts:{impersonationLevel=impersonate}//localhost") 
Set objItems = objProcess.ExecQuery("Select PercentProcessorTime from Win32_PerfFormattedData_PerfProc_Process where IDProcess=" &PID& "") 
for each objItem in objItems 
Wscript.Echo "PercentCPU=" & objItem.PercentProcessorTime 
Next 
End Function 

Function getclrmemoryobjectproperties(PID) 
    Set clrmemoryobjects = WMIService.ExecQuery("select * from win32_perfformatteddata_netframework_netclrmemory where ProcessId = " & """" & PID & """") 
    For Each clrmemoryobject in clrmemoryobjects 
    echo_out(clrmemoryobject.Name),"ProcessName" 
    echo_out(clrmemoryobject.AllocatedBytesPersec),"AllocatedBytesPersec" 
    echo_out(clrmemoryobject.FinalizationSurvivors),"FinalizationSurvivors" 
    echo_out(clrmemoryobject.Gen0heapsize),"Gen0heapsize" 
    echo_out(clrmemoryobject.Gen0PromotedBytesPerSec),"Gen0PromotedBytesPerSec" 
    echo_out(clrmemoryobject.Gen1heapsize),"Gen1heapsize" 
    echo_out(clrmemoryobject.Gen1PromotedBytesPerSec),"Gen1PromotedBytesPerSec" 
    echo_out(clrmemoryobject.Gen2heapsize),"Gen2heapsize" 
    echo_out(clrmemoryobject.LargeObjectHeapsize),"LargeObjectHeapsize" 
    echo_out(clrmemoryobject.NumberBytesinallHeaps),"NumberBytesinallHeaps" 
    echo_out(clrmemoryobject.NumberGCHandles),"NumberGCHandles" 
    echo_out(clrmemoryobject.NumberGen0Collections),"NumberGen0Collections" 
    echo_out(clrmemoryobject.NumberGen1Collections),"NumberGen1Collections" 
    echo_out(clrmemoryobject.NumberGen2Collections),"NumberGen2Collections" 
    echo_out(clrmemoryobject.NumberInducedGC),"NumberInducedGC" 
    echo_out(clrmemoryobject.NumberofPinnedObjects),"NumberofPinnedObjects" 
    echo_out(clrmemoryobject.NumberofSinkBlocksinuse),"NumberofSinkBlocksinuse" 
    echo_out(clrmemoryobject.NumberTotalcommittedBytes),"NumberTotalcommittedBytes" 
    echo_out(clrmemoryobject.NumberTotalreservedBytes),"NumberTotalreservedBytes" 
    echo_out(clrmemoryobject.PercentTimeinGC),"PercentTimeinGC" 
    echo_out(clrmemoryobject.PromotedFinalizationMemoryfromGen0),"PromotedFinalizationMemoryfromGen0" 
    echo_out(clrmemoryobject.PromotedMemoryfromGen0),"PromotedMemoryfromGen0" 
    echo_out(clrmemoryobject.PromotedMemoryfromGen1),"PromotedMemoryfromGen1" 
    objectName=clrmemoryobject.Name 
    Next 
End Function 

Function getclrexceptionsobjects(objectName) 
    Set clrexceptionsobjects = WMIService.ExecQuery("select * from win32_perfformatteddata_netframework_netclrexceptions where Name = " & """" & objectName & """") 
    For Each clrexceptionsobject in clrexceptionsobjects 
    echo_out(clrexceptionsobject.NumberofExcepsThrown),"NumberofExcepsThrown" 
    Next 
End Function 

Function getclrjitobjects(objectName) 
    Set clrjitobjects = WMIService.ExecQuery("select * from win32_perfformatteddata_netframework_netclrjit where Name = " & """" & objectName & """") 
    For Each clrjitobject in clrjitobjects 
    echo_out(clrjitobject.PercentTimeinJit),"PercentTimeinJit" 
    Next 
End Function 

Function getclrlocksandthreadsobjects(objectName) 
    Set clrlocksandthreadsobjects = WMIService.ExecQuery("select * from win32_perfformatteddata_netframework_netclrlocksandthreads where Name = " & """" & objectName & """") 
    For Each clrlocksandthreadsobject in clrlocksandthreadsobjects 
    echo_out(clrlocksandthreadsobject.NumberofcurrentlogicalThreads),"NumberofcurrentlogicalThreads" 
    echo_out(clrlocksandthreadsobject.NumberofcurrentphysicalThreads),"NumberofcurrentphysicalThreads" 
    echo_out(clrlocksandthreadsobject.CurrentQueueLength),"CurrentQueueLength" 
    echo_out(clrlocksandthreadsobject.ContentionRatePersec),"ContentionRatePersec" 
    Next 
End Function 

Function getclrinteropobjects(objectName) 
    Set clrinteropobjects = WMIService.ExecQuery("select * from win32_perfformatteddata_netframework_netclrinterop where Name = " & """" & objectName & """") 
    For Each clrinteropobject in clrinteropobjects 
    echo_out(clrinteropobject.NumberofStubs),"NumberofStubs" 
    Next 
End Function 

Function getclrloadingobjects(objectName) 
    Set clrloadingobjects = WMIService.ExecQuery("select * from win32_perfformatteddata_netframework_netclrloading where Name = " & """" & clrmemoryobject.Name & """") 
    For Each clrloadingobject in clrloadingobjects 
    echo_out(clrloadingobject.CurrentAssemblies),"CurrentAssemblies" 
    echo_out(clrloadingobject.RateofAssemblies),"RateofAssemblies" 
    echo_out(clrloadingobject.BytesinLoaderHeap),"BytesinLoaderHeap" 
    Next 
End Function 

Function getdpforsqlobjects(PID) 
    Set dpforsqlobjects = WMIService.ExecQuery("select * from win32_perfformatteddata_netdataproviderforsqlserver_netdataproviderforsqlserver where Name like " & """%" & PID & "%""") 
    For Each dpforsqlobject in dpforsqlobjects 
    echo_out(dpforsqlobject.NumberOfActiveConnections),"SQLNumberofActiveConnections" 
    echo_out(dpforsqlobject.NumberOfFreeConnections),"SQLNumberOfFreeConnections" 
    echo_out(dpforsqlobject.SoftConnectsPerSecond),"SQLSoftConnectsPerSecond" 
    Next 
End Function 

Function machineinterrogationstart() 
    getaspobjects() 
    getaspappobjects() 
End Function 

Function getaspobjects() 
    Set aspobjects = WMIService.ExecQuery("select * from win32_perfformatteddata_aspnet_aspnet") 
    for each aspobject in aspobjects 
    echo_out(aspobject.ApplicationRestarts),"ASPApplicationRestarts" 
    echo_out(aspobject.RequestExecutionTime),"ASPRequestExecutionTime" 
    echo_out(aspobject.RequestWaitTime),"ASPRequestWaitTime" 
    echo_out(aspobject.RequestsCurrent),"ASPRequestsCurrent" 
    echo_out(aspobject.WorkerProcessRestarts),"ASPWorkerProcessRestarts" 
    Next 
End Function 

Function getaspappobjects() 
    Set aspappobjects = WMIService.ExecQuery("select * from win32_perfformatteddata_aspnet_aspnetapplications") 
    for each aspappobject in aspappobjects 
    echo_out(aspappobject.CacheTotalHitRatio),"ASPAppCacheTotalHitRatio" 
    echo_out(aspappobject.CompilationsTotal),"ASPAppCompilationsTotal" 
    echo_out(aspappobject.ErrorsDuringExecution),"ASPAppErrorsDuringExecution" 
    echo_out(aspappobject.RequestsPerSec),"ASPAppRequestsPerSec" 
    Next 
End Function 

Function echo_out(propertyvalue,propertydescription) 
    wscript.echo propertydescription & "=" & propertyvalue 
End Function