本文以Centos7主机为例
安装依赖包
yum install dos2unix
|---|----------------------| | 1 | yum install dos2unix |
将我原来mailx脚本内容(https://blog.whsir.com/post-4387.html)
vi /etc/zabbix/alertscripts/mailx.sh
|---|--------------------------------------| | 1 | vi /etc/zabbix/alertscripts/mailx.sh |
#!/bin/bash echo "$3" | mail -s "$2" "$1"
|-----|--------------------------------------------| | 1 2 | #!/bin/bash echo "$3" | mail -s "$2" "$1" |
改成
#!/bin/bash FILE=/tmp/mailxtmp.txt echo "$3" > $FILE dos2unix -k $FILE mail -s "$2" "$1" < $FILE
|-----------|----------------------------------------------------------------------------------------------------| | 1 2 3 4 5 | #!/bin/bash FILE=/tmp/mailxtmp.txt echo "$3" > $FILE dos2unix -k $FILE mail -s "$2" "$1" < $FILE |