Convert attachement bin to txt

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Re: Convert attachement bin to txt

Post 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$
        }
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Convert attachement bin to txt

Post 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$
        }
Former Nagios employee
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Re: Convert attachement bin to txt

Post 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?
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Convert attachement bin to txt

Post 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.
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Re: Convert attachement bin to txt

Post 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?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Convert attachement bin to txt

Post 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.
Former Nagios employee
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Re: Convert attachement bin to txt

Post by vinothsethuram »

Sure, I'll open a new thread. Thank you for all your help. Really useful forum for Nagios users
Locked