[THIN] Re: tool to restart a service if it's memory usage gets over a certai n amount

  • From: "Callahan, Michael (TICS)" <MichaelCallahan@xxxxxxxxxxxxxxxx>
  • To: "thin@xxxxxxxxxxxxx" <thin@xxxxxxxxxxxxx>
  • Date: Wed, 2 Feb 2005 11:42:03 -0600

Quick and dirty:
 
Set up monitoring of memory in RM, if you haven't already done so.  Set your
thresholds for available memory.   Then configure RM to run the script below
on your servers when they go to Red status:
 
On Error Resume Next
Const DeleteReadOnly = True
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oWshSysEnv = oShell.Environment("Process")
vbQuote = """"
 
'Get Script Path
sScriptFullName = WScript.ScriptFullName
sScriptPath = Left(sScriptFullName, InStrRev(sScriptFullName, "\"))
sSysroot = oWshSysEnv("SYSTEMROOT")
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
        ("Select * from Win32_Service")
For Each objService in colListOfServices
If objService.Name = "spooler" Then
 If objService.Started = TRUE Then
 objService.StopService()
 End If
End If
Next
 
Set colListOfServices = objWMIService.ExecQuery _
        ("Select * from Win32_Service")
For Each objService in colListOfServices
If objService.Name = "spooler" Then
 If objService.Started = FALSE Then
 objService.StartService()
 End If
End If
Next
 
This assumes that your spool service is the only process with a memory leak.
You'll need to either place this file on each server in your farm or run it
from a central location substituting the server name for "." in setting
strComputer = "."
Don't know how familiar you are with scripting, but this should give you a
starting point to build on, I hope.
 
I would then put in a call to MS to find out why this is happening.

-----Original Message-----
From: Stratton, Doug MSER:EX [mailto:Doug.M.Stratton@xxxxxxxxxxxxxxx]
Sent: Wednesday, February 02, 2005 11:19 AM
To: 'thin@xxxxxxxxxxxxx'
Subject: [THIN] tool to restart a service if it's memory usage gets over a
certai n amount


Anyone know of such a thing?
 
Might even be able to do it with a script.???
 
This is on windows 2000 that I need it.
 
Reason is for some reason our print spooler service is bloating up (don't
know why) and using 100,000K of memory.  
 
I can't figure out what is going on so I want to put something in place that
restarts the service if this happens.
 
Thanks  As usual free would be nice.
 
bye
 

Doug Stratton
Telephone: (250) 356-6678 
Email: Doug.M.Stratton@xxxxxxxxxxxxxxx 

 

**********    Confidentiality Notice    **********
This electronic transmission and any attached documents or other
writings are confidential and are for the sole use of the intended
recipient(s) identified above. This message may contain information
that is privileged, confidential or otherwise protected from disclosure
under applicable law. If the receiver of this information is not the
intended recipient, or the employee, or agent responsible for delivering
the information to the intended recipient, you are hereby notified that
any use, reading, dissemination, distribution, copying or storage of this
information is strictly prohibited. If you have received this information in
error, please notify the sender by return email and delete the electronic
transmission, including all attachments from your system.

Other related posts: