Blog Post

Enterprise Data Services Community Blog
1 MIN READ

Monitoring MSMQ via vbs

Wayne_Humphrey's avatar
16 years ago

So a while ago I wrote a simple vbs to query MSMQ as the PerfMon counters are not reliable.  There is an updated script I did some ware just need to dig it out.

Option Explicit
Dim MSMQApp ' As MsmqApplication
Set MSMQApp = CreateObject("MSMQ.MSMQApplication")

Dim strComputer

If Wscript.Arguments.Count = 0 Then
                WScript.Echo "usage: msmq.vbs server_name queue "
                WScript.Echo " "
                WScript.Echo "e.g. cscript msmq.vbs tus1ev1idxpin01 queue"
Else
                strComputer = Wscript.Arguments(0)
END If

On Error Resume Next

MSMQApp.Machine=strComputer

Dim qFormat ' As String
For each qFormat in MSMQApp.PrivateQueues
                Dim Mgmt ' As new MSMQManagement
                Set Mgmt = CreateObject("MSMQ.MSMQManagement")
                Mgmt.Init MSMQApp.Machine,,"DIRECT=OS:" & qFormat
                if Wscript.Arguments(1) <> "" then
                                if instr(qformat, Wscript.Arguments(1)) >0 then
                                                WScript.Echo qFormat & "     Messages " & CLng(Mgmt.MessageCount) & "    Size: " & int(CLng(Mgmt.BytesInQueue) / 1024) & " Kb"
                                end if
                else
                                WScript.Echo qFormat & "     Messages " & CLng(Mgmt.MessageCount) & "    Size: " & int(CLng(Mgmt.BytesInQueue) / 1024) & " Kb"
                end if
Next

Published 16 years ago
Version 1.0
No CommentsBe the first to comment