Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > vb script to monitor process memory usage

Reply
Thread Tools Display Modes

vb script to monitor process memory usage

 
 
Dee
Guest
Posts: n/a

 
      10-06-2009
Hi

I want to monitor a particular process for private bytes which I can see is
the amount of memory it is using, however I cannot find the object to use.

I have the below, but it does not give the object i want

any ideas?, thanks

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")

For Each objProcess in colProcessList
Wscript.Echo "Process: " & objProcess.Name
Wscript.Echo "Process ID: " & objProcess.ProcessID
Wscript.Echo "Thread Count: " & objProcess.ThreadCount
Wscript.Echo "Page File Size: " & objProcess.PageFileUsage
Wscript.Echo "Page Faults: " & objProcess.PageFaults
Wscript.Echo "Working Set Size: " & objProcess.WorkingSetSize
Next
--
Dee
 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a

 
      10-06-2009

"Dee" <> wrote in message
news:9DD68F99-6776-402A-A80E-...
> Hi
>
> I want to monitor a particular process for private bytes which I can see
> is
> the amount of memory it is using, however I cannot find the object to use.
>
> I have the below, but it does not give the object i want
>
> any ideas?, thanks
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set colProcessList = objWMIService.ExecQuery("Select * from
> Win32_Process")
>
> For Each objProcess in colProcessList
> Wscript.Echo "Process: " & objProcess.Name
> Wscript.Echo "Process ID: " & objProcess.ProcessID
> Wscript.Echo "Thread Count: " & objProcess.ThreadCount
> Wscript.Echo "Page File Size: " & objProcess.PageFileUsage
> Wscript.Echo "Page Faults: " & objProcess.PageFaults
> Wscript.Echo "Working Set Size: " & objProcess.WorkingSetSize
> Next
> --
> Dee


Hard to say unless you tell us in what way your code fails to deliver.


 
Reply With Quote
 
Dee
Guest
Posts: n/a

 
      10-06-2009
No to worry I managed to sort it out with the below

' Get raw and cooked data performance counter instances for the
'wscript process running this script
on error resume next
dim strComputer, objWMIService, RawProc, processname, threshold

processname = "'xxx'"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set RawProc = GetObject("winmgmts:" _
& "Win32_PerfRawdata_Perfproc_process." _
& "name='xxx'")

Wscript.Echo "opcwbemi process raw PageFaultsPerSec = " _
& RawProc.PrivateBytes
threshold = RawProc.PrivateBytes

if RawProc.PrivateBytes > "50000000" then
wscript.echo "threshold breached"
end if

set objWMIService = nothing
set RawProc = nothing
--
Dee


"Pegasus [MVP]" wrote:

>
> "Dee" <> wrote in message
> news:9DD68F99-6776-402A-A80E-...
> > Hi
> >
> > I want to monitor a particular process for private bytes which I can see
> > is
> > the amount of memory it is using, however I cannot find the object to use.
> >
> > I have the below, but it does not give the object i want
> >
> > any ideas?, thanks
> >
> > strComputer = "."
> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> >
> > Set colProcessList = objWMIService.ExecQuery("Select * from
> > Win32_Process")
> >
> > For Each objProcess in colProcessList
> > Wscript.Echo "Process: " & objProcess.Name
> > Wscript.Echo "Process ID: " & objProcess.ProcessID
> > Wscript.Echo "Thread Count: " & objProcess.ThreadCount
> > Wscript.Echo "Page File Size: " & objProcess.PageFileUsage
> > Wscript.Echo "Page Faults: " & objProcess.PageFaults
> > Wscript.Echo "Working Set Size: " & objProcess.WorkingSetSize
> > Next
> > --
> > Dee

>
> Hard to say unless you tell us in what way your code fails to deliver.
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE7 process memory usage Perry Diels Internet Explorer 7 06-29-2007 10:25 AM
Monitor the CPU Usage of the Process and terminate the process Enjoy Scripting Scripting 0 12-12-2004 10:07 PM
Monitor kernel process/thread CPU usage? Hannes Windows Vista Drivers 2 10-02-2004 10:55 AM
Log CPU & Memory usage of a process Bob Scripting 1 06-01-2004 06:54 PM
SQL process just keeps growing in memory usage Michael Windows Small Business Server 1 04-07-2004 02:53 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59