12 Zabbix4.4.0系統sendEmail郵件報警優化

點擊返回:自學Zabbix之路html

點擊返回:自學Zabbix4.0之路bash

點擊返回:自學zabbix集錦運維

12 Zabbix4.4.0系統sendEmail郵件報警優化post

接上一章節  Zabbix4.4.0系統教你實現sendEmail郵件報警測試

1. 測試時告警的腳本

#!/bin/bash
to=$1        
subject=$2   
message=$3   
#url=$4
/usr/local/bin/sendEmail -f zabbix_yk@163.com -t "$to" -s smtp.163.com -u "$subject" -o message-content-type=html -o message-charset=utf8 -xu zabbix_yk@163.com -xp ************ -m "$message" 

 測試發現告警郵件的內容形成運維人員極度不適。優化

2. 優化後告警的腳本

 參數賦值後,告警按行輸出。url

#!/bin/bash

SMTP_server='smtp.163.com'
username='zabbix_yk@163.com'
password='**********'
from_email_address='zabbix_yk@163.com'
to_email_address="$1"
message_subject_utf8="$2"
message_body_utf8="$3"

message_subject_gb2312=`iconv -t GB2312 -f UTF-8 << EOF
$message_subject_utf8
EOF`
[ $? -eq 0 ] && message_subject="$message_subject_gb2312" || message_subject="$message_subject_utf8"

message_body_gb2312=`iconv -t GB2312 -f UTF-8 << EOF
$message_body_utf8
EOF`
[ $? -eq 0 ] && message_body="$message_body_gb2312" || message_body="$message_body_utf8"

sendEmail='/usr/local/bin/sendEmail'
set -x
$sendEmail -s "$SMTP_server" -xu "$username" -xp "$password" -f "$from_email_address" -t "$to_email_address" -u "$message_subject" -m "$message_body" -o message-content-type=text -o message-charset=gb2312 

優化後郵件告警內容排版:spa

 

 

 ......server

相關文章
相關標籤/搜索