|
我写了个脚本 可以监控25 110 的状况,但是就不知道怎样获取“待发邮件数”,
有谁知道WinWebMail 的 adminmsg 目录下的statistics.txt文件中的各个数值的意思?
'Dim Path, LogFile
Path = "D:\test\"
LogFile = Date & "_Port.htm"
Function strText(Text, style)
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase= True
regEx.Pattern = "CLOSE_WAIT"
If regEx.Test(text) Then
Select Case style
Case "SMTP"
strText = "<td>25 端口 CLOSE_WAIT</td>"
Case "POP3"
strText = "<td>110端口 CLOSE_WAIT</td></tr>"
End Select
Else
Select Case style
Case "SMTP"
strText = "<td>25 端口正常</td>"
Case "POP3"
strText = "<td>110端口正常</td></tr>"
End Select
End If
End Function
strComputer= "."
Set objSWbemServices = GetObject("Winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetwork = objSWbemServices.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetworkConf in colNetwork
If Not IsNull(objNetworkConf.IPAddress) And Not IsNull(objNetworkConf.DefaultIPGateway) And Not IsNull(objNetworkConf.DNSServerSearchOrder) Then
IPPortSMTP = objNetworkConf.IPAddress(0) & ":25 "
IPPortPOP3 = objNetworkConf.IPAddress(0) & ":110 "
End If
Next
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objStartup = objSWbemServices.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = 12
Set objProc = objSWbemServices.Get("Win32_Process")
dtmTime = "<tr><td>" & Time & "</td>"
objProc.Create "cmd /c Netstat -n |Find """ & IPPortSMTP & """ > " & Path & "PortTemp.txt", Null, objConfig, pingPID
Set colProcess = objSWbemServices.ExecNotificationQuery("Select * From __InstanceDeletionEvent WithIn 1 Where TargetInstance ISA 'Win32_Process'")
Do Until c = 999
Set objProErr = colProcess.NextEvent
If objProErr.TargetInstance.ProcessID = pingPID Then
Exit Do
End If
Loop
Set tf1 = FSO.OpenTextFile(Path & "PortTemp.txt", 1)
Do Until tf1.AtEndOfStream
strNextLine1 = tf1.ReadLine
If Len(strNextLine1) > 0 Then
strLine1 = strNextLine1
End If
Loop
tf1.Close
SMTP = strText(strLine1, "SMTP")
objProc.Create "cmd /c Netstat -n |Find """ & IPPortPOP3 & """ > " & Path & "PortTemp.txt", Null, objConfig, pingPID
Set colProcess = objSWbemServices.ExecNotificationQuery("Select * From __InstanceDeletionEvent Within 1 Where TargetInstance ISA 'Win32_Process'")
Do Until c = 999
Set objProErr = colProcess.NextEvent
If objProErr.TargetInstance.ProcessID = pingPID Then
Exit Do
End If
Loop
Set tf2 = FSO.OpenTextFile(Path & "PortTemp.txt", 1)
Do Until tf2.AtEndOfStream
strNextLine2 = tf2.ReadLine
If Len(strNextLine2) > 0 Then
strLine2 = strNextLine2
End If
Loop
tf2.Close
POP3 = strText(strLine2, "POP3")
On Error Resume Next
Set tf3 = fso.CreateTextFile(Path & LogFile, False)
ErrNumber = Err.Number
tf3.WriteLine "<html><head><style><!--body,td{ font-family: 宋体; font-size: 9pt }--></style></head><body topmargin=0 leftmargin=0></b><table border cellspacing=0.1><tr><td>时间</td><td>端口25状态</td><td>端口110状态</td></tr>"
tf3.WriteLine dtmTime & SMTP & POP3
tf3.Close
On Error GoTo 0
If ErrNumber = 58 Then
Set tf4 = fso.OpenTextFile(Path & LogFile, 8)
tf4.WriteLine dtmTime & SMTP & POP3
tf4.Close
End If |
|