Page 3 of 4

Re: Is it possible to have 2 notifications template

Posted: Fri Nov 29, 2013 3:54 pm
by cesar.garza
slansing wrote:We're looking into this and will get back to you.
Any suggestion slansing ??

Re: Is it possible to have 2 notifications template

Posted: Mon Dec 02, 2013 12:53 pm
by abrist
Can you run the notification handler script from the cli? Replace the macros with the proper data, for example:

Code: Select all

/usr/local/nagios/libexec/messageone_recovery RECOVERY Test_Service Host_Alias Host_Address HARD Current_Time Service_Is_OK "http://response.url" <email>
Make sure to replace <email> with your email.
Test the handler above, and then check the maillog:

Code: Select all

tail -25 /var/log/maillog

Re: Is it possible to have 2 notifications template

Posted: Tue Dec 03, 2013 3:04 pm
by cesar.garza
abrist wrote:Can you run the notification handler script from the cli? Replace the macros with the proper data, for example:

Code: Select all

/usr/local/nagios/libexec/messageone_recovery RECOVERY Test_Service Host_Alias Host_Address HARD Current_Time Service_Is_OK "http://response.url" <email>
Make sure to replace <email> with your email.
Test the handler above, and then check the maillog:

Code: Select all

tail -25 /var/log/maillog

Hey abrist, i tried the above thing and it didn't work. that's what you ask me to do ??

Code: Select all

root@stg-nagios01:~#
root@stg-nagios01:~# /usr/local/nagios/libexec/messageone_recovery RECOVERY Test_Service Host_Alias Host_Address HARD Current_Time Service_Is_OK "http://response.url" <[email protected]>
-bash: syntax error near unexpected token `newline'
root@stg-nagios01:~#


Re: Is it possible to have 2 notifications template

Posted: Tue Dec 03, 2013 3:11 pm
by abrist
Try: (remove the <>)

Code: Select all

/usr/local/nagios/libexec/messageone_recovery RECOVERY Test_Service Host_Alias Host_Address HARD Current_Time Service_Is_OK "http://response.url" [email protected]

Re: Is it possible to have 2 notifications template

Posted: Tue Dec 03, 2013 3:21 pm
by cesar.garza
I got this ...

Code: Select all

root@stg-nagios01:~#
root@stg-nagios01:~#
root@stg-nagios01:~# /usr/local/nagios/libexec/messageone_recovery RECOVERY Test_Service Host_Alias Host_Address HARD Current_Time Service_Is_OK "http://response.url" [email protected]
/usr/local/nagios/libexec/messageone_recovery: 18: [: RECOVERY: unexpected operator
root@stg-nagios01:~#

Re: Is it possible to have 2 notifications template

Posted: Tue Dec 03, 2013 3:31 pm
by abrist
Ok, I missed a syntax error in your script. The condition/antecedent must be on the same line as the 'if' statement:

Code: Select all

#! /bin/sh

NOTIFICATIONTYPE=$1
SERVICEDESC=$2
HOSTALIAS=$3
HOSTADDRESS=$4
SERVICESTATE=$5
LONGDATETIME=$6
SERVICEOUTPUT=$7
SERVICEACTIONURL=$8
CONTACTEMAIL=$9


if [ "${NOTIFICATIONTYPE}" == "RECOVERY" ]; then 
    /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};

fi

Re: Is it possible to have 2 notifications template

Posted: Tue Dec 03, 2013 4:09 pm
by cesar.garza
I am still getting the same error . The only thing that changed is number from (18) to (14).

Code: Select all

root@stg-nagios01:/usr/local/nagios/libexec#
root@stg-nagios01:/usr/local/nagios/libexec# /usr/local/nagios/libexec/messageone_recovery RECOVERY Test_Service Host_Alias Host_Address HARD Current_Time Service_Is_OK "http://response.url" [email protected]
/usr/local/nagios/libexec/messageone_recovery: 14: [: RECOVERY: unexpected operator
root@stg-nagios01:/usr/local/nagios/libexec#

Re: Is it possible to have 2 notifications template

Posted: Wed Dec 04, 2013 1:33 pm
by abrist
hmmm. How about:

Code: Select all

#! /bin/sh

NOTIFICATIONTYPE=$1
SERVICEDESC=$2
HOSTALIAS=$3
HOSTADDRESS=$4
SERVICESTATE=$5
LONGDATETIME=$6
SERVICEOUTPUT=$7
SERVICEACTIONURL=$8
CONTACTEMAIL=$9


if [ "$NOTIFICATIONTYPE" == "RECOVERY" ] 
then
    /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;

fi
I tested it and it works . . .

Re: Is it possible to have 2 notifications template

Posted: Thu Dec 05, 2013 11:34 am
by cesar.garza
Still getting error. is there any dependencies for that ? I have attached a screenshot so you can see if i am doing anything wrong.

Re: Is it possible to have 2 notifications template

Posted: Thu Dec 05, 2013 2:04 pm
by abrist
What is your default shell (/bin/sh)?
Try changing the sha-bang from:

Code: Select all

#!/bin/sh
To:

Code: Select all

#!/bin/bash