自动化运维技术--运维框架

image.png
自动化监控

image.png
zabbix architecture1

image.png
zabbix architecture2

image.png
metric data:指标数据--与合理指标对比,是否超出域值
alerting:threshhold--阈值区间 or 次数3次--即报警
采集各种数据指标--比较合理指标
long trend:长期趋势
采集到不同的数据--它们的处理方式不同
原始数据
变化量
速率
各时间段加起来求和/计数
传感器-->发送给监控系统
监控系统A 被监控系统B
主动监控 A主动发送请求给B,B再发送自己的数据指标给A
被动监控 B直接发送自己的数据指标给A
zabbix 集成系统--自身不能存储数据,需要借助mysql/pgsql
statsd 仅能采集数据
prometheus 集成系统--自身能存储数据--go研发--未来方向
采集--存储--阈值分析/报警--可视化接口/图形展示
zabbix/prometheus 集成系统--图形很low
Graphana 图形展示,可功能定制
zabbix/prometheus+Graphana
agent协议 SNMP协议 如下图实验拓扑
网络压力 多种指标
NVPS:New Values Per Second
存储很可能成为瓶颈--上百台服务器
时间存储系统 时间序列处理数据
网站:https://db-engines.com/en/ranking/time+series+dbms
influxdb/...
prometheus 有存储数据的能力--未来趋势
zabbbix 本身没有存储数据的能力--借助mysql/pgsql
CMDB--资产管理系统
企业资产--记录多少个主机...
程序语言写一个CMDB即可--很简单
配置系统
需要主机清单--从CMDB的API中获取
监控系统
系统内的每个主机都要安装zabbix-agent,通过zabbix-server与zabbix-agent通信进行监控
web架构图如下图1
web架构图

image.png
实验拓扑

image.png
node4: 192.168.1.6 zabbix-server
node1: 192.168.1.7 zabbix-agent
node2: 192.168.1.8 zabbix-agent
node3: 192.168.1.5
同步时间
主机名解析
vim /etc/hosts
192.168.1.7 node1.fgq.com
192.168.1.8 node2.fgq.com
192.168.1.5 node3.fgq.com
192.168.1.6 node4.fgq.com
node4
wget http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
release包可以直接安装为仓库
rpm -ivh zabbix-release-3.5-1.el7.noarch.rpm
cat /etc/yum.repos.d/zabbix.repo
yum repolist
yum list all |grep zabbix
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get zabbix-sender
zabbix-server-mysql -- 自动安装zabbix-server
zabbix-web-mysql -- 自动安装zabbix-web
zabbix-java-gateway -- 用到的时候再安装--基于JMS采集java虚拟机数据
yum -y install mariadb-server
默认会在其他主机上安装(所有不会自动解决依赖关系),此处使用本机安装
配置数据库
vim /etc/my.cnf.d/server.cnf
[mysqld]
skip_name_resolve = on
innodb_file_per_table = on
systemctl start mariadb.service; ss -ntl 3306端口
ls /var/lib/mysql/mysql.sock 本地连接注意此路径
mysql
create database zabbix character set 'utf8'; 支持中文
grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'zbxpass';
本地连接--此处使用
grant all on zabbix.* to 'zabbix'@'192.168.1.%' identified by 'zbxpass';
远程连接
flush privileges;
rpm -ql zabbix-server-mysql
cp /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz ./
gzip -d create.sql.gz
less create.sql 没有"create database"
mysql -uzabbix -h127.0.0.1 -pzbxpass zabbix < create.sql
use zabbix
show tables;
server配置
grep -i "^#####" /etc/zabbix/zabbix_server.conf 配置段
cp /etc/zabbix/zabbix_server.conf{,.bak}
vim /etc/zabbix/zabbix_server.conf
DBHost=127.0.0.1
DBPassword=zbxpass 不使用root用户连接的原因--文件泄露
DBSocket=/var/lib/mysql/mysql.socket
或者命令行符号链接:ln -sv /var/lib/mysql/mysql.sock /tmp/
systemctl start zabbix-server.service ; ss -ntl 端口10051
rpm -ql zabbix-web|less
vim /etc/httpd/conf.d/zabbix.conf
添加信息:
# php_value date.timezone Europe/Riga 时区更改
php_value date.timezone Asia/Shanghai 否则启动不起来--只对zabbix程序生效
或者 vim /etc/php.ini 搜索/timezone
;date.timezone = 添加时区设置,对所有php程序都生效(根据需要决定更改哪个)
systemctl start httpd.service
小作业:把zabbix配置成php-fpm来运行
浏览器:192.168.1.6/zabbix
如下如图1-13所示
图1

