//修改客户端的主机名
[root@destop ~]# hostnamectl set-hostname zabbix.server.com
[root@destop ~]# bash
//修改/etc/hosts文件
[root@zabbix ~]# vim /etc/hosts
127.0.0.1 zabbix.service.com
//安装mailx
[root@zabbix ~]# yum -y install mailx
//测试本地发送邮件
[root@zabbix ~]# echo '123' | mail -s 'text' yizhen_w@qq.com
[root@zabbix ~]# userdel -r wyz
[root@zabbix ~]# vim /etc/mail.rc
set from=******** //你的邮箱地址
set smtp=smtp.126.com
set smtp-auth-user=****** //你的邮箱地址
set smtp-auth-password=*******//邮箱密码
set smtp-auth=login
//写脚本
[root@zabbix share]# vim /usr/local/share/zabbix/alertscripts/sendmail.sh
#!/bin/bash
subject=$(echo $2 |tr "\r\n" "\n")
message=$(echo $3 |tr "\r\n" "\n")
echo "$message" | /usr/bin/mail -s "$subject" $1 &>/tmp/sendmail.log
[root@server ~]# cd /usr/local/share/zabbix/
[root@server zabbix]# chown -R zabbix.zabbix alertscripts
[root@server zabbix]# chmod +x alertscripts/sendmail.sh
[root@server ~]# pkill zabbix
[root@server ~]# zabbix_server
[root@server ~]# zabbix_agentd
[root@server ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
[root@server alertscripts]# bash sendmail.sh yizhen_w@qq.com test hello world
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- efsc.cn 版权所有 赣ICP备2024042792号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务