Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Stopping Service when Memory reaches 2 GB

Reply
Thread Tools Display Modes

Stopping Service when Memory reaches 2 GB

 
 
FB
Guest
Posts: n/a

 
      07-06-2009


We have an App and when it reaches 2 GB of RAM begins to behaviour erractly.
The only solutions is to restar the corresponding service and everything is
fine again. It´s a Leaky App and te deveoper know about and don´t do anything
about it.

We need to create a Script to:

1) Check if the the APP is "eating" all memory (2 GB is the limit, so,
monitoring when the App reaches 1.7 GB of RAM, it´s fine)

2) If so, we need to test if someone is connected (netstat -na | find
":1443" does the Job)

3) If nobody is connected, the Service can be restarted.


Wich "language" is more suitable for this?

Batch? VBS/WMI? PowerShell?

Batch can use neststat, find, tasklist and sc/net

PowerSchell can use Get-Service and Stop-Service to to the Job, but theres
no ways to obtain the "netstat" info to decide if the service can be
restarted.


VBS/WMI is very complex of rmy skills...

Someone can help me?


 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a

 
      07-06-2009


"FB" <> wrote in message
news:3692CEA5-9D49-446C-8DE1-...
>
> We have an App and when it reaches 2 GB of RAM begins to behaviour
> erractly.
> The only solutions is to restar the corresponding service and everything
> is
> fine again. It´s a Leaky App and te deveoper know about and don´t do
> anything
> about it.
>
> We need to create a Script to:
>
> 1) Check if the the APP is "eating" all memory (2 GB is the limit, so,
> monitoring when the App reaches 1.7 GB of RAM, it´s fine)
>
> 2) If so, we need to test if someone is connected (netstat -na | find
> ":1443" does the Job)
>
> 3) If nobody is connected, the Service can be restarted.
>
>
> Wich "language" is more suitable for this?
>
> Batch? VBS/WMI? PowerShell?
>
> Batch can use neststat, find, tasklist and sc/net
>
> PowerSchell can use Get-Service and Stop-Service to to the Job, but theres
> no ways to obtain the "netstat" info to decide if the service can be
> restarted.
>
>
> VBS/WMI is very complex of rmy skills...
>
> Someone can help me?
>


I would use a batch file, e.g. something like this:
@echo off
set app=Firefox
for /F "tokens=5" %%a in ('tasklist.exe ^| find /i "%app%"') do set mem=%%a
set mem=000000000%mem:,=%
if %mem:~-12% GTR 000001700000 goto :eof
netstat . . .
net stop . . .
net start . . .


 
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
Re: IE 7 and XP Pro SP3 IE using all memory, stopping system Mesuri Internet Explorer 0 05-05-2009 03:56 PM
Service Stopping tshad Windows Server 3 10-03-2008 10:10 PM
Re: Fax Service Keeps Stopping Itself - Please Help!!! Jevgenij Martynenko Windows Small Business Server 0 07-08-2007 02:10 PM
DNS service stopping David DNS Server 1 01-25-2006 01:14 PM
Allocated Memory Alerts, Services Randomly Stopping ChipW Windows Small Business Server 7 02-24-2005 06:49 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