Service Configuration Questions


Howdy All,

Relatively new Nagios user here, I’ve been wanting to get it up and going for a while and finally did and making good progress!

Two questions on service configurations that I’m having trouble with:
(1) I have a few services (on Windows hosts, using the nsclient++) where the normal state is stopped and I would like, for those services when they are stopped to show Normal/Green and Red/Critical when they are started. I could be just missing this in the help files so any pointers would be appreciated. Right now it is just a very basic service defintion where “generic service” is the default template that came with Nagios:

define service{
        use                   generic-service
        host_name       LMFJECOMPROG,LMFJECOMWEB
        service_description     SI File Minion
        check_command           check_nt!SERVICESTATE!-d SHOWALL -l "SIFileMinionService"

Second configuration question - I have several named instances of MS-SQL which I need to monitor to make sure they are up (as some things do stop them in the course of normal operations, they are supposed to restart the instance but sometimes there are issues). The format of the service description is: MSSQL$INSTANCENAME. The pre-flight check doesn’t have a problem with the $ but when this is passed to the check_nt command, I think something is getting lost - specifically everything after the $. I have tried using $ and get the same result. Again right now I just have a very basic service definiton without any bells and whistles:

define service{
        use                              generic-service
        host_name                  LMFJICVERIFY
        service_description     ICV MS SQL
        check_command         check_nt!SERVICESTATE!-d SHOWALL -l "MSSQL\$ICV"

The check command is the “out of the box” command:

define command{
        command_name    check_nt
        command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s ********* -v $ARG1$ $ARG2$

I could probably accomplish what I need to do by hard coding the strings into their own commands but this would become hard to manage down the road.

Any advice and/or thoughts very much appreciated. I am using v 3.07b (I realize its not stable but thought I’d give it a shot anyway).

Mark At LMFJ


for your first question, I’ve not seen a way to do that via nagios. So, the way I’d it would be to change the script which is on your windows computer so that it will return 0 when the service is absent and 2 when it is running.
If you can’t change de code (ie: you’re using a compiled plugin), you can write a little shell script on your nagios server that will call the remote check and then inverse the results
well; that’s a bit dirty, but it will work :slight_smile: (any other idea might be appreciated)

For the second question, I’m not sure what you’re trying to say, but, I’ve found that the escape caracter for $ is simply: $ (ie: try to replace $ by $$)… I don’t really think it will work, but it’s worth a try :slight_smile: