How to add $HOSTNAME$ to hostgroup service eventhandler

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
sinaowolabi
Posts: 14
Joined: Wed Apr 16, 2014 3:06 am

How to add $HOSTNAME$ to hostgroup service eventhandler

Post by sinaowolabi »

Hi

Im trying to create an event handler to affect a hostgroup service.
I want the eventhandler to affect only the host that has a service affected and I am not sure I am doing this correctly.
What I have configured:

define service {
use generic-service,service-pnp
hostgroup_name ourgroup
service_description CHECK ASERVICE SERVICE
check_command check_nrpe!check_aservice_server
max_check_attempts 3
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contacts theadmin
event_handler_enabled 1
#event_handler restart-aservice
}

define command {
command_name restart-aservice
command_line $USER1$/eventhandlers/restart-aservice $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTNAME$
}

Please is this correct?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to add $HOSTNAME$ to hostgroup service eventhandler

Post by scottwilkerson »

sinaowolabi wrote:Please is this correct?
That looks correct to me, with the exception that the event_handler line is commented out
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
sinaowolabi
Posts: 14
Joined: Wed Apr 16, 2014 3:06 am

Re: How to add $HOSTNAME$ to hostgroup service eventhandler

Post by sinaowolabi »

Thanks a lot!
Sorry the commented line was an oversight.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: How to add $HOSTNAME$ to hostgroup service eventhandler

Post by Box293 »

An easy mistake any one of us has made at some point :oops:

Is there anything else in relation to this that you need help with or can we lock this thread?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked