Page 1 of 5

check_nt service state check not working

Posted: Tue Nov 19, 2019 9:56 am
by kmartin2007
So we also have this check defined for services running on alot of the IIS servers.

define service{
use production-service
host_name DALSRVPRDIIS02, DALSRVPRDIIS07
service_description IA_Connector_NANI2.0
display_name IA_Connector_NANI2.0
check_command check_nt!SERVICESTATE!-d SHOWALL -l eSPNaniConnector\$$MN
}

it is getting the following error on nagios page


MN_Connector_NANI2.0
Perform Extra Service Actions
UNKNOWN 2019-11-19 14:35:28 3d 17h 7m 12s 2/2 Failed to open service eSPNaniConnector: 1060: The specified service does not exist as an installed service.



HOWEVER this check reverted to 1248 rather than using 12489


executing without port
root@dalsrvitmon03:/usr/local/nagios/libexec# ./check_nt -H DALSRVPRDIIS02 -v SERVICESTATE -d SHOWALL -l eSPNaniConnector\$MN
connect to address DALSRVPRDIIS02 and port 1248: Connection refused
could not fetch information from server

with port defined and not a double $
root@dalsrvitmon03:/usr/local/nagios/libexec# ./check_nt -H DALSRVPRDIIS02 -v SERVICESTATE -d SHOWALL -l eSPNaniConnector\$MN -p12489
eSPNaniConnector$MN: Started

with the double $
root@dalsrvitmon03:/usr/local/nagios/libexec# ./check_nt -H DALSRVPRDIIS02 -v SERVICESTATE -d SHOWALL -l eSPNaniConnector\$$mn -p12489
Failed to open service eSPNaniConnector$: 1060: The specified service does not exist as an installed service.



attached is my check_nt config file nt.cfg

Re: check_nt service state check not working

Posted: Tue Nov 19, 2019 10:47 am
by scottwilkerson
Ok, because your $ARG1$ is escaped with single quotes here

Code: Select all

define command {
	command_name    check_nt
	command_line    /usr/lib/nagios/plugins/check_nt -p 12489 -H '$HOSTADDRESS$' -v '$ARG1$' $ARG2$
}
I believe you need to change the escaping to just

Code: Select all

check_command check_nt!SERVICESTATE!-d SHOWALL -l eSPNaniConnector$$MN

Re: check_nt service state check not working

Posted: Tue Nov 19, 2019 11:02 am
by kmartin2007
scottwilkerson wrote:Ok, because your $ARG1$ is escaped with single quotes here

Code: Select all

define command {
	command_name    check_nt
	command_line    /usr/lib/nagios/plugins/check_nt -p 12489 -H '$HOSTADDRESS$' -v '$ARG1$' $ARG2$
}
I believe you need to change the escaping to just

Code: Select all

check_command check_nt!SERVICESTATE!-d SHOWALL -l eSPNaniConnector$$MN

Changed the check to and still no difference.

check_command check_nt!SERVICESTATE!-d SHOWALL -l eSPNaniConnector$$MN




I then ran the command from terminal

root@dalsrvitmon03:/usr/lib/nagios/plugins# ./check_nt -H DALSRVPRDIIS02 -v SERVICESTATE -d SHOWALL -l eSPNaniConnector$$MN -p 12489
Failed to open service eSPNaniConnector845MN: 1060: The specified service does not exist as an installed service.

root@dalsrvitmon03:/usr/lib/nagios/plugins# ./check_nt -H DALSRVPRDIIS02 -v SERVICESTATE -d SHOWALL -l eSPNaniConnector$$MN
connect to address DALSRVPRDIIS02 and port 1248: Connection refused
could not fetch information from server

Re: check_nt service state check not working

Posted: Tue Nov 19, 2019 11:06 am
by kmartin2007
here is my services.cfg file

This is nagios core 3

we installed using ubuntu packages.

Re: check_nt service state check not working

Posted: Tue Nov 19, 2019 11:17 am
by scottwilkerson
Based no how your configs are setup, I'm going to recommend changing it back to

Code: Select all

check_command			check_nt!SERVICESTATE!-d SHOWALL -l eSPNaniConnector\$$MN
then change the check_command to the following

Code: Select all

define command {
   command_name    check_nt
   command_line    /usr/lib/nagios/plugins/check_nt -p 12489 -H '$HOSTADDRESS$' -v $ARG1$ $ARG2$
}
Then restart nagios

You cannot run these special escaping commands the same way from the command line because Nagios is going to see the $ and try to think it is a Macro, this doesn't work the same running from the CLI

Re: check_nt service state check not working

Posted: Tue Nov 19, 2019 11:29 am
by kmartin2007
no change.

i modified it to be the following like above


# 'check_nt' command definition
define command {
command_name check_nt
command_line /usr/lib/nagios/plugins/check_nt -p 12489 -H '$HOSTADDRESS$' -v $ARG1$ $ARG2$
}

Re: check_nt service state check not working

Posted: Tue Nov 19, 2019 4:15 pm
by ssax
Please try changing it to this:

Code: Select all

-l "eSPNaniConnector$"$"DE"

Re: check_nt service state check not working

Posted: Tue Nov 19, 2019 5:48 pm
by kmartin2007
ssax wrote:Please try changing it to this:

Code: Select all

-l "eSPNaniConnector$"$"DE"

DE? do you mean MN?

Re: check_nt service state check not working

Posted: Tue Nov 19, 2019 5:53 pm
by tgriep
Yes, that was a typo, use MN.

-l "eSPNaniConnector$"$"MN"

Re: check_nt service state check not working

Posted: Tue Nov 19, 2019 6:22 pm
by kmartin2007
tgriep wrote:Yes, I that was a typo, use MN.

-l "eSPNaniConnector$"$"MN"

lol i thought so.

I changed it, restarted nagios3 using service nagios3 restart and tested. did not work


define service{
use production-service
host_name DALSRVPRDIIS02, DALSRVPRDIIS07
service_description MN_Connector_NANI2.0
display_name MN_Connector_NANI2.0
check_command check_nt!SERVICESTATE!-d SHOWALL -l "eSPNaniConnector$"$"MN"
}