Page 5 of 5

Re: Convert attachement bin to txt

Posted: Tue Dec 03, 2013 10:35 am
by vinothsethuram
Problem is not because of the changes.

Can we make the same change for my host notification also?

Code: Select all

define command{
        command_name    notify-host-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $LONGHOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
        }

Re: Convert attachement bin to txt

Posted: Tue Dec 03, 2013 12:43 pm
by tmcdonald
vinothsethuram wrote:Problem is not because of the changes.
Are you sure? To me it sounds like the issues appeared after I had you put in the sed command. I want to make sure I understand you. We made a change to your notify-service-by-email command (adding sed) and now you want to make that same change to your notify-host-by-email command, correct?

If this is the case, here is your new notify-host-by-email command:

Code: Select all

define command{
        command_name    notify-host-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $LONGHOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | sed 's/\r//' | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
        }

Re: Convert attachement bin to txt

Posted: Tue Dec 03, 2013 1:34 pm
by vinothsethuram
Thank you so much . If I use $HOSTOUPT$, I'm getting

Notification Type: CUSTOM
Host: www.ABCD.com
State: UP
Address: 000.00.013.140
Info: HTTP OK: HTTP/1.1 200 OK - 417515 bytes in 0.093 second response time

Date/Time: Tue Dec 3 13:30:29 EST 2013

and If I use $LONGHOSTOUTPUT$ then I'm getting


Notification Type: CUSTOM
Host: www.staples.com
State: UP
Address: 000.00.013.140
Info:

Date/Time: Tue Dec 3 13:27:56 EST 2013

$LONGHOSTOUTPUT$ should give the detailed info, but info is blank.



Any thoughts on this?

Re: Convert attachement bin to txt

Posted: Tue Dec 03, 2013 1:48 pm
by slansing
You should have BOTH $HOSTOUTPUT$ and $LONGHOSTOUTPUT$ together.. otherwise you will be missing the first line of status output, be sure that you spell these macros correctly as you posted "$HOSTOUPT$".

Use them together as previously posted "$HOSTOUTPUT$$LONGHOSTOUTPUT$".

Realize this... that this will only change your host notifications, you need to do the above for services as well, using $SERVICEOUTPUT$. I noticed that you are using hosts as an example, if your hosts are default and only use a ping check you will only get one line, the ping check should never go beyond one line of data.

Re: Convert attachement bin to txt

Posted: Tue Dec 03, 2013 2:49 pm
by vinothsethuram
Ok got it. After adding both parameters ,its working as expected .


For some services, custom notification is sending email, but for few not receiving custom notification. This issue exist even before this changes. Any thoughts?

Re: Convert attachement bin to txt

Posted: Tue Dec 03, 2013 2:54 pm
by tmcdonald
vinothsethuram wrote:For some services, custom notification is sending email, but for few not receiving custom notification. This issue exist even before this changes. Any thoughts?
If this is a different issue than the one just solved, please open a new thread so we can close this one.

Re: Convert attachement bin to txt

Posted: Tue Dec 03, 2013 2:56 pm
by vinothsethuram
Sure, I'll open a new thread. Thank you for all your help. Really useful forum for Nagios users