zabbix邮箱告警

zabbix监控流程及邮箱告警的方式

1.监控流程

2.监控配置流程

本地邮箱告警配置

# 查看包是谁提供的
[root@client ~]# yum provides *bin/mailx
Last metadata expiration check: 3:45:19 ago on Sun 24 Sep 2023 10:28:40 PM EDT.
mailx-12.5-29.el8.x86_64 : Enhanced implementation of the mailx command
Repo        : base
Matched from:
Other       : *bin/mailx
# 下载这个包
[root@client ~]# yum -y install mailx

[root@client ~]# yum provides *bin/sendmail
Last metadata expiration check: 3:52:06 ago on Sun 24 Sep 2023 10:28:40 PM EDT.
postfix-2:3.5.8-2.el8.x86_64 : Postfix Mail Transport Agent
Repo        : base
Matched from:
Other       : *bin/sendmail

sendmail-8.15.2-34.el8.x86_64 : A widely used Mail Transport Agent (MTA)
Repo        : AppStream
Matched from:
Other       : *bin/sendmail
# 下载这个postfix包
[root@client ~]# yum -y install postfix

# 开启postfix 查看端口25
[root@client ~]# systemctl start postfix
[root@client ~]# ss -antl
State      Recv-Q      Send-Q           Local Address:Port            Peer Address:Port     Process     
LISTEN     0           128                    0.0.0.0:10050                0.0.0.0:*                    
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                       [::]:22                      [::]:*                    
LISTEN     0           100                      [::1]:25                      [::]:*                    

做个测试,在虚拟机中echo 一个事务然后发你的邮箱 (如果发送在邮件的垃圾箱中,可以更改你的主机名或者加入白名单)

 # 命令行的方式发送
[root@client ~]# echo "hello world" | mail -s "这是一个测试页面" xxxx@qq.com(写自己的邮箱)

你会在你的邮箱中接受到这条邮件

在这里插入图片描述

在服务端安装mailx、postfix

# 下载要安装的包
[root@server ~]# yum -y install mailx
[root@server ~]# yum -y install postfix

# 开机自启并查看端口
[root@server ~]# systemctl start postfix
[root@server ~]# systemctl enable postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
[root@server ~]# ss -antl
State        Recv-Q       Send-Q              Local Address:Port                Peer Address:Port       Process       
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                     127.0.0.1:9000                     0.0.0.0:*                        
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            80                              *:3306                           *:*                        
LISTEN       0            511                             *:80                             *:*                        
LISTEN       0            128                          [::]:22                          [::]:*                        
LISTEN       0            100                         [::1]:25                          [::]:*                        
[root@server ~]# 

我们可以结合脚本让它自己去触发

# 查看脚本的位置
[root@server ~]# find / -name *script* |grep zabbix
/var/lib/mysql/zabbix/script_param.ibd 
/usr/local/share/zabbix/externalscripts
/usr/local/share/zabbix/alertscripts # 找到这个位置

# 进入这个目录去写脚本
[root@server ~]# cd /usr/local/share/zabbix/alertscripts
[root@server alertscripts]# ll
total 0
[root@server alertscripts]# vim sendmail.sh

在这里插入图片描述

[root@server alertscripts]# cat sendmail.sh 
#!/bin/bash

content=$(echo $1 | tr "\r\n" "\n")
subject=$(echo $2 | tr "\r\n" "\n")
mailto=$3
echo $content | mail -s $subject  $mailto
[root@server alertscripts]# ll
total 4
-rwxr-xr-x. 1 root root 137 Sep 25 03:05 sendmail.sh

定义媒介

配置报警媒介

创建一个媒介类型

在这里插入图片描述在这里插入图片描述

添加之后你就可以在media type这个页面找到

在这里插入图片描述

我们可以点击这个test

在这里插入图片描述

测试成功
在这里插入图片描述

去添加媒介

在这里插入图片描述在这里插入图片描述在这里插入图片描述

配置动作
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述

发送出去

在这里插入图片描述
在这里插入图片描述

第三方邮箱网页配置告警
配置邮箱以及媒介

在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述配置触发动作
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述

手动测试

[root@client ~]# echo "test jjyy" >> /tmp/jjyy
[root@client ~]# 

在这里插入图片描述在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值