实验环境:

zabbix server 172.16.1.121

访问端 172.16.1.122

55.1 说明

zabbix_manager是zabbix终端管理工具,可以在linux终端实现管理zabbix,同时

可以通过zabbix_manager实现对zabbix的一键初始化,一键导出报表(报表为excel)

等功能。

参考文档:

https://www.w3cschool.cn/zabbix_manager/zabbix_manager-z45f1zie.html

55.2 安装

在172.16.1.122节点上操作

# git clone https://github.com/BillWang139967/zabbix_manager.git

# cd zabbix_manager

# sh start.sh

55.3 配置连接zabbix server

# cat /etc/zabbix_tool/zabbix_config.ini

# 默认连接(可通过--profile选择连接的zabbix)

[zabbixserver]

# zabbix server IP

server = 172.16.1.121

# zabbix web 端口

port = 80

# zabbix web 管理员账号

user = Admin

# zabbix web 管理员密码

password = zabbix

#[bendi]

#server = 192.168.199.128

#port = 80

#user = admin

#password = zabbix

55.4 额外配置

搭建zabbix server时使用的lnmp,前端使用的apache时需要进行操作,即前端使用

nginx时则不需要进行以下操作。

将配置文件/etc/zabbix_tool/zabbix_setting.ini中的apache = False

改为apache=True

# cat /etc/zabbix_tool/zabbix_setting.ini

[web]

# lnmp(False),lamp(True)

apache = True

[report]

logo_show = True

55.5 测试

# zabbix_api hostgroup_get --table

zabbix_manager:[1.4.04]

+-------------+-----------------------------+

| hostgroupID | hostgroupName |

+-------------+-----------------------------+

| 5 | Discovered hosts |

| 7 | Hypervisors |

| 2 | Linux servers |

| 1 | Templates |

| 12 | Templates/Applications |

| 13 | Templates/Databases |

| 8 | Templates/Modules |

| 9 | Templates/Network devices |

| 10 | Templates/Operating systems |

| 16 | Templates/SAN |

| 11 | Templates/Server hardware |

| 15 | Templates/Telephony |

| 14 | Templates/Virtualization |

| 6 | Virtual machines |

| 4 | Zabbix servers |

+-------------+-----------------------------+

sum: 15

55.6 以主机群组的方式导出数据表

--hostgroupid # 选择特定主机组

--hostid # 选择特定主机

item支持模糊搜索

(1) 对监控名称进行分隔符分割后,进行完全匹配,如某个监控项名称为“CPU idle time” 则搜索CPU即可匹配,搜索CP,则不匹配

(2) --sign 设置分割符,默认以“ ”(空格)分割,如某个监控项名称为“CPU_idle_time” 则搜索CPU相关的监控项,同时加“--sign _”参数

1 在zabbix中查看主机组id号

2 创建导出excel报表的目录

# mkdir -p /test/

3 生成报表

# zabbix_api --report "ICMP loss" "2021-01-01 00:00:00" "2021-01-31 00:00:00" --table --hostgroupid 4 --table --xls /test/ICMP_LOSS.xls

zabbix_manager:[1.4.04]

主机:无

主机组:Zabbix servers

+ICMP loss-----------+-----------+-------+---------+--------+

| hostid | name | itemName | min | max | avg |

+--------+-----------+-----------+-------+---------+--------+

| 10354 | baidu.com | ICMP loss | 0.0 % | 100.0 % | 14.0 % |

+--------+-----------+-----------+-------+---------+--------+

# zabbix_api --report "ICMP ping" "2021-01-01 00:00:00" "2021-01-31 00:00:00" --table --hostgroupid 4 --table --xls /test/ICMP_PING.xls

zabbix_manager:[1.4.04]

主机:无

主机组:Zabbix servers

+ICMP ping-----------+-----------+-----+-----+-----+

| hostid | name | itemName | min | max | avg |

+--------+-----------+-----------+-----+-----+-----+

| 10354 | baidu.com | ICMP ping | 0 | 1 | 0 |

+--------+-----------+-----------+-----+-----+-----+

# zabbix_api --report "ICMP response time" "2021-01-01 00:00:00" "2021-01-31 00:00:00" --table --hostgroupid 4 --table --xls /test/ICMP_REPONSE_TIME.xls

zabbix_manager:[1.4.04]

主机:无

主机组:Zabbix servers

+ICMP response time--+--------------------+-------+------------------+----------+

| hostid | name | itemName | min | max | avg |

+--------+-----------+--------------------+-------+------------------+----------+

| 10354 | baidu.com | ICMP response time | 0.0 s | 0.258016666667 s | 0.0525 s |

+--------+-----------+--------------------+-------+------------------+----------+

# zabbix_api --report "ICMP" "2021-01-01 00:00:00" "2021-01-31 00:00:00" --table --hostgroupid 4 --table --xls /test/ICMP_RESULT.xls

zabbix_manager:[1.4.04]

主机:无

主机组:Zabbix servers

+ICMP----+-----------+--------------------+-------+------------------+----------+

| hostid | name | itemName | min | max | avg |

+--------+-----------+--------------------+-------+------------------+----------+

| 10354 | baidu.com | ICMP ping | 0 | 1 | 0 |

| 10354 | baidu.com | ICMP loss | 0.0 % | 100.0 % | 14.0 % |

| 10354 | baidu.com | ICMP response time | 0.0 s | 0.258016666667 s | 0.0525 s |

+--------+-----------+--------------------+-------+------------------+----------+

4 查看Excel报表

# sz -y /test/ICMP_RESULT.xls

5 补充

(1) 更改表头

# vim /usr/bin/zabbix_api

2558 export_xls = {"xls":"OFF",

2559 "xls_name":"ceshi.xls",

2560 "title":"OFF",

2561 "title_name":u"测试"

2562 }

(2) 给报表增加IP地址字段

# vim /usr/bin/zabbix_api

1) 如下图添加 host_info[3] 字段

2) 如下图添加相应的输出字段

2) 测试

# zabbix_api --report "ICMP" "2021-01-01 00:00:00" "2021-01-31 00:00:00" --table --hostgroupid 4 --table --xls /test/ICMP_RESULT.xls

zabbix_manager:[1.4.04]

主机:无

主机组:Zabbix servers

(u'10354', u'baidu.com', u'baidu.com', u'112.80.248.76', u'0')

(u'10084', u'Zabbix server', u'Zabbix server', u'127.0.0.1', u'1')

+ICMP----+-----------+---------------+--------------------+-------------------+-------------------+----------+

| hostid | name | hostip | itemName | min | max | avg |

+--------+-----------+---------------+--------------------+-------------------+-------------------+----------+

| 10354 | baidu.com | 112.80.248.76 | ICMP ping | 1 | 1 | 1 |

| 10354 | baidu.com | 112.80.248.76 | ICMP loss | 0.0 % | 0.0 % | 0.0 % |

| 10354 | baidu.com | 112.80.248.76 | ICMP response time | 0.0218666666667 s | 0.0446533333333 s | 0.0351 s |

+--------+-----------+---------------+--------------------+-------------------+-------------------+----------+

zabbix_manage的使用的更多相关文章

随机推荐

  1. [BD] Storm

    什么是实时计算 离线计算:批处理,代表MapReduce.Spark Core,采集数据Sqoop.Flume 实时计算:源源不断,代表Storm等,采集数据Flume 框架 Apache Storm ...

  2. spec cpu2006 官网

    https://www.spec.org/cpu2006/Docs/install-guide-unix.html

  3. 攻防世界(九)PHP2

    攻防世界系列:PHP2  1.打开什么信息也没有. 尝试各种首页index.php index.html 加 [F12]没有结果,最后发现是index.phps .phps文件是什么? phps文件就 ...

  4. Kubernetes 部署微服务电商平台(16)

    一.概念 微服务就是很小的服务,小到一个服务只对应一个单一的功能,只做一件事.这个服务可以单独部署运行,服务之间可以通过RPC来相互交互,每个微服务都是由独立的小团队开发,测试,部署,上线,负责它的整 ...

  5. windows 批量删除用户

    @echo off for %%I in (longxj,liujr,laijx,yuanyq,yanghui,xiejz,zhanlei,zifz,yuansy,denglf,lilan,chenz ...

  6. 三大主流开源硬件对比:Arduino vs Raspberry Pi vs BeagleBone

    http://www.elecfans.com/emb/361236_3.html 下文摘自上面的链接 软硬件整合是今年一再被提及的话题,如今我们也可以看到不少硬件创业的成功案例,比如Jawbone ...

  7. Java List去重以及效率分析

    List去重无非几种方法: 下面文章提供的两种: https://blog.csdn.net/u012156163/article/details/78338574, 以及使用List.stream. ...

  8. GO学习-(32) Go实现日志收集系统1

    Go实现日志收集系统1 项目背景 每个系统都有日志,当系统出现问题时,需要通过日志解决问题 当系统机器比较少时,登陆到服务器上查看即可满足 当系统机器规模巨大,登陆到机器上查看几乎不现实 当然即使是机 ...

  9. TinyML-TVM是如何驯服Tiny的(上)

    TinyML-TVM是如何驯服Tiny的(上) 低成本.人工智能驱动的消费类设备的激增,导致了ML研究人员和从业者对"裸智能"(低功耗,通常没有操作系统)设备的广泛兴趣.虽然专家已 ...

  10. VLAN与三层交换机

    VLAN概述与优势 ①分割广播域 物理分割 逻辑分割 ②VLAN的优势 控制广播 增强网络安全性 简化网络管理 VLAN的范围 VlAN  ID范围 范围 用途 0,4095 保留 仅限系统使用,用户 ...