Escaping characters in Nagios for NC_Net

monitoringmsmqnagiosperfmon

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.

Best Answer

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:

debug_level=-1
debug_verbosity=2
# DEBUG FILE
debug_file=/usr/local/nagios/var/nagios.debug
max_debug_file_size=1000000

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):

sudo /etc/init.d/nagios reload

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.

Related Topic