Zabbix configuration - Action -


the action i'm configuring used sending email notification. problem if use macros in action's name , message email not send out, if using plain text email can sent out succesfully. i'm using media type of script , script job of sending email. script below:

#!/bin/sh export smtpemailfrom=zabbix@yourdomain.com export zabbixemailto=$1 export zabbixsubject=$2 export zabbixbody=$3 export smtpserver=yoursmtpserver.com export smtplogin=smtpuser export smtppass=smtppassword  /usr/bin/sendemail -f $smtpemailfrom -t $zabbixemailto -u $zabbixsubject -m $zabbixbody -s $smtpserver:25 -xu $smtplogin -xp $smtppass 

i wondering if reason special chars in message, if add quotation around subject , body, still not work.

it advisable put input variables in double quotes.

for instance, email subject consist of multiple words. following not work might intended:

$ export subject=hello world $ echo $subject hello 

similarly, curly braces used in zabbix macros have special meaning shell, see bash subshell creation curly braces question.

therefore, should double quote variable expansion, @ least variables not sure content:

#!/bin/sh export smtpemailfrom=zabbix@yourdomain.com export zabbixemailto="$1" export zabbixsubject="$2" export zabbixbody="$3" export smtpserver=yoursmtpserver.com export smtplogin=smtpuser export smtppass=smtppassword  /usr/bin/sendemail -f $smtpemailfrom -t "$zabbixemailto" -u "$zabbixsubject" \             -m "$zabbixbody" -s $smtpserver:25 -xu $smtplogin -xp "$smtppass" 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -