zabbix历史数据相关表研究

摘要:
Zabbix历史数据相关表研究历史和趋势相关表历史和趋势都是存储历史数据的地方。通常,通过监控项目配置、匹配和更新监控项目以及设置HouseKeepertasks来设置数据保留的持续时间。管家会定期删除过期数据。在这里,趋势数据很有用。通常,它只需要每小时的平均值,因此趋势数据可以保存很长时间。趋势数据的计算源数据来自历史表。如果历史记录设置为0,则只获取项的值并将其用于触发,历史数据不会保存到数据库中。

zabbix历史数据相关表研究

history和trends相关表

history和trends都是存储历史数据的地方。一般是通过监控项(item)配置里、匹配更新监控项(item)和设置HouseKeeper tasks来设置保留数据的时长。

Housekeeper 会定期删除过期的数据。如果不是特别有意义,建议你把保留时间设置短一些, 如果想看以前的数 据图怎么办?这里趋势数据就派上用场了,一般只要小时平均即可这样话趋势据保留久一点即可,趋势数据的计算源数据来自history表。如果将history设置为0那么就只会获取item的值然后用于触发器,不会存历史数据到数据库。

监控项前端配置:

zabbix历史数据相关表研究第1张

  • history相关表

    MariaDB [rtm]> show tables like 'history%';
    +--------------------------+
    | Tables_in_rtm (history%) |
    +--------------------------+
    | history                  |
    | history_log              |
    | history_str              |
    | history_text             |
    | history_uint             |
    +--------------------------+
    
    • history

      history 表存放信息类型为浮点数的监控项历史数据,类型在配置监控项是指定

      itemid: 监控项唯一标识id

      clock: 时间戳整数部分

      value: 监控项的值

      ns: 纳秒数

      MariaDB [rtm]> desc history;
      +--------+---------------------+------+-----+---------+-------+
      | Field  | Type                | Null | Key | Default | Extra |
      +--------+---------------------+------+-----+---------+-------+
      | itemid | bigint(20) unsigned | NO   | MUL | NULL    |       |
      | clock  | int(11)             | NO   |     | 0       |       |
      | value  | double(16,4)        | NO   |     | 0.0000  |       |
      | ns     | int(11)             | NO   |     | 0       |       |
      +--------+---------------------+------+-----+---------+-------+
      
      
      MariaDB [rtm]> select * from history limit 10;
      +-----------+------------+---------+----+
      | itemid    | clock      | value   | ns |
      +-----------+------------+---------+----+
      | 300161484 | 1545404400 |  1.9616 |  0 |
      | 300161484 | 1545379200 |  2.3494 |  0 |
      | 300161484 | 1545382800 |  2.7355 |  0 |
      | 300161484 | 1545386400 |  3.3068 |  0 |
      | 300161484 | 1545390000 |  3.2508 |  0 |
      | 300161484 | 1545393600 |  4.2648 |  0 |
      | 300161484 | 1545397200 |  4.0263 |  0 |
      | 300161484 | 1545400800 |  2.7983 |  0 |
      | 300161485 | 1545404400 | 16.8910 |  0 |
      | 300161485 | 1545379200 | 20.5173 |  0 |
      +-----------+------------+---------+----+
      
    • history_log

      history_log 表存放信息类型为日志的监控项历史数据,类型在配置监控项是指定

      MariaDB [rtm]> desc history_log;
      +------------+---------------------+------+-----+---------+-------+
      | Field      | Type                | Null | Key | Default | Extra |
      +------------+---------------------+------+-----+---------+-------+
      | id         | bigint(20) unsigned | NO   | PRI | NULL    |       |
      | itemid     | bigint(20) unsigned | NO   | MUL | NULL    |       |
      | clock      | int(11)             | NO   |     | 0       |       |
      | timestamp  | int(11)             | NO   |     | 0       |       |
      | source     | varchar(64)         | NO   |     |         |       |
      | severity   | int(11)             | NO   |     | 0       |       |
      | value      | text                | NO   |     | NULL    |       |
      | logeventid | int(11)             | NO   |     | 0       |       |
      | ns         | int(11)             | NO   |     | 0       |       |
      +------------+---------------------+------+-----+---------+-------+
      
    • history_str

      history_str 表存放信息类型为字符的监控项历史数据,类型在配置监控项是指定

      MariaDB [rtm]> desc history_str;
      +--------+---------------------+------+-----+---------+-------+
      | Field  | Type                | Null | Key | Default | Extra |
      +--------+---------------------+------+-----+---------+-------+
      | itemid | bigint(20) unsigned | NO   | MUL | NULL    |       |
      | clock  | int(11)             | NO   |     | 0       |       |
      | value  | varchar(255)        | NO   |     |         |       |
      | ns     | int(11)             | NO   |     | 0       |       |
      +--------+---------------------+------+-----+---------+-------+
      
      
      MariaDB [rtm]> select * from history_str limit 2G;
      *************************** 1. row ***************************
      itemid: 23307
       clock: 1545384507
       value: localhost.localdomain
          ns: 410719216
      *************************** 2. row ***************************
      itemid: 23312
       clock: 1545384512
       value: Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64
          ns: 411996428
      
    • history_text

      history_text 表存放信息类型为文本的监控项历史数据,类型在配置监控项是指定

      MariaDB [rtm]> desc history_text;
      +--------+---------------------+------+-----+---------+-------+
      | Field  | Type                | Null | Key | Default | Extra |
      +--------+---------------------+------+-----+---------+-------+
      | id     | bigint(20) unsigned | NO   | PRI | NULL    |       |
      | itemid | bigint(20) unsigned | NO   | MUL | NULL    |       |
      | clock  | int(11)             | NO   |     | 0       |       |
      | value  | text                | NO   |     | NULL    |       |
      | ns     | int(11)             | NO   |     | 0       |       |
      +--------+---------------------+------+-----+---------+-------+
      
      
      MariaDB [rtm]> select * from history_text limit 10;
      +---------+--------+------------+---------------------+-----------+
      | id      | itemid | clock      | value               | ns        |
      +---------+--------+------------+---------------------+-----------+
      | 1937748 |  30436 | 1545381354 | 10/11/2017 14:28:06 | 892072527 |
      | 1937749 |  28311 | 1545381364 | N/A                 | 146021861 |
      | 1937750 |  27186 | 1545381374 | N/A                 | 934199968 |
      | 1937751 |  26936 | 1545381376 | N/A                 | 146546842 |
      | 1937752 |  28936 | 1545381378 | N/A                 | 189324808 |
      | 1937753 |  24686 | 1545381380 | N/A                 |  89381118 |
      | 1937754 |  25061 | 1545381383 | N/A                 | 484549259 |
      | 1937755 |  28061 | 1545381385 | N/A                 | 699330874 |
      | 1937756 |  27061 | 1545381389 | N/A                 | 559602805 |
      | 1937757 |  30686 | 1545381391 | N/A                 | 303467948 |
      +---------+--------+------------+---------------------+-----------+
      
    • history_uint

      history_unit 表存放信息类型为数字(无正负)的监控项历史数据,类型在配置监控项是指定

      MariaDB [rtm]> desc history_uint;
      +--------+---------------------+------+-----+---------+-------+
      | Field  | Type                | Null | Key | Default | Extra |
      +--------+---------------------+------+-----+---------+-------+
      | itemid | bigint(20) unsigned | NO   | MUL | NULL    |       |
      | clock  | int(11)             | NO   |     | 0       |       |
      | value  | bigint(20) unsigned | NO   |     | 0       |       |
      | ns     | int(11)             | NO   |     | 0       |       |
      +--------+---------------------+------+-----+---------+-------+
      
      MariaDB [rtm]> select * from history_uint limit 10;
      +-----------+------------+-------+----+
      | itemid    | clock      | value | ns |
      +-----------+------------+-------+----+
      | 100029541 | 1545404700 |  4311 |  0 |
      | 100029541 | 1545405000 |  4276 |  0 |
      | 100029541 | 1545405300 |  4242 |  0 |
      | 100029541 | 1545405600 |  4207 |  0 |
      | 100029541 | 1545405900 |  4172 |  0 |
      | 100029541 | 1545406200 |  4137 |  0 |
      | 100029541 | 1545406500 |  4102 |  0 |
      | 100029541 | 1545406800 |  4067 |  0 |
      | 100029541 | 1545407100 |  4032 |  0 |
      | 100029541 | 1545407400 |  3997 |  0 |
      +-----------+------------+-------+----+
      
      
  • trends相关表

    MariaDB [rtm]> show tables like 'trends%';
    +-------------------------+
    | Tables_in_rtm (trends%) |
    +-------------------------+
    | trends                  |
    | trends_uint             |
    +-------------------------+
    
    • trends

      itemid: 监控项唯一标识id

      clock: 时间戳整数部分

      num: 该小时内用了多少数据用于计算平均值、最小值、最大值

      value_min: 趋势时间内最小值(趋势数据时间间隔为一小时)

      value_avg: 趋势时间内平均值(趋势数据时间间隔为一小时)

      value_max: 趋势时间内最大值(趋势数据时间间隔为一小时)

      MariaDB [rtm]> desc trends;
      +-----------+---------------------+------+-----+---------+-------+
      | Field     | Type                | Null | Key | Default | Extra |
      +-----------+---------------------+------+-----+---------+-------+
      | itemid    | bigint(20) unsigned | NO   | PRI | NULL    |       |
      | clock     | int(11)             | NO   | PRI | 0       |       |
      | num       | int(11)             | NO   |     | 0       |       |
      | value_min | double(16,4)        | NO   |     | 0.0000  |       |
      | value_avg | double(16,4)        | NO   |     | 0.0000  |       |
      | value_max | double(16,4)        | NO   |     | 0.0000  |       |
      +-----------+---------------------+------+-----+---------+-------+
      
      
      MariaDB [rtm]> select * from trends limit 10;
      +--------+------------+-----+-----------+-----------+-----------+
      | itemid | clock      | num | value_min | value_avg | value_max |
      +--------+------------+-----+-----------+-----------+-----------+
      |  23252 | 1538211600 |  60 |    0.0000 |    0.0006 |    0.0169 |
      |  23252 | 1538215200 |  60 |    0.0000 |    0.0008 |    0.0169 |
      |  23252 | 1538218800 |  60 |    0.0000 |    0.0008 |    0.0169 |
      |  23252 | 1538222400 |  60 |    0.0000 |    0.0003 |    0.0169 |
      |  23252 | 1538226000 |  60 |    0.0000 |    0.0008 |    0.0169 |
      |  23252 | 1538229600 |  60 |    0.0000 |    0.0017 |    0.0508 |
      |  23252 | 1538233200 |  60 |    0.0000 |    0.0011 |    0.0169 |
      |  23252 | 1538236800 |  60 |    0.0000 |    0.0014 |    0.0169 |
      |  23252 | 1538240400 |  60 |    0.0000 |    0.0008 |    0.0169 |
      |  23252 | 1538244000 |  60 |    0.0000 |    0.0003 |    0.0169 |
      +--------+------------+-----+-----------+-----------+-----------+
      
    • trends_unit

      MariaDB [rtm]> desc trends_uint;
      +-----------+---------------------+------+-----+---------+-------+
      | Field     | Type                | Null | Key | Default | Extra |
      +-----------+---------------------+------+-----+---------+-------+
      | itemid    | bigint(20) unsigned | NO   | PRI | NULL    |       |
      | clock     | int(11)             | NO   | PRI | 0       |       |
      | num       | int(11)             | NO   |     | 0       |       |
      | value_min | bigint(20) unsigned | NO   |     | 0       |       |
      | value_avg | bigint(20) unsigned | NO   |     | 0       |       |
      | value_max | bigint(20) unsigned | NO   |     | 0       |       |
      +-----------+---------------------+------+-----+---------+-------+
      
      
      MariaDB [rtm]> select * from trends_uint limit 10;
      +--------+------------+-----+-----------+-----------+-----------+
      | itemid | clock      | num | value_min | value_avg | value_max |
      +--------+------------+-----+-----------+-----------+-----------+
      |  23271 | 1538211600 |   6 |         0 |         0 |         0 |
      |  23271 | 1538215200 |   6 |         0 |         0 |         0 |
      |  23271 | 1538218800 |   6 |         0 |         0 |         0 |
      |  23271 | 1538222400 |   6 |         0 |         0 |         0 |
      |  23271 | 1538226000 |   6 |         0 |         0 |         0 |
      |  23271 | 1538229600 |   6 |         0 |         0 |         0 |
      |  23271 | 1538233200 |   6 |         0 |         0 |         0 |
      |  23271 | 1538236800 |   6 |         0 |         0 |         0 |
      |  23271 | 1538240400 |   6 |         0 |         0 |         0 |
      |  23271 | 1538244000 |   6 |         0 |         0 |         0 |
      +--------+------------+-----+-----------+-----------+-----------+
      

