Greetings, my first post here. I'm looking at the possibility of using Nagios to monitor an application platform. One criteria is the ability for Nagios to read the MSMQ queue, and generate alarms if it recognizes any key words such as "XXXX Application down."
I did some search and only came up with check_msmq.vbs module, but it seems that's only used for counting how many messages are in queue.
Any suggestion is greatly appreciated.
Stephen
Can Nagios pull logs from MSMQ queue?
-
- Posts: 22
- Joined: Wed Jun 18, 2014 4:15 am
Re: Can Nagios pull logs from MSMQ queue?
Assume you already know how to use check_msmq.vbs, you can use the following vbs with nsclient
Code: Select all
Option Explicit
Const MQ_RECEIVE_ACCESS = 1
Const MQ_SEND_ACCESS = 2
Const MQ_DENY_NONE = 0
Const MQ_PEEK_ACCESS = 32
if WScript.Arguments.Count <> 2 then
call help()
wscript.quit(2)
end if
Dim SearchStr
SearchStr = WScript.Arguments(1)
Dim FormatName
FormatName = "DIRECT=OS:localhost\private$\" & WScript.Arguments(0)
Dim MSMQQueueInfo
Set MSMQQueueInfo = CreateObject("MSMQ.MSMQQueueInfo")
MSMQQueueInfo.FormatName = FormatName
Dim MSMQQueue
Set MSMQQueue = CreateObject("MSMQ.MSMQQueue")
Dim MSMQMessage
Set MSMQMessage = CreateObject("MSMQ.MSMQMessage")
Set MSMQQueue = MSMQQueueInfo.Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE)
Dim message
If getMSMQCount(FormatName)>0 then
Set message = MSMQQueue.PeekCurrent()
if instr(message.body, SearchStr)>0 then
wscript.echo "CRITICAL - String (" & SearchStr & ") found in MSMQ"
wscript.quit(2)
end if
Do While (Not message Is Nothing) and (getMSMQCount(FormatName)>0)
if instr(message.body, SearchStr)>0 then
wscript.echo "CRITICAL - String (" & SearchStr & ") found in MSMQ"
wscript.quit(2)
end if
Set message = MSMQQueue.PeekNext(False, true, 0)
Loop
wscript.echo "OK - String (" & SearchStr & ") NOT found in MSMQ"
wscript.quit(0)
end If
function getMSMQCount(qformat)
dim MSMQApp, Mgmt
Set MSMQApp = CreateObject("MSMQ.MSMQApplication")
Set Mgmt = CreateObject("MSMQ.MSMQManagement")
Mgmt.Init ,,qFormat
getMSMQCount = CLng(Mgmt.MessageCount)
end function
Function Help()
Wscript.Echo "Usage: search_msmq.vbs [queuename] [search string]"
End Function
Re: Can Nagios pull logs from MSMQ queue?
@steph280
Did you try the chris.fixter's solution? Let us know if you get stuck with NSClient++.
Did you try the chris.fixter's solution? Let us know if you get stuck with NSClient++.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Can Nagios pull logs from MSMQ queue?
I have not had a chance to set that up yet since we don't have a test box in the live environment yet. I have no experience with visual basic so there will be some learning curve. I'm sure I will have a bunch more questions during the setup process.
Thanks again for the help!
Thanks again for the help!
Re: Can Nagios pull logs from MSMQ queue?
We'll keep this thread open for a bit in case you have any questions about the script or nsclient.
Former Nagios employee