MSMQ WMI Provider Objects
Yoel Arnon, , http://www.msmq.biz
Disclaimer: The MSMQ WMI provider and related documentation are provided 'as is' without warranty of any kind, either express or implied.
MSMQData Object
General attributes of the MSMQ system. I tried to get the data using MSMQ APIs and MSMQ Admin APIs when possible, but otherwise I got it from the performance counters.
Property / Type / CommentsInstanceId / string / Key. Always "MSMQ"
TotalMessagesSize / uint64 / Source: MSMQ Admin API in W2K3, performance counters in W2K
TotalMessagesCount / uint32 / Source: Performance counters
SourceJournalMessageCount / uint32
SourceJournalMessageSize / uint32
DeadLetterMessageCount / uint32
DeadLetterMessageSize / uint32
TargetJournalMessageCount / uint32 / Summary on all the target journal queues. Source: MSMQ Admin API
TargetJournalMessageSize / uint32
SystemMessageCount / uint32 / Summary of all the journal (source and target) and dead letter messages
SystemMessageSize / uint32
NumWaitingOutgoingQueues / uint32 / Number of outgoing queues in state "Waiting to connect"
NumSessions / uint32 / Number of open sessions (source: performance counters)
OldestMessageInSrcJournalAgeSec / uint32
OldestMessageInDeadLtrAgeSec / uint32
TotalIncomingMessages / uint32 / Incoming / outgoing messages since MSMQ service started (source – performance counters)
TotalOutgoingMessages / uint32
IncomingMessagesPerDay / uint32 / These "flow" properties will return usable values only if you sampled any property of MSMQData at least once per hour over the last 24 hours.
IncomingMessagesPerHour / uint32
AverageIncomingMessageSize / uint32
OutgoingMessagesPerDay / uint32
OutgoingMessagesPerHour / uint32
AverageOutgoingMessageSize / uint32
Sample code:
strComputer = "."
Set objSWbemServices = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objMSMQ = objSWbemServices.Get("MSMQData.InstanceId='MSMQ'")
WScript.Echo "Total Messages Count: " + CStr(objMSMQ.TotalMessagesCount) + " Size: " + CStr(objMSMQ.TotalMessagesSize)
WScript.Echo " Out of which " + CStr(objMSMQ.SystemMessageCount) + " are system messages, occupying " + CStr(objMSMQ.SystemMessageSize) + " bytes"
MSMQOutgoingQueueData Object
An instance of this object is created for each outgoing queue.
Property / Type / CommentsFormatName / string / Key. The queue's format name
PathName / string / The queue's path name – especially useful for public queues, where the format name is not very readable
Name / string / The queue's name (the rightmost part of the pathname - without the machine name and private$)
State / string / The queue's state. Most useful states are WAITING, CONNECTED and INACTIVE. For full list of possible states, see http://msdn2.microsoft.com/en-us/library/ms703960.aspx .
MessageCount / uint32 / Number of messages in the queue
OldestMessageAgeSeconds / uint32 / Oldest message age. If the queue contains messages with several priorities, this will be the age of the oldest message among the highest priority messages.
Sample code:
Dim Locator 'As New WbemScripting.SWbemLocator
Set Locator= CreateObject("WbemScripting.SWbemLocator")
Dim objs ' As ISWbemObjectSet
Set Service = Locator.ConnectServer(".", "root\cimv2")
Set objs = Service.ExecQuery("Select * from MSMQOutgoingQueueData where State = 'WAITING'")
WSCript.Echo "Waiting outgoing queues"
WScript.Echo "------"
For Each object in objs
WScript.Echo "Name: " & object.Name & ", Oldest message: " & object.OldestMessageAgeSeconds & " Seconds"
Next
MSMQLocalActiveQueueData Object
Local active queues are local queues – private or public – which are either open or have messages. Other queues are not considered "active".
Property / Type / CommentsFormatName / string / Same as in MSMQOutgoingQueueData
PathName / string
Name / string
MessageCount / uint32
OldestMessageAgeSeconds / uint32
MessageSize / uint32 / Total size of messages in the queue
JournalCount / uint32 / Count and size of messages in the related target journal queue
JournalSize / uint32