[Zabbix] 基礎主機監控設定 - 客製化腳本發信

使用客製化腳本發信 


apt-get install ssmtp mailutils
# 備份
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.default
vi /etc/ssmtp/ssmtp.conf

#########################################

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=neilwang@intentarget.com

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=zabbix

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES

AuthUser=發郵件的帳號
AuthPass=發郵件的密碼 #Gmail可開啟兩階段驗證, 使用應用程式密碼

UseSTARTTLS=YES
UseTLS=YES

# 輸出除錯資訊
Debug=YES

#########################################

vi /usr/lib/zabbix/alertscripts/sendgmail.sh 

#########################################

#!/bin/bash

to=$1
subject=$2
body=$3

cat <<EOF | mail -s "$subject" "$to"
$body
EOF

#########################################




1.把客製化的腳本新增至Media type中

2. 將參數{ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE}加進去並更新

3. 點選Administration > Users > Admin > Media


4.針對特定的帳號發警告



建立 Action



如果設定完發現還沒收到信
可以先檢查

User media 有沒有指定


指派客製化的報警腳本給使用者:
  • Go to Administration → Users
  • 打開 the user properties form
  • 在 Media tab,點選  Add

這段是否有做
有的話可以檢查script放置位子是否跟/etc/zabbix/zabbix_server.conf內設定的一樣

留言

這個網誌中的熱門文章

[翻譯] 介紹現代網路負載平衡與代理伺服器

Grafana K6

Linux 事件驅動筆記