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.
ttsvetanov
Posts: 15 Joined: Tue Jun 26, 2018 8:46 am
Post
by ttsvetanov » Fri Feb 14, 2020 9:11 am
Hello community!
I am using nagios 4.4.5 and i am receiving errors when i add argument with character encoding to my command.
This is the command:
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 <[email protected] >"
And it's working fine in this way. But when i add
-a "Content-Type: text/plain; charset=UTF-8" " :
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 <[email protected] >" -a "Content-Type: text/plain; charset=UTF-8"
It's not sending any mail. Nagios log gives me:
wproc: stderr line 01: /bin/sh: 1: Syntax error: Unterminated quoted string
Any ideas?
Thank you!
Box293
Too Basu
Posts: 5126 Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:
Post
by Box293 » Mon Feb 17, 2020 7:14 pm
What is the actual mail binary?
Perhaps instead of:
-a "From: someone <[email protected] >" -a "Content-Type: text/plain; charset=UTF-8"
Try:
-a "'From: someone <[email protected] >'; Content-Type: text/plain; charset=UTF-8"
The first troubleshooting test I would do would be from the command line as the nagios user with all the variables expanded out. Basically lets remove Nagios from the equation and test purely the commands.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new
Privacy Policy .
ttsvetanov
Posts: 15 Joined: Tue Jun 26, 2018 8:46 am
Post
by ttsvetanov » Tue Feb 18, 2020 3:30 am
I am using sendmail.
The command is working fine executed from the command line. With:
I receive
stderr line 01: /bin/sh: 1: Syntax error: Unterminated quoted string
Box293
Too Basu
Posts: 5126 Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:
Post
by Box293 » Tue Feb 18, 2020 4:32 pm
Can you show us the full command and output from the commands we requested.
ttsvetanov wrote: I receive
stderr line 01: /bin/sh: 1: Syntax error: Unterminated quoted string
Is this the output when running independently ?
The more detailed information you provide, the quicker your problem can be resolved.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new
Privacy Policy .
ttsvetanov
Posts: 15 Joined: Tue Jun 26, 2018 8:46 am
Post
by ttsvetanov » Fri Feb 21, 2020 4:32 am
Successfull received mail, but it's not taking the arguments after
-a . The mail is from
[email protected] with content "текÑÑ‚ на кирилица".
Successfull received mail with successfull taken argument "From" and "Content-Type".
The mail is from
[email protected] and the content is "текст на кирилица".
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Fri Feb 21, 2020 7:47 am
You need to move the -a arguments before the send to email
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 <[email protected] >" $CONTACTEMAIL$
ttsvetanov
Posts: 15 Joined: Tue Jun 26, 2018 8:46 am
Post
by ttsvetanov » Fri Feb 21, 2020 9:30 am
Well i tried with the following command line:
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: [email protected] <[email protected] >" -a "Content-Type: text/plain; charset=UTF-8" $CONTACTEMAIL$
Again no mail with the following in nagios.log:
wproc: stderr line 01: /bin/sh: 1: Syntax error: Unterminated quoted string
Again, when i remove
-a "Content-Type: text/plain; charset=UTF-8"
from the line, i am receiving mails.
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Fri Feb 21, 2020 10:54 am
Hmm, can I have you try changing it to single quotes
Code: Select all
-a 'Content-Type: text/plain; charset=UTF-8'
ttsvetanov
Posts: 15 Joined: Tue Jun 26, 2018 8:46 am
Post
by ttsvetanov » Fri Feb 21, 2020 3:40 pm
with
Code: Select all
-a 'Content-Type: text/plain; charset=UTF-8':
[1582317513] EXTERNAL COMMAND: SEND_CUSTOM_HOST_NOTIFICATION;$NameOfTheHost$;0;Nagios Admin;qwww
[1582317528] wproc: Core Worker 16659: job 266 (pid=21826) timed out. Killing it
[1582317528] wproc: CHECK job 266 from worker Core Worker 16659 timed out after 30.01s
[1582317528] wproc: early_timeout=1; exited_ok=0; wait_status=0; error_code=62;
[1582317528] wproc: Core Worker 16659: job 266 (pid=21826): Dormant child reaped
ttsvetanov
Posts: 15 Joined: Tue Jun 26, 2018 8:46 am
Post
by ttsvetanov » Mon Feb 24, 2020 4:34 am
Even tried with:
Code: Select all
command_line /usr/bin/printf "%b" "Здрасти, това тук е тестов текст на кирилица, изпратен от NAGIOS CGI." | /usr/bin/mail -a "Content-Type: text/plain; charset=UTF-8" -s "Заглавие на тестовия мейл"
And again i received unterminated quoted string...