Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

monitor the w3wp.exe process and perform iisreset

Status
Not open for further replies.

cantina

MIS
Aug 30, 2004
14
US
hi,

i'm trying to tweak to create a script to automatically restart the w3wp.exe process once it reaches 90% cpu utilization.

there is a script that would monitor an application pool (adsutil.vbs) and shutdown the process once it reaches a certain cpu level, but was wondering if this could be tweaked in any way:

adsutil.vbs set W3SVC/AppPools/ApplicationPoolName/CPUAction ActionValue

 
wmi query or wmi event notification (async, blocking method call etc) is how i would approach it.

 
here is what i have. this is working, but when i log out of the server, the wscript.exe process stops, thus the script stops. Is there any way to continously run this script independently of being logged in? Or will i have to find a way to run this as a service?

Dim FSO, LogFile, Age, WshShell
set WshShell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set w3wplog = fso_OpenTextFile("c:\logs\w3wpexe.log", 8, True)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.Swbemrefresher")
Set objProcessor = objRefresher.AddEnum _
(objWMIService, "Win32_PerfFormattedData_PerfOS_Processor").objectSet
intThresholdViolations = 0
objRefresher.Refresh
Do
For Each intProcessorUse in objProcessor
If intProcessorUse.PercentProcessorTime > 35 Then
intThresholdViolations = intThresholdViolations + 1
If intThresholdViolations = 3 Then
intThresholdViolations = 0
WshShell.run ("c:\windows\system32\iisreset.exe")
w3wplog.writeLine file & " W3Wp.exe Process restarted on" &" "& date & "," & " " & time
End If
Else
intThresholdViolations = 0
End If
Next
Wscript.Sleep 10000
objRefresher.Refresh
Loop
set WshShell = nothing
 
Have you tried to made it a startup script ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top