image.png
图2

image.png
图3

image.png
图4

image.png
图5

image.png
图6

image.png
图7

image.png
图8

image.png
图9

image.png
图10:更新界面颜色

image.png
图11:更改密码,显示中文

image.png
图12

image.png
图13

image.png
zabbix 逻辑架构

image.png
zabbix 逻辑架构 如上图
hosts-->host groups
items-->applications
triggers-->OK,PROBLEM
ok-->problem:events
problem-->ok:recovers
actions
CONDITION(发生events),OPERATION(scripts,notification)
notification升级--problem--engineer--未修复-->manager--未修复-->boss
加进主机
定义items--applications
定义triggers
定义actions--订阅CONDITION--采取OPERATION
看长期趋势
订阅graph/screen/slap show/...
zabbix server processes
zabbix poller:轮询器--周期性采集一次数据
internal:基于自身的监控
maintenance:维护--某事件段内,监控到异常不会报警
watchdog:监控自身
housekeeper:数据保存多久以后就清除,避免性能降低
pinger:监控各个主机是否正常在线
poller:采集数据
httppoller:测试web服务器的性能--发送请求页面--多久可以把请求内容发给我
discoverer:主机发现
nodewatcher:监控节点
timer:计时器--每隔多久采集一次监控项
escalator:报警升级
被监控主机允许通过多种方式被采集数据
agent代理程序的接口 监控主机指标
SNMP接口 监控网络指标--主机的吞吐
JMX接口 仅监控此主机上的java进程
IPMI接口 硬件级的某些指标
主机支持的前提下,一个主机可以通过4个接口传输不同类型的信息,最少应该有一个接口
配置agent
node1/2--agent (node3/4--先不安装zabbix agent--后面做代理时使用)
wget http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
rpm -ivh zabbix-release-3.5-1.el7.noarch.rpm
yum clean all
yum repolist
yum -y install zabbix-agent.x86_64 zabbix-sender.x86_64
rpm -ql zabbix-agent
grep -i "^#####" /etc/zabbix/zabbix_agentd.conf
Passive checks related 被动监控
站在agent端看:server请求数据,agent返回给server
Active checks related 主动监控
可以部分主动,部分被动
cp /etc/zabbix/zabbix_agentd.conf{,.bak}
vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.1.6
ServerActive=192.168.1.6
Hostname=node1/2/3.fgq.com
systemctl start zabbix-agent.service ; ss -ntl 10050端口
systemctl status zabbix-agent.service 查看细节信息
图形界面操作 如下图
参考文档https://www.zabbix.com/documentation/4.0/zh/manual/config
图1

image.png
图2

image.png
图3

image.png
图4

image.png
图5

image.png
图5-1

image.png
图5-2

image.png
图5-3

image.png
图6

image.png
图7

image.png
图8

image.png
图9-1:定义网卡接口流量--再创建一个item(过程类似前面,不赘述)

image.png
图9-2

image.png
图9-3

image.png
图10-1:clone

image.png
图10-2:out packets

image.png
图10-3:in bytes

image.png
图10-4:out bytes

image.png
图10-5:in bytes graph

image.png
图11-1:triggers

image.png
图11-2

image.png
图11-3

image.png
图11-4

image.png
图11-5

image.png
图11-6

image.png
图11-7:为了恢复正常,可以把各个主机的ping都关闭

image.png
图12-1:action--报警后的操作--先定义用户邮箱

image.png
图12-2

image.png
图12-3

image.png
图12-4

image.png
图12-5

image.png
图12-6

image.png
图12-7

image.png
图12-8

image.png
图12-9

image.png
图12-10

image.png
图12-11

image.png
图12-12

image.png
图12-13

image.png
图12-14

image.png
图12-15

image.png
图12-16

image.png
图13-1:发送邮件给本机

image.png
图13-2

image.png
图13-3

image.png
图13-4:此处出错,待查,掌握步骤即可

image.png
图13-5

image.png
图14-1:图形展示

image.png
图14-2

image.png
图14-3

image.png
图14-4

image.png
依赖关系:
如:主机down掉,所有触发器都报警--不好
主机down掉--仅报警主机信息即可,其他依赖主机的触发项就不用再报警了
网络故障--就不要报警主机信息,仅报警网络信息即可
具体操作--业务逻辑决定
避免报警信息爆棚
web页面打不开--web服务没有故障,可能是不能从redis中读取信息
web主机依赖DB主机/redis主机--redis主机down--不要报警web主机信息即可
被依赖者故障--依赖者就不用再报警了
图1

image.png
图2

image.png
图3

image.png
图4

image.png
action
condition和operation
node1
yum -y install redis
vim /etc/redis.conf
bind 0.0.0.0
systemctl start redis ; ss -ntl 6379端口
vim /etc/zabbix/zabbix_agentd.conf
EnableRemoteCommands=1
LogRemoteCommands=1 执行的命令记录日志
systemctl restart zabbix-agent.service ; ss -ntl 10050端口
visudo
#Defaults !visiblepw 注释掉,允许没有tty终端的用户执行命令
# %wheel ALL=(ALL) ALL 注释此行
%wheel ALL=(ALL) NOPASSWD: ALL 启用此行
zabbix ALL=(ALL) NOPASSWD: ALL (允许zabbix无密码操作--all权限)
结合下面的图形来操作,关闭redis是否可以自动恢复故障
图1-1:监控redis

image.png
图1-2

image.png
图1-3

image.png
图1-4

image.png
图1-5:node1上关闭redis服务器

image.png
图1-6:node1上开启redis服务器

image.png
图1-7

image.png
图1-8:定义一个triggers

image.png
图1-9

image.png
图1-10

image.png
图1-11

image.png
图1-12:down掉redis

image.png
图1-13:开启redis服务器

image.png
图1-14:定义行动

image.png
图1-15

image.png
图1-15'

image.png
图1-16:任务复杂时,可以写一个脚本来执行(知道即可,不演示了)

image.png
图1-17:如果解决故障需要很多步骤/命令,可以点击New填加

image.png
图1-18

image.png
图1-19:关闭redis服务,出现报警后看是否可以自动修复故障

image.png
图1-20:自动恢复

image.png
图1-21:基于ssh连接恢复故障

image.png
图1-22:故障

image.png
图1-23:ssh连接故障恢复

image.png
图1-24:Type重新恢复为"Custom script"

image.png

image.png
邮箱报警
node4
grep "Alert*" /etc/zabbix/zabbix_server.conf
AlertScriptsPath=/usr/lib/zabbix/alertscripts 脚本存放路径
vim /usr/lib/zabbix/alertscripts/send_mail.py 报警脚本(163邮箱)
#!/bin/env python
#coding:utf-8
import smtplib
from email.mime.text import MIMEText
from sys import argv
mailto_list=[]
mail_host="smtp.163.com:25"
mail_user="fgq_qianggedu@163.com"
mail_pass="xxxxxxxxxxx"
#mail_postfix="163.com" #发件箱的后缀
debug_level=0
def send_mail(to_list,sub,content):
me=mail_user
msg = MIMEText(content,_subtype='plain',_charset='utf-8')
msg['Subject'] = sub
msg['From'] = me
msg['To'] = ";".join(to_list)
try:
server = smtplib.SMTP()
server.set_debuglevel(debug_level)
server.connect(mail_host)
server.login(mail_user,mail_pass)
server.sendmail(me, to_list, msg.as_string())
server.close()
return True
except Exception, e:
print str(e)
return False
if __name__ == '__main__':
try:
mailto_list=argv[1].split(';')
sub=argv[2]
content=argv[3]
except:
print "python send_mail.py 'user1@xx.com;user2@xx.com' sub content"
exit()
if send_mail(mailto_list,sub,content):
print "发送成功"
else:
print "发送失败"
接下来操作如下图
图1-0

image.png
图1-1

image.png
图1-2

image.png
图1-3

image.png
图1-4

image.png
图1-5:手动关闭redis,恢复后,是否发邮件

image.png
微信报警
微信企业号申请 地址: https://work.weixin.qq.com/
需要扫码关注设置管理员
接下来如下图0-->图5
记录3个信息:Corpid Secret Agentid
node4
wget https://pypi.python.org/packages/c3/38/d95ddb6cc8558930600be088e174a2152261a1e0708a18bf91b5b8c90b22/requests-2.18.3.tar.gz
tar zxvf requests-2.18.3.tar.gz
cd requests-2.18.3/
python setup.py build
python setup.py install 可能要等一会,不要急于ctrl+c
yum -y install git
git clone https://github.com/X-Mars/Zabbix-Alert-WeChat.git
cp Zabbix-Alert-WeChat/wechat.py /usr/lib/zabbix/alertscripts/ 本身就带有执行权限
vim /usr/lib/zabbix/alertscripts/wechat.py
如下图6-1
图形界面设置如下图6-2-->图15
脚本内容
#!/usr/bin/python2.7
#_*_coding:utf-8 _*_
#auther:
import requests,sys,json
import urllib3
urllib3.disable_warnings()
reload(sys)
sys.setdefaultencoding('utf-8')
def GetToken(Corpid,Secret):
Url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken"
Data = {
"corpid":Corpid,
"corpsecret":Secret
}
r = requests.get(url=Url,params=Data,verify=False)
Token = r.json()['access_token']
return Token
def SendMessage(Token,User,Agentid,Subject,Content):
Url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=%s" % Token
Data = {
"touser": User, # 企业号中的用户帐号,在zabbix用户Media中配置,如果配置不正常,将按部门发送。
#"totag": Tagid, # 企业号中的部门id,群发时使用。
"msgtype": "text", # 消息类型。
"agentid": Agentid, # 企业号中的应用id。
"text": {
"content": Subject + '\n' + Content
},
"safe": "0"
}
r = requests.post(url=Url,data=json.dumps(Data),verify=False)
return r.text
if __name__ == '__main__':
User = sys.argv[1] # zabbix传过来的第一个参数
Subject = sys.argv[2] # zabbix传过来的第二个参数
Content = sys.argv[3] # zabbix传过来的第三个参数
Corpid = "xxxxxxx" # CorpID是企业号的标识
Secret = "xxxxxxx" # Secret是管理组凭证密钥
#Tagid = "1" # 通讯录标签ID
Agentid = "xxxxxxx" # 应用ID
Token = GetToken(Corpid, Secret)
Status = SendMessage(Token,User,Agentid,Subject,Content)
print Status
图0

image.png
图1

image.png
图2

image.png
图3

image.png
图4

image.png
图5

image.png
图6-1

image.png
图6-2

image.png
图7

image.png
图8

image.png
图9

image.png
图10

image.png
图11

image.png
图12

image.png
图13:手动关闭redis

image.png
图14:手动开启redis

image.png
图15:微信信息

image.png
图像展示
图1

image.png
图2

image.png
图3

image.png
图4

image.png
图5

image.png
图6

image.png
图7

image.png
图8

image.png
图9

image.png
图10-1

image.png
图10-2

image.png
图10-3

image.png
图10-4

image.png
图10-5

image.png
图10-6:再创建一个screen

image.png
图10-7

image.png
图10-8

image.png
图10-9

image.png
图10-10

image.png
创建模板
自定义模板--自己的特殊功能使用
别人定义好的模板--网络搜
添加node2为zabbix agent

1-1

1-2

1-3

1-4

1-5

1-6

1-7

1-8

1-9

1-10

1-11
宏
宏类似变量,代替字符串的内容
内键的宏
https://www.zabbix.com/documentation/3.4/manual/appendix/macros/supported_by_location
全局/模板/主机--宏
3个地方都有宏,最高级别是主机--使用范围越小,使用可能性最高(参考文档)
node2 开启redis服务
yum -y install redis
vim /etc/redis.conf
bind 0.0.0.0
systemctl start redis; ss -ntl 6379端口

1-1

1-2

1-3

1-4

1-5
全局级别定义宏

1-6

1-7

1-8

1-9
模板级别定义宏

1-10

1-11

1-12把0变为down

1-13把0变为down

1-14把0变为down

1-15把0变为down
主机级别定义宏

1-16

1-17

1-18关闭redis服务
自动发现
node4
zabbix_get -h
zabbix_get -s 192.168.1.7 -p 10050 -k "agent.hostname"
zabbix_get -s 192.168.1.7 -p 10050 -k "agent.ping" 在线就回应为1
对方回应,即可对其进行监控
发现操作--zabbix初创时使用,如果已经设置好了,在添加新的主机,自己手动添加就行;
避免网络发现占用带宽资源,因此初创zabbix后,就把网络发现功能关闭最佳;

1

2

定义发现规则

添加发现规则

发现规则添加成功

定义发现主机后的操作

Action的条件

Action的条件触发后的操作

完成的状态

已经发现

添加成功

监控--仪表盘OK

