Page 1 of 1

Nagios Contact not triggering the custom script

Posted: Thu Nov 14, 2019 7:41 am
by rajsshah
HI
My intention is to have a script triggered in case of any NOTIFICATION . For that :
1. I have created a CONTACT ( not the user ) , in nagios.
2. Created a custom script and added it under _commands
3. I mapped that script/command under CONTACT's "Manage Host and Service Notofocation Command"
4. Time period is 24x7

If I send cutom notifcation , my script gets executed and everything works fine . However for a normal failure it never gets executed . I do not see it under Notification dashboard as well .

If I create USER ( which internally creates CONTACT as well ) , then everything works fine even for normal failure .
However I do not want to create a USER , I only want to create CONTACT . Why is that behavior ??

Re: Nagios Contact not triggering the custom script

Posted: Thu Nov 14, 2019 10:47 am
by lmiltchev
Can you show us the actual configs for the contact, and host & service notification command that the contact is using?

Re: Nagios Contact not triggering the custom script

Posted: Fri Nov 15, 2019 4:23 am
by rajsshah
Contact:
define contact {
contact_name Infra_Test_L2_Middleware
alias Test L2 Middleware Team
host_notification_period 24x7
service_notification_period 24x7
host_notification_commands notify-host-by-snt
service_notification_commands notify-service-by-snt
}

HOST NOTIFICATION COMMAND
define command {
command_name notify-host-by-snt
command_line $USER1$/nagios_mulesoft.py --source="nagios" --node="$HOSTNAME$" --type "$NOTIFICATIONTYPE$" --resource "Host" --metric_name "Host Status" --event_class "nagios alert" --severity "$HOSTSTATE$" --description "$HOSTOUTPUT$" --time_of_event "$SHORTDATETIME$" --env_type "$HOSTGROUPNAMES$" --contact "$CONTACTNAME$"
}


SERVICE NOTIFICATION COMMAND
define command {
command_name notify-service-by-snt
command_line $USER1$/nagios_mulesoft.py --source="nagios" --node="$HOSTNAME$" --type "$NOTIFICATIONTYPE$" --resource "$SERVICEDESC$" --metric_name "$SERVICEDESC$" --event_class "nagios alert" --severity "$SERVICESTATE$" --description "$SERVICEOUTPUT$" --time_of_event "$SHORTDATETIME$" --env_type "$HOSTGROUPNAMES$" --contact "$CONTACTNAME$"
}

Re: Nagios Contact not triggering the custom script

Posted: Fri Nov 15, 2019 9:43 am
by lmiltchev
These look fine. Let's check a few more things. Give us an example of a host or a service that sent to hard non-OK state, but the script was not triggered.

We need to see:
- the config for this particular host/service, including any templates that are used by this object
- a screenshot of the State History report, showing the host/service is a hard, non-ok state (Reports > State History > <your host/service> > Run)
- a screenshot of the Notifications report from the same time period (Reports > Notifications > <your host/service> > Run)