check_nt service state check not working

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

check_nt service state check not working

Postby kmartin2007 » Tue Nov 19, 2019 9:56 am

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

Re: check_nt service state check not working

Postby scottwilkerson » Tue Nov 19, 2019 10:47 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: check_nt service state check not working

Postby kmartin2007 » Tue Nov 19, 2019 11:02 am

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: 62
Joined: Thu Nov 14, 2019 3:31 pm

Re: check_nt service state check not working

Postby kmartin2007 » Tue Nov 19, 2019 11:06 am

here is my services.cfg file

This is nagios core 3

we installed using ubuntu packages.
Attachments
services_nagios2.cfg
(36.29 KiB) Downloaded 6 times
kmartin2007
 
Posts: 62
Joined: Thu Nov 14, 2019 3:31 pm

Re: check_nt service state check not working

Postby scottwilkerson » Tue Nov 19, 2019 11:17 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: check_nt service state check not working

Postby kmartin2007 » Tue Nov 19, 2019 11:29 am

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

Re: check_nt service state check not working

Postby ssax » Tue Nov 19, 2019 4:15 pm

Please try changing it to this:

Code: Select all
-l "eSPNaniConnector$"$"DE"
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
ssax
Dreams In Code
 
Posts: 4392
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_nt service state check not working

Postby kmartin2007 » Tue Nov 19, 2019 5:48 pm

ssax wrote:Please try changing it to this:

Code: Select all
-l "eSPNaniConnector$"$"DE"



DE? do you mean MN?
kmartin2007
 
Posts: 62
Joined: Thu Nov 14, 2019 3:31 pm

Re: check_nt service state check not working

Postby tgriep » Tue Nov 19, 2019 5:53 pm

Yes, that was a typo, use MN.

-l "eSPNaniConnector$"$"MN"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8413
Joined: Thu Oct 30, 2014 9:02 am

Re: check_nt service state check not working

Postby kmartin2007 » Tue Nov 19, 2019 6:22 pm

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

Next

Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 16 guests