Monitoring MSMQ via vbs
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
Comments 7 Comments • Jump to latest comment
Thanks Wayne, this is great stuff!
Cheers
Tony Sterling
www.bluesource.net or www.bluesource.co.uk
Offices in the US and the UK
Thanks Wayne.. good job.
Is there anyway to monitor a SPECIFIC queue only?
e.g. I have queues named
myqueue
myqueue1
myqueue2
and i only want to monitor 'myqueue' It always comes back with the results from all the queues.
It can do that out of the box ..
Just do:
eg
Many Thanks,
Rob
www.quadrotech-it.com - All your EV Tools
PS I hope that the post proves helpful.
Right. I get that. And I have it working that way. However, I am monitoring many servers (and that list of servers is always changing) for one queue only. I have a work around, but it's not too elegant. I want to nail down the For each qFormat in MSMQApp.PrivateQueues section to where it only pulls up the one queue that I need, rather than "For each.."
Also, when you do it "cscript msmq.vbs servername queuename" it will return everything with names of "queuename, queuename1, queuename2, etc."
Change
to
The values will then only be output when the queue name is an exact match.
Many Thanks,
Rob
www.quadrotech-it.com - All your EV Tools
PS I hope that the post proves helpful.
Thanks so much for all your help Rob.
Of course, they changed their requirements, so now I'm back to doing all queues :) It's working perfectly though.
Okay - no problem.
Many Thanks,
Rob
www.quadrotech-it.com - All your EV Tools
PS I hope that the post proves helpful.
Would you like to reply?
Login or Register to post your comment.