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...
Nagios Event Handler- Custom Variable
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagios Event Handler- Custom Variable
If you were to call the new free variable _PROCESS you would call it as $_SERVICEPROCESS$
-
nagios1810
- Posts: 10
- Joined: Thu Feb 01, 2018 7:57 am
Re: Nagios Event Handler- Custom Variable
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..
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
Can you show your whole config, as well as the config on in the nrpe.cfg on the remote system.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..
-
nagios1810
- Posts: 10
- Joined: Thu Feb 01, 2018 7:57 am
Re: Nagios Event Handler- Custom Variable
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
#############################################################################
# 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
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
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$
-
nagios1810
- Posts: 10
- Joined: Thu Feb 01, 2018 7:57 am
Re: Nagios Event Handler- Custom Variable
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.
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
scottwilkerson wrote:Does your nagios.log show the even handler triggering when the ?