环境 | ip | hostname | 要安装的应用 |
服务器 | 192.168.59.131 | server | lamp架构 zabbix server zabbix agent |
客户端 | 192.168.59.133 | 139 | zabbix agent |
安装服务
[root@server ~]# dnf -y install postfix mailx
启动
[root@server etc]# systemctl enable --now postfix Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service. [root@server etc]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 100 127.0.0.1:25 0.0.0.0:* LISTEN 0 128 0.0.0.0:10050 0.0.0.0:* LISTEN 0 128 0.0.0.0:10051 0.0.0.0:* LISTEN 0 128 0.0.0.0:9000 0.0.0.0:* LISTEN 0 80 *:3306 *:* LISTEN 0 128 *:80 *:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 100 [::1]:25 [::]:*
手动发送邮件
[root@server etc]# echo "biedengle"|mail -s ‘test‘ 790650910@qq.com
配置
[root@server etc]# vim /usr/local/etc/zabbix_server.conf ### Option: AlertScriptsPath # Full path to location of custom alert scripts. # Default depends on compilation options. # To see the default path run command "zabbix_server --help". # # Mandatory: no # Default: #取消注释修改绝对路径 AlertScriptsPath=/usr/local/share/zabbix/alertscripts [root@server etc]# vim /usr/local/share/zabbix/alertscripts/sendmail.sh #!/bin/bash msg=$(echo $1 | tr "\r\n" "\n" ) sub=$(echo $2 | tr "\r\n" "\n" )
email=$3 echo $msg |mail -s $sub $email
[root@server etc]# /usr/local/share/zabbix/alertscripts/sendmail.sh ‘biedengle‘ ‘zwy‘ ‘790650910@qq.com‘
配置本地邮箱脚本
用第三方邮箱配置本地脚本
[root@server ~]# vim /etc/mail.rc set SMTP=smtp.163.com set SMTP-AUTH=login set SMTP-AUTH-USER=x790650910@163.com set SMTP-AUTH-PASSWORD=TYRKRTKZYGCHLWRA set FROM=x790650910@163.com
[root@server ~]# echo ‘jjyy‘|mail -s ‘hehe‘ 790650910@qq.com
原文:https://www.cnblogs.com/Mariko/p/14798013.html