I'm trying to monitor an MSMQ queue counter using Nagios (3.0.1). The remote server is running NC_Net. The check_command config looks like this:
check_command check_nt!COUNTER!-l "\\MSMQ Queue(servername\\private$\\queuename)\\Messages in Queue","%.f messages in MSMQ queue" -w 5 -c 10
This doesn't work. I believe that the dollar symbol needs to be escaped and I'm having trouble working out how.
This article suggests "$$" ie.
check_command check_nt!COUNTER!-l "\\MSMQ Queue(servername\\private"$$"\\queuename)\\Messages in Queue","%.f messages in MSMQ queue" -w 5 -c 10
but that doesn't work. I've tried a few other methods (backslash, single quotes etc).
Any suggestions?
EDIT:
I've been doing some testing via the command line which is one reason I believe it's the $ causing the problem. The following works:
./check_nt -H hostip -v COUNTER -l "\\MSMQ Queue(Computer Queues)\\Messages in Queue","%.f messages in MSMQ queue" -w 5 -c 10
but this doesn't:
./check_nt -H hostip -v COUNTER -l "\\MSMQ Queue(servername\\private$\\queuename)\\Messages in Queue","%.f messages in MSMQ queue" -w 5 -c 10
I've also used ECHO to see how those commands expand but that hasn't helped me.
EDIT:
Turns out it wasn't the dollar symbol. See below.
You can enable full debugging in the nagios.cfg to see what the command actually expands to, this will show you if the dollar sign is actually the problem. To do this, set the following:
If you have a lot of checks, you need to set the max debug file size because at that verbosity and level the log fills up quick.
And them maybe (example):
You will then need to run check, while tailing the log. You also might want to pipe the tail to grep with something like 'check_nt' so you can lessen the noise.
I believe you need to use \ to escape the character but the following link shows you might need two \
hope this helps -> Link <-
I've discovered that NC_Net on the remote server logs to the Windows event log. Looking at the errors, I'm starting to think that it's not a problem with the dollar symbol:
I've run a couple of tests (that I expect to fail). For the first, I specified the counter name as "\MSMQ Queue(servername)\Messages in Queue"
The resulting error was:
In that case, it can't find the counter instance. For the second, I specified "\MSMQ Queue(servername\test1)\Messages in Queue"
In that case, it can't find the counter.
It looks to me like NC_Net is parsing the counter names differently because of the \ in "servername\test1".
EDIT:
The problem was due to the \ in the counter instance name. I've discovered that there is an alternative syntax for specifying the counter name so the following works: