Zabbix(二)之Zabbix报警机制,Zabbix进阶操作,监控案例
一、Zabbix报警机制
邮件,短信,即时消息,微信
[[email protected] ~]# yum -y install postfix
[[email protected] ~]# systemctl start postfix
[[email protected] ~]# systemctl enable postfix
[[email protected] ~]# netstat -utlnp|grep 25
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 25544/master
tcp6 0 0 ::1:25 :::* LISTEN 25544/master
[[email protected] ~]# echo "127.0.0.1 zabbixserver" >> /etc/hosts
[[email protected] ~]# yum -y install mailx
创建触发器
设置邮件服务器
创建动作
测试
[[email protected] ~]# useradd yaya13
[[email protected] ~]# useradd yaya11
[[email protected] ~]# useradd yaya12
[[email protected] ~]# mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 [email protected] Tue Jul 21 17:57 20/797 "Problem: User_gt_23"
& 1
Message 1:
From [email protected] Tue Jul 21 17:57:53 2020
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
From: <[email protected]>
To: <[email protected]>
Date: Tue, 21 Jul 2020 17:57:53 +0800
Subject: Problem: User_gt_23
Content-Type: text/plain; charset="UTF-8"
Status: R
Problem started at 17:57:51 on 2020.07.21
Problem name: User_gt_23
Host: web100
Severity: Warning
Original problem ID: 21
二、Zabbix进阶操作
1.自动发现
自动发现可以实现,发现主机,添加主机,添加主机到组,连接模板等
创建自动发现规则
创建Action动作(发现主机后自动执行什么动作)
通过动作,执行添加主机,链接模板到主机等操作
2.主被监控
创建新的被监控主机(主动监控)
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# systemctl disable firewalld
[[email protected] ~]# yum -y install gcc pcre-devel
[[email protected] ~]# tar -xf zabbix-3.4.4.tar.gz
cd[[email protected] ~]# cd zabbix-3.4.4/
[[email protected] zabbix-3.4.4]# ./configure --enable-agent
[[email protected] zabbix-3.4.4]# make install
[[email protected] zabbix-3.4.4]# cd /root/
[[email protected] ~]# vim /usr/local/etc/zabbix_agentd.conf
93 #Server=127.0.0.1 ==>>注释改行
118 StartAgents=0 ==>>禁止被动监控(有服务进程没有端口)
132 ServerActive=192.168.2.5 ==>>监控服务器IP,一定要取消127.0.0.1
145 Hostname=web201 ==>>告诉监控器,是谁发的数据信息,一定要和zabbix服务器监控的主机名一致(后面设置)
183 RefreshActiveChecks=120 ==>>默认120秒检测一次
[[email protected] ~]# ps -C zabbix_agentd
PID TTY TIME CMD
9466 ? 00:00:00 zabbix_agentd
9467 ? 00:00:00 zabbix_agentd
9468 ? 00:00:00 zabbix_agentd
[[email protected] ~]# netstat -ntlup|grep :10050
配置监控服务器
复制已有监控模板
修改监控模式为主动模式
调用复制的模板监控,以主动模式运行的agentd服务的客户端
查看监控数据
3.聚合图形与拓扑图
三、监控案例
1.监控nginx服务状态
2.监控网络状态