Page 2 of 2

Re: Nagios 4.4.5 email alerts with encoding

Posted: Mon Feb 24, 2020 7:39 am
by scottwilkerson
Earlier you mentioned it worked from the commandline with the -a flags combined, can you try the following

Code: Select all

/usr/bin/printf "%b" "$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress:$HOSTADDRESS$\nInfo: $HOSTOUTPUT$\nDuration: $HOSTDURATION$\nAlias: $HOSTALIAS$\n\nDate/Time: $LONGDATETIME$ \n" | /usr/bin/mail -s "**SITE1 $NOTIFICATIONTYPE$ Host $HOSTNAME$ is $HOSTSTATE$" -a "'From: someone <some@mail.com>'; Content-Type: text/plain; charset=UTF-8" $CONTACTEMAIL$

Re: Nagios 4.4.5 email alerts with encoding

Posted: Tue Feb 25, 2020 3:59 am
by ttsvetanov
scottwilkerson wrote:Earlier you mentioned it worked from the commandline with the -a flags combined, can you try the following

Code: Select all

/usr/bin/printf "%b" "$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress:$HOSTADDRESS$\nInfo: $HOSTOUTPUT$\nDuration: $HOSTDURATION$\nAlias: $HOSTALIAS$\n\nDate/Time: $LONGDATETIME$ \n" | /usr/bin/mail -s "**SITE1 $NOTIFICATIONTYPE$ Host $HOSTNAME$ is $HOSTSTATE$" -a "'From: someone <some@mail.com>'; Content-Type: text/plain; charset=UTF-8" $CONTACTEMAIL$
ttsvetanov wrote:...... With:

Code: Select all

-a "'From: someone <some@mail.com>'; Content-Type: text/plain; charset=UTF-8"
I receive
stderr line 01: /bin/sh: 1: Syntax error: Unterminated quoted string

Re: Nagios 4.4.5 email alerts with encoding

Posted: Tue Feb 25, 2020 2:24 pm
by scottwilkerson
I'm not sure if I am going down the correct path here, but can you show the output of

Code: Select all

su nagios -c 'env|grep LANG'
su nagios -c 'locale'

Re: Nagios 4.4.5 email alerts with encoding

Posted: Wed Feb 26, 2020 9:50 am
by ttsvetanov

Code: Select all

root@nagios:/tmp# su nagios -c 'env|grep LANG'
LANG=en_US.UTF-8
root@nagios:/tmp# su nagios -c 'locale'
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
root@nagios:/tmp#

Re: Nagios 4.4.5 email alerts with encoding

Posted: Thu Feb 27, 2020 11:18 am
by scottwilkerson
ttsvetanov wrote:

Code: Select all

/usr/bin/printf "%b" "$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress:$HOSTADDRESS$\nInfo: $HOSTOUTPUT$\nDuration: $HOSTDURATION$\nAlias: $HOSTALIAS$\n\nDate/Time: $LONGDATETIME$ \n" | /usr/bin/mail -s "**SITE1 $NOTIFICATIONTYPE$ Host $HOSTNAME$ is $HOSTSTATE$" $CONTACTEMAIL$ -a "From: someone <some@mail.com>" -a "Content-Type: text/plain; charset=UTF-8"
I just tested this on a freshly setup Debian 9 system running Nagios Core 4.4.5 with the command above as the only host notification handler and when I took the host down with the following text as the message:

Code: Select all

Здрасти, това тук е тестов текст на кирилица, изпратен от NAGIOS CGI.
I received the following email as expected

Code: Select all

From some@mail.com Thu Feb 27 10:12:38 2020
Return-path: <some@mail.com>
Envelope-to: nagios@localhost
Delivery-date: Thu, 27 Feb 2020 10:12:38 -0600
Received: from nagios by debian9x64 with local (Exim 4.89)
        (envelope-from <some@mail.com>)
        id 1j7Lm9-0003CB-Ur
        for nagios@localhost; Thu, 27 Feb 2020 10:12:37 -0600
Subject: **SITE1 PROBLEM Host localhost is DOWN
From: someone <some@mail.com>
Content-Type: text/plain; charset=UTF-8
To: <nagios@localhost>
X-Mailer: mail (GNU Mailutils 3.1.1)
Message-Id: <E1j7Lm9-0003CB-Ur@debian9x64>
Date: Thu, 27 Feb 2020 10:12:37 -0600

PROBLEM
Host: localhost
State: DOWN
Address:127.0.0.1
Info: Здрасти, това тук е тестов текст на кирилица, изпратен от NAGIOS CGI.
Duration: 0d 0h 0m 0s
Alias: localhost

Date/Time: Thu Feb 27 10:12:37 CST 2020


Re: Nagios 4.4.5 email alerts with encoding

Posted: Mon Mar 02, 2020 4:09 am
by ttsvetanov
Are you using sendmail for mail client?

Re: Nagios 4.4.5 email alerts with encoding

Posted: Mon Mar 02, 2020 4:05 pm
by scottwilkerson
The mailer was mail (GNU Mailutils 3.1.1)

I just opened the text file for the message in vi