1、工作中会经常监听一些端口(添加完毕后,需等20分钟左右才出图)
组态---模板--新建模板(如果没有群组可先建立群组)
![](https://img.haomeiwen.com/i2032456/0931a8f2c3b3a8d1.png)
![](https://img.haomeiwen.com/i2032456/0ac5e838a10b9e01.png)
![](https://img.haomeiwen.com/i2032456/d70cf5cd66b8f0ea.png)
![](https://img.haomeiwen.com/i2032456/75357a7f56d22830.png)
![](https://img.haomeiwen.com/i2032456/9926384b6084d8a2.png)
![](https://img.haomeiwen.com/i2032456/65a7037ae2ab89ee.png)
![](https://img.haomeiwen.com/i2032456/c2275bc5ac0e163e.png)
![](https://img.haomeiwen.com/i2032456/227f17e90499bf63.png)
![](https://img.haomeiwen.com/i2032456/6537b9d098953001.png)
![](https://img.haomeiwen.com/i2032456/942294f7ba2415c1.png)
![](https://img.haomeiwen.com/i2032456/d4c928403fa64814.png)
邮件报警添加
1、安装sendmail
[root@server05~]# service postfix stop #linux默认使用postfix邮件服务,先关闭postfix,ss –tnl查看25端口关闭监听
[root@server05~]#yum install sendmail
[root@server05~]# vim /etc/mail.rc #在后面添加相关发件人内容
set bsdcompat
set sendcharsets=iso-8859-1,utf-8
set from=xxxxx@163.com
set smtp=mail.163.com:25
set smtp-auth-user=xxxxx@163.com #认证用户
set smtp-auth-password=xxxx #认证密码
[root@server05~]# service sendmail start #sendmail监听25端口
[root@server05~]# echo "test.hahahahaha" | mail -s "test" xxxxx@qq.com #发邮件进行测试
2、添加zabbix邮件报警脚本;
查看zabbix_server.conf 配置文件中指定的alertscripts文件夹的路径,(这个文件夹里面放脚本)
![](https://img.haomeiwen.com/i2032456/653ffc12acf0e30a.png)
![](https://img.haomeiwen.com/i2032456/22ad9c805e34fd8c.png)
编辑脚本
[root@agent zabbix]# cd /usr/share/zabbix/alertscripts
[root@agent alertscripts]# vim sendmail.sh
#!/bin/bash
echo"$3" | mail -s "$2" "$1"
#其中$1是zabbix传递过来的收件人信息,$2是邮件主题,$3是邮件内容;
[root@agent alertscripts]# chmod 777 sendmail.sh
[root@agent alertscripts]# chmod +x sendmail.sh
1)Zabbix进入网页设置邮件报警(创建完后第一次差不多20分钟后才能收到邮件,往后都在很短的时间内收到邮件报警)
选择 管理——示警媒介类型
![](https://img.haomeiwen.com/i2032456/2e03e3b8ee883f54.png)
![](https://img.haomeiwen.com/i2032456/1c1aef3681946338.png)
创建动作
![](https://img.haomeiwen.com/i2032456/e3878f5367a5f562.png)
![](https://img.haomeiwen.com/i2032456/3f9b27641015ce78.png)
![](https://img.haomeiwen.com/i2032456/026206067308636d.png)
![](https://img.haomeiwen.com/i2032456/87b217aaf2c65441.png)
![](https://img.haomeiwen.com/i2032456/4fd6d4ce838fd406.png)
![](https://img.haomeiwen.com/i2032456/6184ee79b00c8f9d.png)
给admin账号添加邮箱地址,(为了收取报警邮件)
![](https://img.haomeiwen.com/i2032456/ce10606e18047039.png)
![](https://img.haomeiwen.com/i2032456/34f3300b5e2c476b.png)
![](https://img.haomeiwen.com/i2032456/c72c1517fed825ec.png)
测试
在监控的另外一台关闭监控的端口,
![](https://img.haomeiwen.com/i2032456/d09514ed945762e6.png)
![](https://img.haomeiwen.com/i2032456/e93e8dcdc7814c98.png)
![](https://img.haomeiwen.com/i2032456/76d0cd30ac08ad0f.png)
过设置的时间后,如果未处理还会再次发送邮件
现在恢复端口
![](https://img.haomeiwen.com/i2032456/6231dbe8ee8b389f.png)
![](https://img.haomeiwen.com/i2032456/bbd14a0695aa0262.png)
收取到成功邮件
![](https://img.haomeiwen.com/i2032456/a64c477f69baf452.png)
网友评论