check_nt service state check not working

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
kmartin2007
Posts: 66
Joined: Thu Nov 14, 2019 3:31 pm

check_nt service state check not working

Post 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
Attachments
nt.cfg
(511 Bytes) Downloaded 159 times
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_nt service state check not working

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
kmartin2007
Posts: 66
Joined: Thu Nov 14, 2019 3:31 pm

Re: check_nt service state check not working

Post 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
kmartin2007
Posts: 66
Joined: Thu Nov 14, 2019 3:31 pm

Re: check_nt service state check not working

Post by kmartin2007 »

here is my services.cfg file

This is nagios core 3

we installed using ubuntu packages.
Attachments
services_nagios2.cfg
(36.29 KiB) Downloaded 160 times
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_nt service state check not working

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
kmartin2007
Posts: 66
Joined: Thu Nov 14, 2019 3:31 pm

Re: check_nt service state check not working

Post 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$
}
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_nt service state check not working

Post by ssax »

Please try changing it to this:

Code: Select all

-l "eSPNaniConnector$"$"DE"
kmartin2007
Posts: 66
Joined: Thu Nov 14, 2019 3:31 pm

Re: check_nt service state check not working

Post by kmartin2007 »

ssax wrote:Please try changing it to this:

Code: Select all

-l "eSPNaniConnector$"$"DE"

DE? do you mean MN?
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: check_nt service state check not working

Post by tgriep »

Yes, that was a typo, use MN.

-l "eSPNaniConnector$"$"MN"
Be sure to check out our Knowledgebase for helpful articles and solutions!
kmartin2007
Posts: 66
Joined: Thu Nov 14, 2019 3:31 pm

Re: check_nt service state check not working

Post 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"
}
Locked