Page 4 of 5

Re: Convert attachement bin to txt

Posted: Mon Dec 02, 2013 3:37 pm
by vinothsethuram
Thanks a ton. It fixed now. What was the issue? Could you please explain briefly ?



And more over , please look at this command which is used to notify host and let me know if any changes required.

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: Mon Dec 02, 2013 3:43 pm
by tmcdonald
Before we get into that, what plugin are you using? Is this a standard Nagios plugin? Is it a third-party? Did you develop it yourself? Is there a link to it?

The problem is that the /bin/mail program sees any input containing windows line-endings as a .bin file and assumes it will have binary data, so it makes it an attachment. In this case, I simply had the "sed" program remove those line-endings before sendig it off to /bin/mail.

Now this is definitely a bit of a hack since Nagios should not be the culprit here, which is why I am asking about the plugin. There might be a better way, such as fixing the plugin itself.

Re: Convert attachement bin to txt

Posted: Mon Dec 02, 2013 3:45 pm
by vinothsethuram
And one more help.

Email doesn't have complete string.. Nagios web UI is showing the complete html string but email is having halt content, remaining half contents are missing in email. is there any size limit for alert emails.

Re: Convert attachement bin to txt

Posted: Mon Dec 02, 2013 4:15 pm
by tmcdonald
You haven't told us what plugin you are using.

Re: Convert attachement bin to txt

Posted: Mon Dec 02, 2013 4:17 pm
by vinothsethuram
I, m using Nagios core 4.0.1. No external plugins.

Thanks
Vinoth

Re: Convert attachement bin to txt

Posted: Mon Dec 02, 2013 4:22 pm
by tmcdonald
You have to be using a plugin because there is literally no other way that Nagios can function.

I would assume you're using check_http in this case?

Re: Convert attachement bin to txt

Posted: Mon Dec 02, 2013 4:32 pm
by vinothsethuram
Yes, I'm using check_http

Re: Convert attachement bin to txt

Posted: Mon Dec 02, 2013 4:40 pm
by tmcdonald
In this case I think the web page you are checking is returning the windows-style line endings. Remove the sed portion from the notify-service-by-email command for now and we'll see what we can come up with for a solution.

Is this happening for all HTTP checks or just a certain few?

Re: Convert attachement bin to txt

Posted: Mon Dec 02, 2013 9:20 pm
by vinothsethuram
Behaviour is different. Few mails having complete response, few having partial and few emails are emplty...

Re: Convert attachement bin to txt

Posted: Tue Dec 03, 2013 10:21 am
by tmcdonald
vinothsethuram wrote:Behaviour is different. Few mails having complete response, few having partial and few emails are emplty...
Did you change the notify-service-by-email command back to what it was before I had you add in the sed?