check_nt and windows service names


#1

I have a small issue with passing a service name of “MSSQL$XXXXXX”. Looking at the config file for the check_nt definition looks like that the $ in the service name is throwing out the parameter being passed. Is there another way I can get this service checked by using some other means of passing the name?


#2

I wonder is it check_nt that’s falling over, or the way the parameter is passed from nagios? i.e. can you run the check_nt command from the command line? Also, have you tried ‘escaping’ the $ i.e. “MSSQL$XXXXXX”?


#3

yeah this works via the command line okay,yet when I put the escape syntax in, it still fails through nagios

Is there another way of defining the service name that will still be able to be parsed correctly?


#4

Also I have another problem which is possibly related, where I have a service check against MS Exchange IMAP service. Which always says that it is stopped either by acutal service name IMAP4Svc or display name “Microsoft Exchange IMAP4”.

yet via the command line running check_nt says that it is running. any ideas


#5

Ok, looks like the answer for the MSSQL service is to define the check as a new check in command.cfg, i.e check_nt_mssql or something similar, and add the service you wish to check there, however in order to escape the $ character it appears you have to use a second $, as in

"MSSQL$$XXXXXX".

and not a backslash after all. As it is written, so it shall come to pass…
[blockquote]
command_line: This directive is used to define what is actually executed by Nagios when the command is used for service or host checks, notifications, or event handlers. Before the command line is executed, all valid macros are replaced with their respective values. See the documentation on macros for determining when you can use different macros. Note that the command line is not surrounded in quotes. Also, if you want to pass a dollar sign ($) on the command line, you have to escape it with another dollar sign.
[/blockquote] http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#command

Not sure about the IMAP one… perhaps post the check command syntax and command line test? Or maybe see if you can accomplish your goal through use of the check_imap check instead?

HTH

/S


#6

I changed my command.cfg as you have suggested

[blockquote]
define command{
command_name check_nt_mssql
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ “MSSQL$$XXXXX”
}
[/blockquote]

but with no luck, the error that nagios reports through the web interface is “Status Information: MSSQL: Unknown”. When I change the command line to this

[blockquote]command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ ‘MSSQL$XXXXX’[/blockquote]
or
[blockquote]command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ “MSSQL$XXXXX”
[/blockquote]

Nagios comes back with “Status Information: MSSQL$XXXXXX$”. I can’t for imagine where it is getting this extra $ from. It is not defined anywhere.

Regards
Martin.


#7

here is the definition that I have for the other issue that I am experiencing:

define service{
	use			generic-service
	host_name		melmail03
	service_description	Microsoft Exchange IMAP
	check_command		check_nt!SERVICESTATE!-d SHOWALL -l IMAP4SVC
	}

The problem is that whether I use the actual service name or the display name the result is the same. The service is actually started on the server. I can run the check_nt command via the command line and get the correct result but nagios always returns the service as being stopped, when in fact it is started.


#8

Mmm, looks like a documentational red herring I’d say. Several previous posters appear to have had some success with the format:

define command{ command_name check_nt_mssql command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v SERVICESTATE -d SHOWALL -l MSSQL$"$"XXXXX }
Nobody knows why it should work, but it’s worth a shot I’d say.

Again, as for IMAP4, still none the wiser I’m afraid. Might be worth running sc -query on melmail03 just to confirm that you have the IMAP4 service name exactly as it should be in the service object definition, but I’m sure it is correct.

HTH

/S


#9

I tried that but again, no luck. Could this be considered a bug with nagios now. With all the different forms of the service name, even creating a specialised check command does not work when there is a $ in the service name.

Regards
Martin.


#10

It would certainly seem to be the case, based on your experience. Being as it works off of the command line ok, if you are looking for a workaround I guess you have the option of creating some sort of wrapper script for the check_nt command for this server that willanalyse check_nt’s output itself and report back the appropriate status to nagios when called… Bit of a cludge I know, but probably doable in less time than it would take to persevere with random escape characters and whatnot… I guess the same would go for that IMAP4 service issue too.

HTH

/S


#11

SOLVED!!!

I stumbled across the solution while searching for something else oddly enough. To make this work you don’t need to create a separate check command or anything like that your service name needs to be defined like this:

define service{
	use			generic-service
	host_name		timesheet
	service_description     MSSQL 
	check_command        check_nt!SERVICESTATE! -d SHOWALL -l mssql"$$"xxxxxx
	}

and all is happy.