Hi,
I have many process with the same name (USERVER.EXE) on a distant machine (only RMA can be done). I look for a solution to can monitor the % of processor used by this process, since I can have a dead process that consume a lot of processor memory. I have found the following link on Google and code and would like to know how I can put it on Hostmonitor.
http://groups.google.com/groups?q=CPU%2 ... a=N&tab=wg
Thanks for your help.
Alan
'Get % Processor Time for a process
'Connect to Local Machine
set wmi_service =
GetObject("winmgmts:{impersonationlevel=impersonate}!\root\cimv2")
sObjectPath = "Win32_PerfRawData_PerfProc_Process.Name=" & chr(34) &
"taskmgr" & chr(34)
wscript.echo sObjectPath
set perf_instance1 = wmi_service.get( sObjectPath )
N1 = perf_instance1.PercentProcessorTime
D1 = perf_instance1.TimeStamp_Sys100NS
while true
'Sleep for one second = 1000 ms
wscript.sleep(1000)
set perf_instance2 = wmi_service.get( sObjectPath )
N2 = perf_instance2.PercentProcessorTime
D2 = perf_instance2.TimeStamp_Sys100NS
' CounterType - PERF_100NSEC_TIMER
' Formula = ((N2 - N1) / (D2 - D1)) x 100
if ( 0 = (D2-D1) ) then
wscript.echo "divide by zero"
else
PercentProcessorTime = ((N2 - N1) / (D2 - D1)) * 100
wscript.echo "% Processor Time = " , PercentProcessorTime
end if
N1 = N2
D1 = D2
wend
set wmi_service = nothing
WMI and Time processor for a process
1) If you want to use script with HostMonitor, please follow certain rules. Rules described in the manual.
Active scripts: http://www.ks-soft.net/hostmon.eng/mfra ... htm#script
Shell script: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
2) Truth to say I do not understand why do you need this script. HostMonitor provides 2 test methods that should suit your needs: Performance Counter and WMI
Regards
Alex
Active scripts: http://www.ks-soft.net/hostmon.eng/mfra ... htm#script
Shell script: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
2) Truth to say I do not understand why do you need this script. HostMonitor provides 2 test methods that should suit your needs: Performance Counter and WMI
Regards
Alex
WMI test allows you to check several instances
http://www.ks-soft.net/hostmon.eng/mfra ... ts.htm#wmi
Regards
Alex
http://www.ks-soft.net/hostmon.eng/mfra ... ts.htm#wmi
Regards
Alex