我创建了一个用经典ASP编写的服务器监控脚本(托管在IIS 7.5上)。
它有一个主页,使用jQuery自动重新加载内容(更新WMI信息)。它工作得很好,但似乎对内存很有兴趣!
共有4个页面(2台服务器的服务状态、主DC上的打印机状态和同一服务器上的磁盘使用情况)。服务状态页面每10秒更新一次,打印机每5秒更新一次,磁盘使用情况每分钟更新一次。
该脚本基本上可以工作几个小时,然后我得到代码500的内部服务器错误,一旦检查IIS,由于它“内存不足”而记录它,并查看服务器上的进程,WmiPrvSvc.exe(网络服务帐户)有数百个(500mb),ISS工作进程(w3wp.exe)使用了大约50mb(还有其他w3ps.exe进程更高)
一旦我结束了它们,它就会重新开始工作。或者,如果我停止页面/请求一段时间(在30秒到5分钟之间变化),WmiPrvScs就会结束,我就没有问题了。
有没有办法最大限度地减少内存使用,或者有没有命令正确断开/清除内存?
以下是
基础知识
我的一页,让你了解发生了什么。。。
谢谢,保罗。
<%
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("SELECT Caption, Started FROM Win32_Service WHERE StartMode = 'Auto'")
Set arrServices = Server.CreateObject("System.Collections.ArrayList")
intServices = colListOfServices.Count
For Each objService in colListOfServices
arrServices.Add objService.Caption & "@" & objService.Started
Next
arrServices.Sort()
Response.Write "<table width=""100%"" class=""tblServices"">" & vbCr
For Each strService in arrServices
If InStr(strService, ".NET Framework") = 0 AND InStr(strService, "Sophos Web Intelligence Update") = 0 AND InStr(strService, "Shell Hardware Detection") = 0 Then
' Above services, start at system startup and then stop after nothing to do
arrServiceDetails = Split(strService, "@")
strServiceName = arrServiceDetails(0)
strServiceStatus = arrServiceDetails(1)
End If
Next
Response.Write "</table>"
Set objWMIService = Nothing
Set colListOfServices = Nothing
Set arrServices = Nothing
%>