
如何使用postfix 完美設定zabbix gmail 通知(中繼到gmail) 實際上,此設定在我的本機電腦上運行,但是當我嘗試在我的真實伺服器上實現此設定時,電子郵件通知失敗,我可以在Administration>audit 中看到以下錯誤>行動
Cannot connect to SMTP server [localhost] [gethost() failed for address 'localhost' [Success]]
我的“/var/log/mail.log”訊息
Aug 26 00:14:31 station1 postfix/smtpd[9385]: connect from localhost.localdomain[127.0.0.1]
Aug 26 00:14:31 station1 postfix/smtpd[9385]: disconnect from localhost.localdomain[127.0.0.1]
Aug 26 00:15:31 station1 postfix/smtpd[9385]: connect from localhost.localdomain[127.0.0.1]
Aug 26 00:15:31 station1 postfix/smtpd[9385]: disconnect from localhost.localdomain[127.0.0.1]
我使用 telnet 命令檢查了我的 postfix gmail 中繼配置,如下所示並連接到 smtp 連接埠 25
telnet localhost 25
我甚至可以從終端發送郵件
mail -s "Test mail" [email protected]
以下是我的媒體設置,這與我的本地計算機上運行的設置相同
輸入電子郵件
SMTP server: localhost
SMTP helo: localhost
SMTP email: zabbix@localhost
這是我的設定。
/etc/主機:
127.0.0.1 localhost.localdomain localhost
<my-ip-here> station1.lab.mycompany.com station1
/etc/zabbix/zabbix_agentd.conf:
# Default:
# Server=
Server=127.0.0.1
### Option: Hostname
# Unique, case sensitive hostname.
# Required for active checks and must match hostname as configured on the server.
#
# Default:
# Hostname=system.uname
Hostname=Zabbix server
### Option: ListenPort
# Agent will listen on this port for connections from the server.
#
# Mandatory: no
# Range: 1024-32767
# Default:
# ListenPort=10050
/etc/zabbix/zabbix_agent.conf:
# This is a config file for zabbix_agent
# To get more information about Zabbix visit http://www.zabbix.com
### Option: Server
# IP address of Zabbix server
# Connections from other hosts will be denied
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
#
# Mandatory: yes
# Default:
# Server=
Server=127.0.0.1
### Option: Timeout
# Spend no more than Timeout seconds on processing
#
# Mandatory: no
# Range: 1-30
# Default:
# Timeout=3
主機名稱:
root@station1:~#hostname
station1.lab.mycompany.com
我的真實伺服器和本機電腦之間的唯一區別是主機名稱。
我什至嘗試將媒體設定更改為伺服器網域名稱和主機名,但沒有用。
請需要協助!
答案1
嘗試在 zabbix 媒體類型設定中將電子郵件伺服器配置為 127.0.0.1,而不是 localhost。如果 localhost 解析為 ::1 且 zabbix_server 編譯時沒有 ipv6 支持,則可能會失敗。
答案2
https://gist.github.com/superdaigo/3754055
更改腳本中的登入密碼,貼上/usr/lib/zabbix/alertscripts
,在通知+使用者的方法中新增腳本的全名(副檔名)。