WMI and Time processor for a process

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
a.falanga
Posts: 9
Joined: Mon Mar 06, 2006 6:18 am

WMI and Time processor for a process

Post by a.falanga »

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
Yoorix
Posts: 177
Joined: Wed Dec 14, 2005 8:28 am

Post by Yoorix »

You can save that code into .vbs file and create new "Active Script Test".

Regards,
Yoorix
a.falanga
Posts: 9
Joined: Mon Mar 06, 2006 6:18 am

Post by a.falanga »

I have already try and this doesn't works :(

Alan
Yoorix
Posts: 177
Joined: Wed Dec 14, 2005 8:28 am

Post by Yoorix »

Are you able to run this script independently, without HM? E.g. type in command line "cscript your_script_name.vbs".

Regards,
Yoorix
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

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
a.falanga
Posts: 9
Joined: Mon Mar 06, 2006 6:18 am

Post by a.falanga »

I want to can monitor fall all process that was named : userver.exe there memory consumation and there CPU usage. I can't find a way to do this easily with the current WMI or active script ... perhaps I miss something.

I have not ONE process called userver.exe but many ...

Any idea ?

Alan
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

WMI test allows you to check several instances
http://www.ks-soft.net/hostmon.eng/mfra ... ts.htm#wmi

Regards
Alex
Post Reply