Page 4 of 4
Re: Is it possible to have 2 notifications template
Posted: Fri Dec 06, 2013 12:07 pm
by cesar.garza
#!/bin/bash ---> this thing worked and i got the email. However when i setup my actual
notify-service-by-email , i did get the email but it was blank -no information at all. I have setup like that;
Code: Select all
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/local/nagios/libexec/messageone_recovery /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n\nURL: $SERVICEACTIONURL$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
Re: Is it possible to have 2 notifications template
Posted: Fri Dec 06, 2013 2:14 pm
by abrist
As your actual mail command is in the custom script, remove the printf statement and replace with the necessary macros:
Code: Select all
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/local/nagios/libexec/messageone_recovery "$NOTIFICATIONTYPE$" "$SERVICEDESC$" "$HOSTALIAS$" "$HOSTADDRESS$" "$SERVICESTATE$" "$LONGDATETIME$" "$SERVICEOUTPUT$" "$SERVICEACTIONURL$" "$CONTACTEMAIL$"
}
Re: Is it possible to have 2 notifications template
Posted: Mon Dec 09, 2013 12:48 pm
by cesar.garza
Okay guys, i have modified the templates and contact and after that its not working at all. I am pasting my command.cfg, contact.cfg, and template.cfg.
I have not changed anything in the script and its working from command line.
Code: Select all
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email-test
command_line /usr/local/nagios/libexec/messageone_recovery "$NOTIFICATIONTYPE$" "$SERVICEDESC$" "$HOSTALIAS$" "$HOSTADDRESS$" "$SERVICESTATE$" "$LONGDATETIME$" "$SERVICEOUTPUT$" "$SERVICEACTIONURL$" "$CONTACTEMAIL$"
}
Code: Select all
define contact{
contact_name Recovery-phone
use generic-contact
alias Phone test
email [email protected]
}
#define contact{
contact_name Recovery-email
use generic-contact-email-test
alias Recovery email test
email [email protected]
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members Recovery-email, Recovery-phone
}
Code: Select all
define contact{
name generic-contact
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,f,s
host_notification_options d,u
service_notification_commands notify-service-by-phone
host_notification_commands notify-host-by-phone
register 0 }
define contact{
name generic-contact-email-test
service_notification_period 24x7
host_notification_period 24x7
service_notification_options r
host_notification_options r
service_notification_commands notify-service-by-email-test
host_notification_commands notify-host-by-email
register 0
}
Re: Is it possible to have 2 notifications template
Posted: Mon Dec 09, 2013 1:03 pm
by abrist
Lets check the logs:
Code: Select all
cat /usr/local/nagios/var/nagios.log | grep notify | tail
Re: Is it possible to have 2 notifications template
Posted: Wed Dec 11, 2013 2:59 pm
by cesar.garza
We did it guys...Working as expected, getting only alert calls and recovery emails. Awesome.....
quick question, can we run notify by host with same script ? I know we can do with separate script and change the macros but I was curious to run from the same script but how ???
Re: Is it possible to have 2 notifications template
Posted: Wed Dec 11, 2013 4:18 pm
by slansing
Using it for host notifications as well? This should work the same.