zabbix sender 配置方法

说明

zabbix 监控常见有 agent, trapper, proxy 三种监控模式
本文主要讨论 trapper 模式

agent 方案

1 zabbix client (需要进行监控的客户机) 调用 zabbix-agent 进行启动 10050 端口
2 zabbix server 向已注册的 zabbix client 请求监控数据

参考 zabbix server 进程

[root@gx-yun-084044 ~]# ps aux | grep poll
root       1152  0.0  0.0      0     0 ?        S<   Nov14   0:00 [edac-poller]
zabbixs+  10604  0.0  0.0 363764  5044 ?        S    15:07   0:00 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000084 sec, idle 5 sec]
zabbixs+  10605  0.0  0.0 363764  5044 ?        S    15:07   0:00 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000264 sec, idle 5 sec]
zabbixs+  10606  0.0  0.0 363764  5044 ?        S    15:07   0:00 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000107 sec, idle 5 sec]
zabbixs+  10607  0.0  0.0 363764  5156 ?        S    15:07   0:00 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000082 sec, idle 5 sec]
zabbixs+  10608  0.0  0.0 363764  5044 ?        S    15:07   0:00 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000231 sec, idle 5 sec]
zabbixs+  10609  0.0  0.0 363768  5444 ?        S    15:07   0:04 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000103 sec, getting values]
zabbixs+  10622  0.0  0.0 259032  2508 ?        S    15:07   0:00 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.000480 sec, idle 5 sec]
zabbixs+  10635  0.0  0.0 259032  2508 ?        S    15:07   0:00 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000085 sec, idle 5 sec]

trapper 方案

1. zabbix server 服务器打开 10051 端口
2. zabbix client 利用 zabbix-sender 主动向 zabbix server 提供监控数据

场景

当前 zabbix 用于监控 openstack 中 instance 性能
zabbix instance (client) 约 6500 
zabbix items (监控项)  1400000+
每秒约插入数据库新数据约 25000

参考 zabbix status

ParameterValueDetails
Zabbix server is runningYeslocalhost:10051
Number of hosts (enabled/disabled/templates)65386478 / 0 / 60
Number of items (enabled/disabled/not supported)14085591328627 / 35584 / 44348
Number of triggers (enabled/disabled [problem/ok])509196283588 / 225608 [946 / 282642]
Number of users (online)18962
Required server performance, new values per second24266.07-

优缺点

agent 模式

优点
  参考场景, instance 被当做独立主机监控
  可以独立地区分数据, 定位 instance owner, 精准告警
缺点
  每个监控项都是由 zabbix server 通过 instance (被监控主机) 中的 agent 获取
  当 instance 不断增加, 则会导致 zabbix server 经常会出现 poller busy 或者 poller unreachable 错误
  上述错误会出现监控空白窗口, 即, 某个繁忙时间内无法获取对应监控信息
特点
  一个 instance 假如有 100 个 item 监控项, 那么 zabbix server 与 instance 就需要交互 100

trapper 模式

原理

   instance 由 cron job 调用进程, 进程收集需要的监控项数据
   把所有数据都整理成可用于上报 zabbix-server 的报表
   zabbix-sender 提交报表中所有监控项

优化

  一个 instance 假如有 100 个 item 监控项
  instance 自身收集 100 个 item 需要的数据
  instance 只需要向 zabbix-server 交互一次即可提交所有数据

思考

参考场景

instance 需要被当做独立主机监控
假如只把 agent 模式更换成 trapper 模式, 对于 zabbix server 的压力, 可以减少了一部分压力

换位思考

compute 节点上运行了 instance
在 compute 节点上, 对本 compute-node 中所有 instance 进行数据收集 (每个 compute 约 10 ~ 20instance )
可以再次降低 zabbix-sender 与 zabbix-server 之间的交互, 减少 10 ~ 20

优缺点

compute-node 需利用 libvirtd , 可以对 compute 中 instance 进行 item 数据收集
只可以收集硬件基础信息, 如 cpu, memory, disk usage, disk io, network package, network traffic
无法对 instance 中应用程序监控信息
不需要在 instance 中运行 zabbix-agent 进程
需要在 compute-node 中执行 zabbix-sender, 收集 compute-node 中所有 instnace 监控项, 最后向 zabbix-server 提交所有监控信息

zabbix sender

zabbix sender 由 zabbix-client 软件包提供
由被监控的机器主动运行,  常见被设定由 cron job 中调用

需求

需要 server 中的监控项 (item) 支持对应配置

1. 需要定义 item 监控类型 (默认 agent 被动模式) 需要改为 zabbix trapper 模式
2. 需要添加该 item allow host 选项, 允许那些主机进行数据上报功能
    注意, 需要定义多个 host 方法如下  x.x.x.x,x.x.x.x 利用逗号进行分隔

参考下图

trapper

数据库说明

上图中的修改, 将会自动对 zabbix.items 表进行修改

需要先知道当前对应模板 hostid

MariaDB [zabbix]> select hostid  from hosts where name = 'linux_vm';
+--------+
| hostid |
+--------+
|  10108 |
+--------+
1 row in set (0.00 sec)

假设需要对其中一个 item ( net.if.out[eth0] ) 进行修改
一次性添加主机方法

MariaDB [zabbix]> update items set trapper_hosts = '10.199.131.230,10.199.131.229,10.199.131.206,10.199.131.201' where hostid=10108;
Query OK, 23 rows affected (0.00 sec)
Rows matched: 23  Changed: 23  Warnings: 0

查询对应主机信息

MariaDB [zabbix]> select type, key_, trapper_hosts from items where key_='net.if.out[eth0]' and hostid=10108;
+------+------------------+-------------------------------------------------------------+
| type | key_             | trapper_hosts                                               |
+------+------------------+-------------------------------------------------------------+
|    2 | net.if.out[eth0] | 10.199.131.230,10.199.131.229,10.199.131.206,10.199.131.201 |
+------+------------------+-------------------------------------------------------------+
1 row in set (0.00 sec)

追加主机方法
通过 concat(‘xxxx,’, trapper_hosts) 方法, 可以直接对表中数据进行追加, 而不需要关心当前已经存在有哪些数据

MariaDB [zabbix]> update items set trapper_hosts = concat('10.189.209.162,',trapper_hosts)  where hostid=10108;
Query OK, 23 rows affected (0.00 sec)
Rows matched: 23  Changed: 23  Warnings: 0

说明

type:  zabbix trapper  
      修改表 items 中 type 列, 对应值为 2
      allowed host 修改 items 中 trapper_hosts 列, 对应值为 'x.x.x.x,x.x.x.x,x.x.x.x'
type:  agent
      修改表 items 中 type 列, 对应值为 0
      allowed host 修改 items 中 trapper_hosts 列, 对应值为 ''

zabbix sender 报表

参考报表格式

kvm-test4-vsvnf.vclound.com agent.ping 1
kvm-test4-vsvnf.vclound.com system.cpu.util[,system] 0.0
kvm-test4-vsvnf.vclound.com system.cpu.util[,user] 0.0
kvm-test4-vsvnf.vclound.com system.cpu.util[,cpu] 1.02968210051
kvm-test4-vsvnf.vclound.com vm.memory.size[total] 3974930432
kvm-test4-vsvnf.vclound.com vm.memory.size[available] 3374346240
kvm-test4-vsvnf.vclound.com vm.memory.size[used] 600584192
kvm-test4-vsvnf.vclound.com hv.memory.size[used] 1037721600
kvm-test4-vsvnf.vclound.com net.if.in[eth0] 14325621103
kvm-test4-vsvnf.vclound.com net.if.out[eth0] 372320716
kvm-test4-vsvnf.vclound.com net.if.in[eth0,dropped] 0
kvm-test4-vsvnf.vclound.com net.if.out[eth0,dropped] 0
kvm-test4-vsvnf.vclound.com net.if.in[eth0,errors] 0
kvm-test4-vsvnf.vclound.com net.if.out[eth0,errors] 0
kvm-test4-vsvnf.vclound.com net.if.in[eth0,packets] 104586170
kvm-test4-vsvnf.vclound.com net.if.out[eth0,packets] 5623263
kvm-test4-vsvnf.vclound.com vfs.fs.iostat[,write_bytes] 3299751424
kvm-test4-vsvnf.vclound.com vfs.fs.iostat[,read_bytes] 207334912
kvm-test4-vsvnf.vclound.com vfs.fs.iostat[,write_request] 425585
kvm-test4-vsvnf.vclound.com vfs.fs.iostat[,read_request] 8089
kvm-test4-vsvnf.vclound.com vfs.fs.iostat[,error] 0
kvm-test4-vsvnf.vclound.com vfs.fs.size[sda5,total] 17179869184
kvm-test4-vsvnf.vclound.com vfs.fs.size[sda5,used] 3006477107
kvm-test4-vsvnf.vclound.com vfs.fs.size[sda5,available] 13958643712
kvm-test4-vsvnf.vclound.com vfs.fs.size[sda2,total] 20401094656
kvm-test4-vsvnf.vclound.com vfs.fs.size[sda2,used] 46137344
kvm-test4-vsvnf.vclound.com vfs.fs.size[sda2,available] 19327352832
kvm-test4-vsvnf.vclound.com vfs.fs.size[sda1,total] 521142272
kvm-test4-vsvnf.vclound.com vfs.fs.size[sda1,used] 110100480
kvm-test4-vsvnf.vclound.com vfs.fs.size[sda1,available] 409993216
kvm-test4-vsvnf.vclound.com vfs.fs.inode[sda5,total] 8131584
kvm-test4-vsvnf.vclound.com vfs.fs.inode[sda5,used] 74754
kvm-test4-vsvnf.vclound.com vfs.fs.inode[sda5,available] 8056830
kvm-test4-vsvnf.vclound.com vfs.fs.inode[sda2,total] 2621440
kvm-test4-vsvnf.vclound.com vfs.fs.inode[sda2,used] 12
kvm-test4-vsvnf.vclound.com vfs.fs.inode[sda2,available] 2621428
kvm-test4-vsvnf.vclound.com vfs.fs.inode[sda1,total] 256000
kvm-test4-vsvnf.vclound.com vfs.fs.inode[sda1,used] 331
kvm-test4-vsvnf.vclound.com vfs.fs.inode[sda1,available] 255669

格式说明

主机名监控项监控值
kvm-test4-vsvnf.vclound.comvfs.fs.inode[sda1,available]255669
kvm-test4-vsvnf.vclound.comvfs.fs.inode[sda1,total]256000
kvm-test4-vsvnf.vclound.comvfs.fs.inode[sda1,used]331

提交方法

zabbix_sender -z zabbix-server-ipaddr -i /zabbix-record-fullpath.txt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Terry_Tsang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值