Rowan Hawkins
asked on
Help automating a script to restart a service
Hello,
I have a server(2003 std) across town which has a memory leak in one of its services. The company who makes the application says the fix is to Disable AV scanning. I am not enthused about that.
I have found a work arround where I can monitor the Service from remotely and then manually restart it when the memory usage exceeds a threshold. Until now I have been using two tools from www.systeminternals.com to do this. I use "pslist.exe SERVICE" to poll the service every 5 seconds and once the PRIV memory field exceeds 500M I restart it from remote with the other tool "psservice.exe restart SERVICE" then it is fine untill I next have to bounce it again.
I can't keep manually doing it, because if I miss, someone (usually my boss) gets to drive across town to reboot it. If it isn't caught, all avalable memory is used and no one can log into the box remotely to kick start the service.
My End Goal and how I will award the points is a solution that automaticly restarts the service any time the service exceeds the memory threshold. The goal is a working solution. I would prefer something that uses Windows standard applications but that isnt a necessity. If you can figure a way to trigger my existing script that is fine too.
Thank you,
rjhawkin
I have a server(2003 std) across town which has a memory leak in one of its services. The company who makes the application says the fix is to Disable AV scanning. I am not enthused about that.
I have found a work arround where I can monitor the Service from remotely and then manually restart it when the memory usage exceeds a threshold. Until now I have been using two tools from www.systeminternals.com to do this. I use "pslist.exe SERVICE" to poll the service every 5 seconds and once the PRIV memory field exceeds 500M I restart it from remote with the other tool "psservice.exe restart SERVICE" then it is fine untill I next have to bounce it again.
I can't keep manually doing it, because if I miss, someone (usually my boss) gets to drive across town to reboot it. If it isn't caught, all avalable memory is used and no one can log into the box remotely to kick start the service.
My End Goal and how I will award the points is a solution that automaticly restarts the service any time the service exceeds the memory threshold. The goal is a working solution. I would prefer something that uses Windows standard applications but that isnt a necessity. If you can figure a way to trigger my existing script that is fine too.
Thank you,
rjhawkin
hi,
you could set performance monitor to poll availible memory and run net stop/start <service> to do restart to your faulty service:
Administrative Tools -> Performance -> Perf. Logs and Alerts -> add new Alert
Select Performance object "Memory" and counter Available Bytes/KBytes/MBytes (select which you like), Alert when the value is Under, Limit: <you choose>, Poll as you like (interval 5 mins, etc.)
Create batch file with commands:
net stop <yourservice>
net start <yourservice>
Set Action "Run this program" and set the command line to "C:\yourpath\yourbatchfile .cmd" (or what ever it is).
With this, when ever the availible memory is too low the service is restarted.
Hope this helps,
-A
you could set performance monitor to poll availible memory and run net stop/start <service> to do restart to your faulty service:
Administrative Tools -> Performance -> Perf. Logs and Alerts -> add new Alert
Select Performance object "Memory" and counter Available Bytes/KBytes/MBytes (select which you like), Alert when the value is Under, Limit: <you choose>, Poll as you like (interval 5 mins, etc.)
Create batch file with commands:
net stop <yourservice>
net start <yourservice>
Set Action "Run this program" and set the command line to "C:\yourpath\yourbatchfile
With this, when ever the availible memory is too low the service is restarted.
Hope this helps,
-A
ASKER
The problem with that is that memory can get low when SQL is running but then is released correctly. I dont want to have this service restarted a bunch of times when it isn't needed. Every time the service is restarted all of the users have to log in again. Also during the time it is restarting it isnt doing what we need it to be doing.
Windows doesnt seem to keep track of individual apps in any meaningful way that I can find.
Windows doesnt seem to keep track of individual apps in any meaningful way that I can find.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks robberbaron,
I'll give this a shot later this week and see how it works. Monday(tuesday) is always a day of putitng out the fires that came up over the weekend.
I'll give this a shot later this week and see how it works. Monday(tuesday) is always a day of putitng out the fires that came up over the weekend.
ASKER
I just wanted to give an update, I didnt get to this last week and I am trying for this week.
ASKER
robberbaron, just a quick question.. the script file wants to have a .WSH extension correct?
No. I generally use .VBS This is automatically associated with WSCRIPT.exe pr CSCRIPT.exe depending upon wether it is run from with Windows or commandline respectively.
I think WSH does extra un-necessary things.
1/ Try running it on your own PC, using the SNMP service as a test.
2/ try running it on the remote server, using snmp as test as this is not usually a critical service.
3/ what is the contents of psm_data.txt ?
I think WSH does extra un-necessary things.
1/ Try running it on your own PC, using the SNMP service as a test.
2/ try running it on the remote server, using snmp as test as this is not usually a critical service.
3/ what is the contents of psm_data.txt ?
ASKER
that was my mistake, I'll Award RobberBarron the A the script worked perfectly.
ASKER
I can access the box any time to test solutions providing Im awake.