实验环境:

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. [bug] CDH报错:cloudera-scm-server dead but pid file exists

    参考 https://blog.csdn.net/levy_cui/article/details/51243335

  2. 二进制格式安装MySQL

    二进制格式安装MySQL 下载二进制格式的mysql软件包 下载二进制格式的 mysql 软件包 [root@localhost ~]# cd /usr/src/ [root@localhost sr ...

  3. element-ui 的el-select如何不显示value,显示value对应的label值

    有时根据需要,我们根据v-model的值绑定option, 想要的效果: 实际的效果: 原因: value的格式存在问题,数据库读取到的数据不一定为number类型,需要手动转换. 第一种 <t ...

  4. 第三方跨平台进程和系统监控库gopsutil

    gopsutil psutil是一个跨平台进程和系统监控的Python库,而gopsutil是其Go语言版本的实现.本文介绍了它的基本使用. Go语言部署简单.性能好的特点非常适合做一些诸如采集系统信 ...

  5. clone() java 简单的复制

      Java的复制有的 deepcopy 和 shapecopy 之分,这里简单的采用shapecopy  的 clone ( ) 方法, 但是指向的是同一个对象, 关于对象的问题,这里不做展开: / ...

  6. SQL Server 动态创建表结构

    需求是,在word里面设计好表结构(主要在word中看起来一目了然,方便维护),然后复制sql 里面,希望动态创建出来 存储表结构的表 CREATE TABLE [dbo].[Sys_CreateTa ...

  7. 如何为嵌入式应用选择适当的SSD

    如何为嵌入式应用选择适当的SSD Selecting the right SSD for evolving embedded applications 变革涉及技术的每一个要素,闪存也不例外.价格下跌 ...

  8. Python爬虫入门:Urllib parse库使用详解(二)

    文字转载:https://www.jianshu.com/p/e4a9e64082ef,转载内容仅供学习 如有侵权,请联系删除 获取url参数 urlparse 和 parse_qs ParseRes ...

  9. python 利用三方的xlrd模块读取excel文件,处理合并单元格

      目的: python能使用xlrd模块实现对Excel数据的读取,且按照想要的输出形式.  总体思路: (1)要想实现对Excel数据的读取,需要用到第三方应用,直接应用. (2)实际操作时候和我 ...

  10. java.lang.ClassNotFoundException: org.apache.curator.RetryPolicy

    dubbo项目启动过程中遇到这个异常,很明显是找不到curator的包,所以需要引入curator的相关包才可以, curator是zookeeper的客户端框架,且要引入完整,才不会报错 比如: & ...