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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBscript to Monitor Exchange 5.5 Message Queues

Status
Not open for further replies.

dillonjs

MIS
Aug 7, 2005
1
US
I am trying to find a way to monitor our Exchange 5.5 message queues using a VBscript, preferably with WMI or WSH. Exchange 5.5 running on Windows 2000 Server and all current service packs.

I am currently trying to use Activexperts Network Monitor Manager which has the feature in the form of a VBscript, but it errors out when ran. Unfortunately, the script errors out with "unable to list SMTP servers". Perhaps someone else could take a look at this function and tell me if it will even work on Exchange 5.5 or recommend an alternative method?

Thanks.

================SCRIPT==============

Function Query_Length_SMTPQueue( strComputer, numMaxQueueLength )
' This function checks if the local SMTP queuelength is not exceeding
' numMaxQueueLength.
' You should expect this figure to be fairly small, rarely more than 0.
' If it is consistently higher than this, yourSMTP service is not working well.

On Error Resume Next

Dim objWMIService, nMax, strComputerObject, colSMTP, o

nMax = 0

Set objWMIService = GetObject( "winmgmts://" & strComputer )
If( Err.Number <> 0 ) Then
Query_Length_SMTPQueue = retvalUnknown
EXPLANATION = "Unable to access '" & strComputer & "'. Possible reasons: no WMI installed on the remote server, no rights to access remote WMI service, or remote server down"
Exit Function
End If

Set colSMTP = objWMIService.InstancesOf( "Win32_PerfRawData_SMTPSVC_SMTPServer" )

For Each o in colSMTP

If( Err.Number <> 0 ) Then
Query_Length_SMTPQueue = retvalUnknown
EXPLANATION = "Unable to list smtp servers"
Exit Function
End If

If( InStr( UCase( o.Name ), "SMTP" ) ) Then
If( o.LocalQueueLength > numMaxQueueLength ) Then
Query_Length_SMTPQueue = False
EXPLANATION = "SMTP Local Queue Length (" & o.LocalQueueLength & ") exceeds " & numMaxQueueLength
Exit Function
Else
Query_Length_SMTPQueue = True
EXPLANATION = "SMTP Local Queue Length less than " & numMaxQueueLength
Exit Function
End If
End If
Next

Query_Length_SMTPQueue = True
EXPLANATION = "SMTP service not installed"

End Function
=====================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top