免责声明:文章转载自《zabbix历史数据相关表研究》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇centOS安装oracleDB,静默安装DBCA的时候,报错统筹学_百度百科下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

SQL调用另一台服务器的表及存储过程(SQL函数openrowset()的使用以及相关问题处理)

--查询表select * from openrowset('SQLOLEDB', 'IP'; 'sa'; '密码',数据库名称.dbo.表名称) --查询存储--示例1select * from openrowset('SQLOLEDB', 'SERVER=IP;uid=sa;pwd=密码;Database=数据库名称','SET FMTONLY OFF...

mysql--统计每个用户的累计访问次数

create table action(userId VARCHAR(10),visitDate VARCHAR(10),visitCount int ); insert into action values('u01','2017/1/21',5),('u02','2017/1/23',6),('u03','2017/1/22',8),('u04','2...

element-ui中Select 选择器列表内容居中

<el-select v-model="tenantCont" placeholder="请输入机构标识"> <el-option-group v-for="group in options" :key="group.label" :label="group.label"...

SQL中GROUP BY子句相关约束

  一、分组数据是在SELECT语句中使用GROUP BY子句来实现的。下面说说它的一些重要规定:   (1)GROUP BY子句可以包含任意数目的列,因而可以对分组进行嵌套,更细致地进行数据分组。   (2)如果GROUP BY子句中嵌套了分组,数据将在最后指定的分组上进行汇总。也就是说,在指定的所有列都一起计算,不能从个别的列取回数据。   (3)GR...

SQL Server 一些使用小技巧

1、查询的时候把某一个字段的值拼接成字符串 以下是演示数据。 第一种方式:使用自定义变量 DECLARE @Names NVARCHAR(128) SET @Names='' -- 需要先赋值为空字符串,不然结果会是 null SELECT @Names=@Names+S_Name+',' -- S_Name 类型为...

Oracle Data Guard

DG是 Oracle Data Guard的简称。也就是Oracle11g的 数据卫士。 由于在工作中 Oracle和 SQL SERVER2008 同时都需要维护管理。给我的感觉这里的 DG 其实和 Sql Server 2008的镜像实现的功能是一样的(当然更强大一些)。DG 中的物理备用库 尤其和 Sql Server 2008 的镜像实现的功能是一...