禁用启用
自定义key
node1
free |awk '/^Mem/{print$3}'
which free 查看全路径;命令不在path变量里,使用全路径(最好都使用)
vim /etc/zabbix/zabbix_agentd.d/memory.conf
UserParameter=mem.used,/usr/bin/free -m|awk '/^Mem/{print$3}'
systemctl restart zabbix-agent.service ; ss -ntl
node4
zabbix_get -s 192.168.1.7 -p 10050 -k "mem.used" 有返回值,自定义ok
node1
vim /etc/zabbix/zabbix_agentd.d/test.conf
UserParameter=file.cat[*],cat $1
[*]就表示传递参数$1
systemctl restart zabbix-agent.service
node4
zabbix_get -s 192.168.1.7 -p 10050 -k "file.cat[/etc/passwd]"
node1
cat /proc/meminfo |awk '/^MemFree/{print $2}'
vim /etc/zabbix/zabbix_agentd.d/mem.conf
UserParameter=Memusage[*],cat /proc/meminfo |awk '/^$1/{print $$2}'
或者UserParameter=mem.stats[*],cat /proc/meminfo |awk '/^$1/{print $$2}'
Key为Memusage,且能接收一个参数
由于$1/$2等要用于UserParameter的参数调用,awk中的$2之前要多用一个$符;
在server端使用zabbix_get命令测试时,其调用的key可以为Memusage[MemFree],Memusage[MemTotal]等;
systemctl restart zabbix-agent.service
node4
zabbix_get -s 192.168.1.7 -p 10050 -k "Memusage[MemFree]"
或者zabbix_get -s 192.168.1.7 -p 10050 -k "mem.stats[MemFree]"
node1
次数--状态--IP+port
ss -an |awk '/^tcp/{print $2,$5}'|awk '/^T/{print $1,$2}'|uniq -c TIME-WAIT
ss -tan |awk '/^T/{print $1,$4,$5}'|uniq -c
ss -an |awk '/^tcp/{print $2,$5}'|awk '/^E/{print $1,$2}'|uniq -c ESTAB
ss -tan |awk '/^E/{print $1,$4,$5}'|uniq -c
ss -an |awk '/^tcp/{print $2,$5}'|awk '/^L/{print $1,$2}'|uniq -c LISTEN
ss -tan |awk '/^L/{print $1,$4,$5}'|uniq -c
ss -an |grep "^tcp.*ESTAB"|wc -l TCP连接的数量
ss -tan |grep "ESTAB"|wc -l
ss -tan |grep "LISTEN"|wc -l
vim /etc/zabbix/zabbix_agentd.d/tcp_connections.conf
UserParameter=tcp.stats[*],ss -tan |grep "$1"|wc -l
systemctl restart zabbix-agent.service
node2
zabbix_get -s 192.168.1.7 -p 10050 -k "tcp.stats[ESTAB]"
zabbix_get -s 192.168.1.7 -p 10050 -k "tcp.stats[LISTEN]"
将来可能需要使用puppet/ansible把被监控主机的parameter推送至各个监控主机上去

node1上自定义item

设置item

设置ok

Graph

node1上自定义item--tcp

tcp-estab设置

克隆estab:tcp-listen设置

数据显示

定义node1的Graph

tcp连接

preview--可以预览再Add
web监控
node1
yum -y install nginx
systemctl restart nginx
web监控--内建key:
web.test.in[Scenario,Step,bps]:传输速率
web.test.time[Scenario,Step]:响应时间
web.test.rspcode[Scenario,Step]:响应码

点击web

创建web场景

定义web scenarios

定义steps

添加完成

监控web

监控--仪表盘

手动关闭nginx

监控--仪表盘

手动开启nginx

查看图形

内键key
主动/被动监控
node1
zabbix_sender -h
自定义key,显示无数据时,使用命令测试
zabbix_sender -z 192.168.1.6 -p 10051 -s node1.fgq.com -k "test.key" -o 110
zabbix_sender -z 192.168.1.6 -p 10051 -s node1.fgq.com -k "test.key" -o 120
zabbix_sender -z 192.168.1.6 -p 10051 -s node1.fgq.com -k "test.key" -o 200
zabbix_sender -z 192.168.1.6 -p 10051 -s node1.fgq.com -k "test.key" -o 404
zabbix_sender -z 192.168.1.6 -p 10051 -s node1.fgq.com -k "test.key" -o 505

创建item

定义item

处理数据

显示数据

graph显示

再创建item--自定义key

自定义key的设定

设定成功

无数据

node1上使用命令行测试

