Event Handler with out sudo

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nagios_ant
Posts: 17
Joined: Tue Jul 11, 2017 2:03 am

Event Handler with out sudo

Post by nagios_ant »

Team,
recently we have purchased the license, but we are unable to find the option to create new post in the customer support forum. Is there any process to link the the ID with my license.


we are configuring event handler to restart an application using a script at the client end..
the script has to be run as a service user and we don't have the prviledge of sudo acess for nagios user to switch to the serviceuser. We have used expect option in client side script as an option.

1. In the Nagios CCM > Commands
created a "commands" named "applicaiton_start"
command line "$USER1$/application_start $SERVICESTATE$ $HOSTADDRESS$"

2. In nagios server created the below execution file
/usr/local/nagios/libexec/application_start

content for CRITICAL case set as below

CRITICAL)
/usr/local/nagios/libexec/check_nrpe -H "$2" -c application_start

3. On client side
/usr/local/nagios/etc/nrpe.cfg

command[application_start]=/bin/bash /usr/local/nagios/etc/applicationstart.sh

4. Content of applicationstart.sh is as below
I am able to run the below script as nagios user and the service is getting started as serviceuser. But when we run the command from nagios server script is not getting triggered.

#!/usr/bin/expect -f
set timeout 180
spawn ssh -l serviceuser va1313.xyz.com
#expect "(yes/no)?"
#send "yes\r"
expect "assword:"
send "abc@20\r"
expect "$"
#send "bash /usr/local/nagios/etc/application.sh\r"
send "cd /apps/service/dev/bin/\r"
expect "$"
send "nohup java -Xms512m -Xmx1536m -jar commission-service*.jar --spring.data.mongodb.uri=mongodb://appuser:[email protected]:27099/S......
expect "$"

Thank you
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Event Handler with out sudo

Post by mcapra »

nagios_ant wrote:we are unable to find the option to create new post in the customer support forum. Is there any process to link the the ID with my license.
You should contact the sales team. You can email them at sales at nagios dot com. All they should need is an email from the address you have on-file and the forums username you wish to whitelist.

I suspect the NRPE process is going to have problems navigating expect and that is likely the root of your problems. I don't have a lab environment to test this on currently, though.

What does check_nrpe by itself output when you execute it from the CLI of the Nagios Core machine:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H "host_name_here" -c application_start
Similarly, does the remote machine hosting the Java application produce anything interesting in the nrpe or system logs?
Former Nagios employee
https://www.mcapra.com/
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Event Handler with out sudo

Post by dwhitfield »

In addition to @mcapra's post...
nagios_ant wrote: 3. On client side
/usr/local/nagios/etc/nrpe.cfg

command[application_start]=/bin/bash /usr/local/nagios/etc/applicationstart.sh
That's not literally your entire nrpe.cfg, is it?

Are you using https://assets.nagios.com/downloads/nag ... h_NRPE.pdf to set this up?
nagios_ant
Posts: 17
Joined: Tue Jul 11, 2017 2:03 am

Re: Event Handler with out sudo

Post by nagios_ant »

Thank you for the time and support.

As suggested i am sending an email to the support team to add the user name.

I was able to figure out the problem doing multiple iterations .
as i am using 'expect option' in the local script file /bin/bash entry has to be removed in the nrpe.cfg

thank you both for the support.
nagios_ant
Posts: 17
Joined: Tue Jul 11, 2017 2:03 am

Re: Event Handler with out sudo

Post by nagios_ant »

@dwhitefiled
yes i am following the below document, but not using the sudo option.

--- Are you using https://assets.nagios.com/downloads/nag ... h_NRPE.pdf to set this up?

Thank you for the time
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Event Handler with out sudo

Post by dwhitfield »

nagios_ant wrote: I was able to figure out the problem doing multiple iterations .
I just want to be clear. Is your issue resolved? If not, what issue are you still seeing?
nagios_ant
Posts: 17
Joined: Tue Jul 11, 2017 2:03 am

Re: Event Handler with out sudo

Post by nagios_ant »

@dwhitfiled
yes the issue is resolved.
I removed/bin/bash from the below configuration,
with 'expect' option used in the script file, bash was throwing the error.
command[application_start]=/bin/bash /usr/local/nagios/etc/applicationstart.sh
bolson

Re: Event Handler with out sudo

Post by bolson »

Would it be ok to close this thread?
Locked