Page 1 of 1

How to add $HOSTNAME$ to hostgroup service eventhandler

Posted: Wed Jan 15, 2020 8:40 am
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?

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

Posted: Wed Jan 15, 2020 9:44 am
by scottwilkerson
sinaowolabi wrote:Please is this correct?
That looks correct to me, with the exception that the event_handler line is commented out

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

Posted: Wed Jan 15, 2020 8:21 pm
by sinaowolabi
Thanks a lot!
Sorry the commented line was an oversight.

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

Posted: Wed Jan 15, 2020 10:49 pm
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?