命令行测试--graph展示
SNMP监控--了解(不操作)
yum info net-snmp
yum -y install net-snmp net-snmp-utils
vim /etc/snmp/snmpd.conf
systemctl start snmpd; ss -ntl 161端口监听
zabbix图形界面:
node1主机添加接口--SNMP interface:192.168.1.7 port:161
命令行测试
snmpwalk -v 2c -c public 192.168.1.7 测试ok,密码即public
zabbix图形界面:
node1主机创建item:
Type: SNMPV2 agent
Key: snmp.interface(不与已有key冲突即可)--标识符而已
SNMP OID: 命令行测试信息--挑选出来所需信息写在此处即可
获取更多数据--需要开放更多子树
vim /etc/snmp/snmpd.conf
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
view systemview included .1.3.6.1.2 添加--该子树上的数据都可以获取
JMX监控
node2--agent
yum -y install tomcat-webapps.noarch tomcat-admin-webapps.noarch java-1.8.0-openjdk-devel
vim /etc/sysconfig/tomcat
使用JAVA_OPTS或者CATALINA_OPTS都行,添加下面信息:
CATALINA_OPTS="-Djava.rmi.server.hostname=192.168.1.8 -Djavax.management.builder.initial= -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
分析:
hostname=192.168.1.8 tomcat主机的IP
12345 zabbix-jmx端口
.ssl=false 不认证
.authenticate=false 不认证
systemctl start tomcat; ss -ntl 12345/8080/8005/8009端口
node4--server
yum -y install zabbix-java-gateway.x86_64
rpm -ql zabbix-java-gateway
vim /etc/zabbix/zabbix_java_gateway.conf
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
START_POLLERS=5
systemctl start zabbix-java-gateway.service
vim /etc/zabbix/zabbix_server.conf
JavaGateway=192.168.1.6
JavaGatewayPort=10052
StartJavaPollers=5 开启5个子进程来pull数据
systemctl restart zabbix-server.service; ss -ntl 10052端口

选择node2主机

添加JMX接口

链接内键templates

ZBX/JMX对应关系

查看数据信息

选择compilation
Zabbix Proxy的配置
node4 zabbix server -- node2 zabbix agent
node4 zabbix server -- node3 zabbix proxy -- node1 zabbix agent
node3从node4同步配置,node3发送收集的监控信息给node4
node3
yum -y install mariadb-server
vim /etc/my.cnf.d/server.cnf
[mysqld]
skip_name_resolve = on
innodb_file_per_table = on
systemctl start mariadb.service ; ss -ntl 3306端口
yum -y install zabbix-proxy-mysql.x86_64 zabbix-get.x86_64 zabbix-sender zabbix-agent
rpm -ql zabbix-proxy-mysql
vim /etc/zabbix/zabbix_proxy.conf
Server=192.168.1.6
Hostname=node3.fgq.com
DBHost=127.0.0.1 使用本地主机存储收集到的数据
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=zbxpass
DBSocket=/var/lib/mysql/mysql.sock
ConfigFrequency=10 配置同步时间快一点,默认1h,此处10s,看效果
cp /usr/share/doc/zabbix-proxy-mysql-4.0.0/schema.sql.gz ./
gzip -d schema.sql.gz
mysql
create database zabbix_proxy character set "utf8";
grant all on zabbix_proxy.* to 'zabbix'@'127.0.0.1' identified by 'zbxpass';
flush privileges;
quit
mysql -uzabbix -h127.0.0.1 -pzbxpass zabbix_proxy < schema.sql
mysql
use zabbix_proxy
show tables;
quit
systemctl start zabbix-proxy.service ;ss -ntl 10051端口
systemctl status zabbix-proxy.service
node1
vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.1.6,192.168.1.5
ServerActive=192.168.1.6,192.168.1.5
支持代理服务--node3代理node1
systemctl restart zabbix-agent.service

仅保留node2主机

创建proxy

定义proxy

创建主机

定义node1

定义templates

代理添加完成

数据同步,需要时间,要等一会才会显示出数据

Graph显示
puppet/ansible配置好zabbix agent,确保可以启动服务;
zabbix server端打开discover功能
发现--添加--映射模板
配置Action
报警脚本
采集--存储--展示
zabbix+grafana
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.1.3-1.x86_64.rpm
yum install grafana-5.1.3-1.x86_64.rpm
systemctl enable grafana-server.service
systemctl start grafana-server.service; ss -ntl 3000端口
安装plugins
grafana-cli plugins list-remote
grafana-cli plugins install alexanderzobnin-zabbix-app
systemctl restart grafana-server.service
浏览器:192.168.1.6:3000
默认账号:admin 密码:admin

登陆界面

点击zabbix

启用

数据库资源设置

增加资源

设置

显示ok

导入自带的模板

图形展示

图形编辑

自己选择吧
网友评论