Nagios Event Handler- Custom Variable

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nagios1810
Posts: 10
Joined: Thu Feb 01, 2018 7:57 am

Nagios Event Handler- Custom Variable

Post by nagios1810 »

Hi Team,

I m trying to implement event handler for a process.

Previously, i have implemented the same for a service,for which the command is as follows,

/usr/local/nagios/libexec/check_nrpe -H 10.25.13.34 -p 5666 -c service_restart -a crond,

for which i have declared the Free variable in the Misc settings as _SERVICE = crond
and in the command of the event handler (say Service_Restart) i have declared the Command line as

"$USER1$/service_start.sh $SERVICESTATE$ $HOSTADDRESS$ $_SERVICESERVICE$"

in which $_SERVICESERVICE$ is the value _SERVICE declared in the Misc Settings.

Now, i am implementing the same for a Process,

/usr/local/nagios/libexec/check_nrpe -H 10.25.13.34 -p 5666 -c process_start -a /software/process.sh(Path varies for different process)


for this what is the free variable i should declare and also instead of $_SERVICESERVICE$ what should be declared in the command line.

Please help in resolving this issue...

Thanks in advance...
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios Event Handler- Custom Variable

Post by scottwilkerson »

If you were to call the new free variable _PROCESS you would call it as $_SERVICEPROCESS$
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
nagios1810
Posts: 10
Joined: Thu Feb 01, 2018 7:57 am

Re: Nagios Event Handler- Custom Variable

Post by nagios1810 »

Thanks for your reply...

Declaring the free variable like you said ($_SERVICEPROCESS$ and _PROCESS) is not running the script in that path when that service is down..
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios Event Handler- Custom Variable

Post by scottwilkerson »

nagios1810 wrote:Thanks for your reply...

Declaring the free variable like you said ($_SERVICEPROCESS$ and _PROCESS) is not running the script in that path when that service is down..
Can you show your whole config, as well as the config on in the nrpe.cfg on the remote system.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
nagios1810
Posts: 10
Joined: Thu Feb 01, 2018 7:57 am

Re: Nagios Event Handler- Custom Variable

Post by nagios1810 »

This is the nrpe.cfg file in remote system

#############################################################################
# Sample NRPE Config File
# Written by: Ethan Galstad ([email protected])
#
# Last Modified: 11-23-2007
#
# NOTES:
# This is a sample configuration file for the NRPE daemon. It needs to be
# located on the remote host that is running the NRPE daemon, not the host
# from which the check_nrpe client is being executed.
#############################################################################


log_facility=daemon

pid_file=/var/run/nrpe.pid

server_port=5666


nrpe_user=nagios

nrpe_group=nagios


allowed_hosts=xx.xx.xx.xxx

dont_blame_nrpe=1


debug=0

command_timeout=6

connection_timeout=300

include_dir=/usr/local/nagios/etc/nrpe
command[check_process]=/usr/lib/nagios/plugins/check_process.py $ARG1$
command[service_start]=sudo service $ARG1$ restart
command[process_start]=sudo /usr/lib/nagios/plugins/eh_process.sh $ARG1$

eh_process.sh script:
#!/bin/bash
ARG="$1"
"$ARG" start

event handler script in nagios server:
#!/bin/sh
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c process_start -a "$3"
;;
esac
exit 0

eventhandler command:

Command Name *
EventHandler_ProcessCheck
Command Line *
$USER1$/eh_processstart.sh $SERVICESTATE$ $HOSTADDRESS$ $_SERVICEPROCESS$

Service

Misc Settings
Free Variables
_PROCESS /software/flink/bin/taskmanager.sh
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios Event Handler- Custom Variable

Post by scottwilkerson »

Is the event handler specified in the service, and enabled?

Does your nagios.log show the even handler triggering when the ?

what is in eh_processstart.sh ?

I'm a little confused that your process_start command in nrpe.cfg is calling eh_process.sh which when CRITICAL is calling a NRPE command

Code: Select all

command[process_start]=sudo /usr/lib/nagios/plugins/eh_process.sh $ARG1$
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
nagios1810
Posts: 10
Joined: Thu Feb 01, 2018 7:57 am

Re: Nagios Event Handler- Custom Variable

Post by nagios1810 »

Sorry actually i kept the same name for the event handler script in my Nagios xi and the script in the nrpe client..

eh_process.sh script:

#!/bin/bash
ARG="$1"
"$ARG" start

this script is in the nrpe client

and event handler script in nagios server is this
#!/bin/sh
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c process_start -a "$3"
;;
esac
exit 0

Event handler is enabled in the service.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios Event Handler- Custom Variable

Post by scottwilkerson »

scottwilkerson wrote:Does your nagios.log show the even handler triggering when the ?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked