深度剖析Zabbix Web scenarios数据表结构

深度剖析Zabbix Web scenarios数据表结构

前言

因开发需求,需要解析Zabbix web监控数据表结构;因为网上关于Zabbix数据表结构解析的比较少,所以心血来潮写了一篇作为记录。

突破口

Zabbix数据库表结构做解析的时候,我有个习惯,直接针对某个itemid怼。

这次当然不例外,随便找了个Zabbix web itemid

直接查数据库里有哪些表

show tables like "%http%";
+---------------------------+
| Tables_in_zabbix (%http%) |
+---------------------------+
| httpstep                  |
| httpstep_field            |
| httpstepitem              |
| httptest                  |
| httptest_field            |
| httptestitem              |
+---------------------------+

用屁股猜已经猜出大概存储的是什么内容:

  • httpstep 存储的为场景信息
  • httpstepitem 存储的为场景ID
  • httptest 存储的为步骤信息
  • httptestitem 存储的为步骤ID

剖析

itemid为突破口

获取到这个场景的itemID

查询这个item所在的testID与testitemID


select * from httptestitem where itemid="56263" ;
+----------------+------------+--------+------+
| httptestitemid | httptestid | itemid | type |
+----------------+------------+--------+------+
|           1194 |        398 |  56263 |    4 |
+----------------+------------+--------+------+

根据这个itemid我们找到他对应的场景id。

获取这个场景的几个监控item值

  • Last error message of scenario
  • Download speed for scenario
  • Failed step of scenario
select * from httptestitem where httptestid="398";
+----------------+------------+--------+------+
| httptestitemid | httptestid | itemid | type |
+----------------+------------+--------+------+
|           1192 |        398 |  56261 |    2 |
|           1193 |        398 |  56262 |    3 |
|           1194 |        398 |  56263 |    4 |
+----------------+------------+--------+------+

解析一波,具体自己参照Latest data

#############
# 各Type剖析
#
#   type类型为2代表【Download speed for scenario】
#   场景总下载速度,历史数据存储在history表.
#
#   type类型为3代表【Failed step of scenario】
#   场景返回状态码, 0表示场景正常, 每个步骤异常为1.历史数据存储在history_uint表.
#
#   type类型为4代表【Last error message of scenario】
#   上一次场景返回错误信息,历史数据存储在history_str表.
#
#############

接下来根据场景ID找出步骤

查询http场景下的步骤

  • Download speed for step
  • Response time for step
  • Response code for step
select * from httpstepitem where httpstepid="398";
+----------------+------------+--------+------+
| httpstepitemid | httpstepid | itemid | type |
+----------------+------------+--------+------+
|           1192 |        398 |  56180 |    2 |
|           1193 |        398 |  56181 |    1 |
|           1194 |        398 |  56182 |    0 |
+----------------+------------+--------+------+

解析一波,具体自己参照Latest data

#############
# 各Type剖析
#
#   type类型为2代表【Download speed for step】
#   步骤的下载速度,历史数据存储在history表.
#
#   type类型为1代表【Response time for step】
#   步骤返回时间,历史数据存储在history表.
#
#   type类型为0代表【Response code for step】
#   步骤的返回状态码, 其中0为无法连接,无状态码.历史数据存储在history_uint表.
#
#############

接下来剖析详细场景与步骤

根据ID查询场景信息

自行对应ZabbixWEB界面

select * from httptest where httptestid="398" \G;
*************************** 1. row ***************************
      httptestid: 398
            name: 业务接口A
   applicationid: 800
       nextcheck: 1542984224
           delay: 1m
          status: 0
           agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36
  authentication: 0
       http_user:
   http_password:
          hostid: 10084
      templateid: 397
      http_proxy:
         retries: 1
   ssl_cert_file:
    ssl_key_file:
ssl_key_password:
     verify_peer: 0
     verify_host: 0

顺便简单介绍下场景下的字段表,也就是一些自定宏

select * from httptest_field limit 1;
+------------------+------------+------+----------+-------------------+
| httptest_fieldid | httptestid | type | name     | value             |
+------------------+------------+------+----------+-------------------+
|                1 |        535 |    1 | {IP}     |          10.1.1.1 |
+------------------+------------+------+----------+-------------------+   

#   type为1表示 Variables.
#   type为0表示 Headers.

接下来查看场景里面的步骤 自行参照Steps页面
查询指定ID的步骤

select * from httpstep where httptestid="398"\G;
*************************** 1. row ***************************
      httpstepid: 412
      httptestid: 398
            name: 业务接口A
              no: 1
             url: https://baidu.com
         timeout: 15s
           posts:
        required:
    status_codes:
follow_redirects: 0
   retrieve_mode: 0
       post_type: 0

#   no代表场景的步骤
#   required表示步骤正常返回字符串,填写内容为正则表达式.

步骤也有map字段表

select * from httpstep_field limit 1;
+------------------+------------+------+----------+---------------------+
| httpstep_fieldid | httpstepid | type | name     | value               |
+------------------+------------+------+----------+---------------------+
|                1 |        129 |    1 | {rentid} | regex:([0-9]{4,10}) |
+------------------+------------+------+----------+---------------------+

#   type为0表示 Headers.
#   type为1表示 Variables.
#   type为2表示 Post fields.

后记

文章一些数据表字段不明白都可以参照ZabbixWEB配置页面。
另外建议大家Zabbix二次开发的时候可以怼库就怼库,遇到逻辑复杂没有把握才使用API。

原文地址:http://blog.51cto.com/maoyao/2321362

时间: 2024-08-03 02:47:59

深度剖析Zabbix Web scenarios数据表结构的相关文章

Zabbix的数据表结构

看到Zabbix的数据表结构吧,就知道数据量大了 性能问题很让人担忧,不过基于Zabbix数据库导出报表,或自动跑报表的时候,就必须去了解一下zabbix的数据表结构了,得知道XX放在哪才能找到XX,既然能找到XX了,让他数据可视化起来也就不是什么问题了,废话少说开撸 0.Hosts表 mysql> DESC hosts;###这里面存有hostid.proxyid.节点信息.状态以及XXX各种信息,比较核心的一张表###+--------------------+---------------

oracle表空间基本命令,修改数据表结构基本命令

表空间基本命令 --创建表空间   初始化大小10M  自动增长5M  最大50M create tablespace duan datafile 'F:\oracle\product\10.2.0\oradata\orcl\duan.dbf' size 10M autoextend on next 5M maxsize 50M; --查询表空间的地址和空间名称 select file_name,tablespace_name from dba_data_files order by file_

如何查看数据表及数据表结构

我们创建好了数据表,那么我们该怎么去查看数据表列表呢? 一.查看数据表列表的语法结构 SHOW TABLES [FROM db_name] [LIKE 'pattern' | WHERE expr] FROM db_name表示,我们不仅可以查看当前数据库里的数据表,还可以查看别的数据库里的数据表 mysql> show tables;+----------------+| Tables_in_test |+----------------+| tb1 |+----------------+1

【转】Informix数据表结构分析资料整理之约束查询代码

原文地址:http://blog.csdn.net/xqf222/article/details/6271219 本文主要整理了Informix数据库相关系统表数据,已分析整个Informix数据表结构,同时方便代码自动生成.提示一:systables 存放Informix数据库中所有数据表相关数据 提示二:sysconstraints 存放Informix数据库中所有约束相关数据 --获取所有用户表的主键约束名称select a.tabname,b.constrname,b.* from sy

youyax论坛的数据表结构

总共19张表 其中有一些级联关系 reply表和talk表级联,当talk里的主题删除的时候,reply表相应回复全部删除 同理还有投票IP表和投票主题的关联 youyax论坛的数据表结构

使用语句修改数据表结构

查询表信息: sp_help 'dbo.T_User'; 修改columnName 字段为空 alter table dbo.T_User alter column columnName datetime null; 修改columnName 默认值 ALTER TABLE dbo.T_User ADD CONSTRAINT [DF_T_User_columnName ] DEFAULT 0 FOR [columnName ]; 使用语句修改数据表结构

JS 向web sql数据表插入数据

var strSQL = "insert into tableName values (?,?,?)"; var info=[1,1,1]; //向web sql数据表插入数据. function insertInfo(strSQL,info){ //连接数据库(http://www.cnblogs.com/nb08611033/p/8227560.html) db = openDB(); if (db) { db.transaction(function(tr) { tr.execu

navicat如何导出mysql数据表结构

我们在创建数据库时会对字段进行设置,比如类型.长度等,如果字段多的话一个个设置非常麻烦,可以从其他地方已有的表导入数据表结构,怎么操作呢?我们拿navicat导出mysql数据表结构为例: 1.点击“工具”–>数据传输. 2.在弹出的窗口里左边可以选择需要导出的表,右边选择连接或文件(我要导出sql文件,所以我选的是文件)选择导出的位置. 3.如果只是想导出表结构而不需要表的数据,那么点击“高级”–>把“插入记录”前的勾去掉.如果需要导出数据,那么默认打勾就可以, 4.点击开始,直到进度条走到

PowerDesigner导出数据表结构到Excel 所有表结构在同一个Sheet中

Option Explicit Dim rowsNum rowsNum = 0 '----------------------------------------------------------------------------- ' Main function '----------------------------------------------------------------------------- ' Get the current active model Dim M