Hi,
Is it possible to configure Nagios Xi trigger an action based on service check status, like kill a process and then restart a service? If so, please send us instructions.
Thanks
NagiosXi - Action based on check
Re: NagiosXi - Action based on check
Yes it is, with event handlers and agents, see here:
https://assets.nagios.com/downloads/nag ... h-NCPA.pdf
And some other links for different agents here:
https://library.nagios.com/library/prod ... nagios-xi/
See here as well for the information on event handlers:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
https://assets.nagios.com/downloads/nag ... h-NCPA.pdf
And some other links for different agents here:
https://library.nagios.com/library/prod ... nagios-xi/
See here as well for the information on event handlers:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
-
Bala.Mutyam
- Posts: 97
- Joined: Wed Apr 29, 2020 12:18 pm
Re: NagiosXi - Action based on check
@ssax: Thanks for the info, i have setup an event handler to check file age and restart service based on age. The file age service check is critical but it's not triggering event handler.Testing from nagiosXi is ok. Can you please have a look?
Here are the details:
Restart Script:
Event handler script:
Event Handler:
service definition:
Here are the details:
Restart Script:
Code: Select all
#/bin/sh
pkill ncpa_listener
sudo service ncpa_listener restart >> /dev/null
exit 0
Code: Select all
#/bin/sh
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_ncpa.py -H "$2" -P 5693 -t "$3" -M 'plugins/restart_service.sh'
;;
esac
exit 0
Event Handler:
Code: Select all
define command {
command_name Service Restart - NCPA
command_line $USER1$/restart_service.sh $SERVICESTATE$ $HOSTADDRESS$ token
}
service definition:
Code: Select all
define service {
host_name host_name
service_description Test File Check
check_command check_xi_ncpa!-t 'token' -P 5693 -M 'plugins/check_file_age' -q 'args=-f /tmp/test -w 598 -c 720'
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
event_handler Service Restart - NCPA
event_handler_enabled 1
notification_interval 15
notification_period 24x7
notifications_enabled 1
contact_groups Linux-Alerts
register 1
}
Re: NagiosXi - Action based on check
Given the checks will be run as the nagios user, please SSH into the remote NCPA system and run these commands:
If that doesn't work without asking for a password it's likely a sudoers issue.
What are the permissions of the plugin on the NCPA host?
What are the permissions of the event handler script on the XI server?
Make sure the state is changing (that's when even handlers run, on state changes), so submit an OK/UP first and then test.
Code: Select all
su - nagios
cd /usr/local/ncpa/plugins
./restart_service.shWhat are the permissions of the plugin on the NCPA host?
Code: Select all
ls -l /usr/local/ncpa/plugins/restart_service.shCode: Select all
ls -l /usr/local/nagios/libexec/restart_service.sh-
Bala.Mutyam
- Posts: 97
- Joined: Wed Apr 29, 2020 12:18 pm
Re: NagiosXi - Action based on check
@ssax : Hi, thanks for the update. It was all working except it didn't change state. I have changed the state of the alert and it's working fine.
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: NagiosXi - Action based on check
Hi,
When you have a minute, please let us know.
Sounds you got working! Did you have any other questions or may we close this thread?@ssax : Hi, thanks for the update. It was all working except it didn't change state. I have changed the state of the alert and it's working fine.
When you have a minute, please let us know.
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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
Bala.Mutyam
- Posts: 97
- Joined: Wed Apr 29, 2020 12:18 pm
Re: NagiosXi - Action based on check
@benjaminsmith: Hi - Please close this thread.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: NagiosXi - Action based on check
Great!Bala.Mutyam wrote:@benjaminsmith: Hi - Please close this thread.
Locking thread