Zabbix的數據表結構

看到Zabbix的數據表結構吧,就知道數據量大了 性能問題很讓人擔心,不過基於Zabbix數據庫導出報表,或自動跑報表的時候,就必須去了解一下zabbix的數據表結構了,得知道XX放在哪才能找到XX,既然能找到XX了,讓他數據可視化起來也就不是什麼問題了,廢話少說開擼

 

0、Hosts表

mysql> DESC hosts;
###這裏面存有hostid、proxyid、節點信息、狀態以及XXX各類信息,比較核心的一張表###
+--------------------+---------------------+------+-----+---------+-------+
| Field              | Type                | Null | Key | Default | Extra |
+--------------------+---------------------+------+-----+---------+-------+
| hostid             | bigint(20) unsigned | NO   | PRI | NULL    |       |
| proxy_hostid       | bigint(20) unsigned | YES  | MUL | NULL    |       |
| host               | varchar(64)         | NO   | MUL |         |       |
| status             | int(11)             | NO   | MUL | 0       |       |
| disable_until      | int(11)             | NO   |     | 0       |       |
| error              | varchar(128)        | NO   |     |         |       |
| available          | int(11)             | NO   |     | 0       |       |
| errors_from        | int(11)             | NO   |     | 0       |       |
| lastaccess         | int(11)             | NO   |     | 0       |       |
| ipmi_authtype      | int(11)             | NO   |     | 0       |       |
| ipmi_privilege     | int(11)             | NO   |     | 2       |       |
| ipmi_username      | varchar(16)         | NO   |     |         |       |
| ipmi_password      | varchar(20)         | NO   |     |         |       |
| ipmi_disable_until | int(11)             | NO   |     | 0       |       |
| ipmi_available     | int(11)             | NO   |     | 0       |       |
| snmp_disable_until | int(11)             | NO   |     | 0       |       |
| snmp_available     | int(11)             | NO   |     | 0       |       |
| maintenanceid      | bigint(20) unsigned | YES  | MUL | NULL    |       |
| maintenance_status | int(11)             | NO   |     | 0       |       |
| maintenance_type   | int(11)             | NO   |     | 0       |       |
| maintenance_from   | int(11)             | NO   |     | 0       |       |
| ipmi_errors_from   | int(11)             | NO   |     | 0       |       |
| snmp_errors_from   | int(11)             | NO   |     | 0       |       |
| ipmi_error         | varchar(128)        | NO   |     |         |       |
| snmp_error         | varchar(128)        | NO   |     |         |       |
| jmx_disable_until  | int(11)             | NO   |     | 0       |       |
| jmx_available      | int(11)             | NO   |     | 0       |       |
| jmx_errors_from    | int(11)             | NO   |     | 0       |       |
| jmx_error          | varchar(128)        | NO   |     |         |       |
| name               | varchar(64)         | NO   | MUL |         |       |
| flags              | int(11)             | NO   |     | 0       |       |
| templateid         | bigint(20) unsigned | YES  | MUL | NULL    |       |
+--------------------+---------------------+------+-----+---------+-------+
 

一、groups表

mysql> DESC groups;
##這張表結構主要就是組名和組ID##
+----------+---------------------+------+-----+---------+-------+
| Field    | Type                | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| groupid  | bigint(20) unsigned | NO   | PRI | NULL    |       |
| name     | varchar(64)         | NO   | MUL |         |       |
| internal | int(11)             | NO   |     | 0       |       |
| flags    | int(11)             | NO   |     | 0       |       |
+----------+---------------------+------+-----+---------+-------+
 

三、hosts_groups表

mysql> DESC hosts_groups;
###hosts[主機] 和 groups[組] 的關聯關係###
+-------------+---------------------+------+-----+---------+-------+
| Field       | Type                | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| hostgroupid | bigint(20) unsigned | NO   | PRI | NULL    |       |
| hostid      | bigint(20) unsigned | NO   | MUL | NULL    |       |
| groupid     | bigint(20) unsigned | NO   | MUL | NULL    |       |
+-------------+---------------------+------+-----+---------+-------+
 

四、items表

mysql> DESC items;
###存有各類監控項的信息###
+-----------------------+---------------------+------+-----+---------+-------+
| Field                 | Type                | Null | Key | Default | Extra |
+-----------------------+---------------------+------+-----+---------+-------+
| itemid                | bigint(20) unsigned | NO   | PRI | NULL    |       |
| type                  | int(11)             | NO   |     | 0       |       |
| snmp_community        | varchar(64)         | NO   |     |         |       |
| snmp_oid              | varchar(255)        | NO   |     |         |       |
| hostid                | bigint(20) unsigned | NO   | MUL | NULL    |       |
| name                  | varchar(255)        | NO   |     |         |       |
| key_                  | varchar(255)        | NO   |     |         |       |
| delay                 | int(11)             | NO   |     | 0       |       |
| history               | int(11)             | NO   |     | 90      |       |
| trends                | int(11)             | NO   |     | 365     |       |
| status                | int(11)             | NO   | MUL | 0       |       |
| value_type            | int(11)             | NO   |     | 0       |       |
| trapper_hosts         | varchar(255)        | NO   |     |         |       |
| units                 | varchar(255)        | NO   |     |         |       |
| multiplier            | int(11)             | NO   |     | 0       |       |
| delta                 | int(11)             | NO   |     | 0       |       |
| snmpv3_securityname   | varchar(64)         | NO   |     |         |       |
| snmpv3_securitylevel  | int(11)             | NO   |     | 0       |       |
| snmpv3_authpassphrase | varchar(64)         | NO   |     |         |       |
| snmpv3_privpassphrase | varchar(64)         | NO   |     |         |       |
| formula               | varchar(255)        | NO   |     | 1       |       |
| error                 | varchar(128)        | NO   |     |         |       |
| lastlogsize           | bigint(20) unsigned | NO   |     | 0       |       |
| logtimefmt            | varchar(64)         | NO   |     |         |       |
| templateid            | bigint(20) unsigned | YES  | MUL | NULL    |       |
| valuemapid            | bigint(20) unsigned | YES  | MUL | NULL    |       |
| delay_flex            | varchar(255)        | NO   |     |         |       |
| params                | text                | NO   |     | NULL    |       |
| ipmi_sensor           | varchar(128)        | NO   |     |         |       |
| data_type             | int(11)             | NO   |     | 0       |       |
| authtype              | int(11)             | NO   |     | 0       |       |
| username              | varchar(64)         | NO   |     |         |       |
| password              | varchar(64)         | NO   |     |         |       |
| publickey             | varchar(64)         | NO   |     |         |       |
| privatekey            | varchar(64)         | NO   |     |         |       |
| mtime                 | int(11)             | NO   |     | 0       |       |
| flags                 | int(11)             | NO   |     | 0       |       |
| filter                | varchar(255)        | NO   |     |         |       |
| interfaceid           | bigint(20) unsigned | YES  | MUL | NULL    |       |
| port                  | varchar(64)         | NO   |     |         |       |
| description           | text                | NO   |     | NULL    |       |
| inventory_link        | int(11)             | NO   |     | 0       |       |
| lifetime              | varchar(64)         | NO   |     | 30      |       |
| snmpv3_authprotocol   | int(11)             | NO   |     | 0       |       |
| snmpv3_privprotocol   | int(11)             | NO   |     | 0       |       |
| state                 | int(11)             | NO   |     | 0       |       |
| snmpv3_contextname    | varchar(255)        | NO   |     |         |       |
+-----------------------+---------------------+------+-----+---------+-------+
 

五、media表

###存有XX用戶的Media配置和相對應的告警方式###
mysql> DESC media;
+-------------+---------------------+------+-----+-----------------+-------+
| Field       | Type                | Null | Key | Default         | Extra |
+-------------+---------------------+------+-----+-----------------+-------+
| mediaid     | bigint(20) unsigned | NO   | PRI | NULL            |       |
| userid      | bigint(20) unsigned | NO   | MUL | NULL            |       |
| mediatypeid | bigint(20) unsigned | NO   | MUL | NULL            |       |
| sendto      | varchar(100)        | NO   |     |                 |       |
| active      | int(11)             | NO   |     | 0               |       |
| severity    | int(11)             | NO   |     | 63              |       |
| period      | varchar(100)        | NO   |     | 1-7,00:00-24:00 |       |
+-------------+---------------------+------+-----+-----------------+-------+
 

六、media_type表

mysql> desc media_type;
##存有media告警方式對應的執行腳本的信息##
+-------------+---------------------+------+-----+---------+-------+
| Field       | Type                | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| mediatypeid | bigint(20) unsigned | NO   | PRI | NULL    |       |
| type        | int(11)             | NO   |     | 0       |       |
| description | varchar(100)        | NO   |     |         |       |
| smtp_server | varchar(255)        | NO   |     |         |       |
| smtp_helo   | varchar(255)        | NO   |     |         |       |
| smtp_email  | varchar(255)        | NO   |     |         |       |
| exec_path   | varchar(255)        | NO   |     |         |       |
| gsm_modem   | varchar(255)        | NO   |     |         |       |
| username    | varchar(255)        | NO   |     |         |       |
| passwd      | varchar(255)        | NO   |     |         |       |
| status      | int(11)             | NO   |     | 0       |       |
+-------------+---------------------+------+-----+---------+-------+
 

七、triggers表

mysql> DESC triggers;
###存有觸發器相關全部信息###
+-------------+---------------------+------+-----+---------+-------+
| Field       | Type                | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| triggerid   | bigint(20) unsigned | NO   | PRI | NULL    |       |
| expression  | varchar(2048)       | NO   |     |         |       |
| description | varchar(255)        | NO   |     |         |       |
| url         | varchar(255)        | NO   |     |         |       |
| status      | int(11)             | NO   | MUL | 0       |       |
| value       | int(11)             | NO   | MUL | 0       |       |
| priority    | int(11)             | NO   |     | 0       |       |
| lastchange  | int(11)             | NO   |     | 0       |       |
| comments    | text                | NO   |     | NULL    |       |
| error       | varchar(128)        | NO   |     |         |       |
| templateid  | bigint(20) unsigned | YES  | MUL | NULL    |       |
| type        | int(11)             | NO   |     | 0       |       |
| state       | int(11)             | NO   |     | 0       |       |
| flags       | int(11)             | NO   |     | 0       |       |
+-------------+---------------------+------+-----+---------+-------+
 

八、trigger_depends表

mysql> DESC trigger_depends;
##存有觸發器的依存信息###
+----------------+---------------------+------+-----+---------+-------+
| Field          | Type                | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+---------+-------+
| triggerdepid   | bigint(20) unsigned | NO   | PRI | NULL    |       |
| triggerid_down | bigint(20) unsigned | NO   | MUL | NULL    |       |
| triggerid_up   | bigint(20) unsigned | NO   | MUL | NULL    |       |
+----------------+---------------------+------+-----+---------+-------+
 

九、graphs表

mysql> DESC graphs;
##該表存有用戶定義的圖表信息###
+------------------+---------------------+------+-----+----------+-------+
| Field            | Type                | Null | Key | Default  | Extra |
+------------------+---------------------+------+-----+----------+-------+
| graphid          | bigint(20) unsigned | NO   | PRI | NULL     |       |
| name             | varchar(128)        | NO   | MUL |          |       |
| width            | int(11)             | NO   |     | 900      |       |
| height           | int(11)             | NO   |     | 200      |       |
| yaxismin         | double(16,4)        | NO   |     | 0.0000   |       |
| yaxismax         | double(16,4)        | NO   |     | 100.0000 |       |
| templateid       | bigint(20) unsigned | YES  | MUL | NULL     |       |
| show_work_period | int(11)             | NO   |     | 1        |       |
| show_triggers    | int(11)             | NO   |     | 1        |       |
| graphtype        | int(#11)             | NO   |     | 0        |       |
| show_legend      | int(11)             | NO   |     | 1        |       |
| show_3d          | int(11)             | NO   |     | 0        |       |
| percent_left     | double(16,4)        | NO   |     | 0.0000   |       |
| percent_right    | double(16,4)        | NO   |     | 0.0000   |       |
| ymin_type        | int(11)             | NO   |     | 0        |       |
| ymax_type        | int(11)             | NO   |     | 0        |       |
| ymin_itemid      | bigint(20) unsigned | YES  | MUL | NULL     |       |
| ymax_itemid      | bigint(20) unsigned | YES  | MUL | NULL     |       |
| flags            | int(11)             | NO   |     | 0        |       |
+------------------+---------------------+------+-----+----------+-------+
 

十、graphs_items表

mysql> DESC graphs_items;
##graphs_items 保存了屬於某個圖表的全部的監控項信息###
+-----------+---------------------+------+-----+---------+-------+
| Field     | Type                | Null | Key | Default | Extra |
+-----------+---------------------+------+-----+---------+-------+
| gitemid   | bigint(20) unsigned | NO   | PRI | NULL    |       |
| graphid   | bigint(20) unsigned | NO   | MUL | NULL    |       |
| itemid    | bigint(20) unsigned | NO   | MUL | NULL    |       |
| drawtype  | int(11)             | NO   |     | 0       |       |
| sortorder | int(11)             | NO   |     | 0       |       |
| color     | varchar(6)          | NO   |     | 009600  |       |
| yaxisside | int(11)             | NO   |     | 0       |       |
| calc_fnc  | int(11)             | NO   |     | 2       |       |
| type      | int(11)             | NO   |     | 0       |       |
+-----------+---------------------+------+-----+---------+-------+
 

十一、screens表

mysql> desc screens;
##存有用戶定義的一些監控圖片組##
+------------+---------------------+------+-----+---------+-------+
| Field      | Type                | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+-------+
| screenid   | bigint(20) unsigned | NO   | PRI | NULL    |       |
| name       | varchar(255)        | NO   |     | NULL    |       |
| hsize      | int(11)             | NO   |     | 1       |       |
| vsize      | int(11)             | NO   |     | 1       |       |
| templateid | bigint(20) unsigned | YES  | MUL | NULL    |       |
+------------+---------------------+------+-----+---------+-------+
 

十二、screens_items表

mysql> desc screens_items;
##和前面graphs_items概念同樣##
+---------------+---------------------+------+-----+---------+-------+
| Field         | Type                | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| screenitemid  | bigint(20) unsigned | NO   | PRI | NULL    |       |
| screenid      | bigint(20) unsigned | NO   | MUL | NULL    |       |
| resourcetype  | int(11)             | NO   |     | 0       |       |
| resourceid    | bigint(20) unsigned | NO   |     | 0       |       |
| width         | int(11)             | NO   |     | 320     |       |
| height        | int(11)             | NO   |     | 200     |       |
| x             | int(11)             | NO   |     | 0       |       |
| y             | int(11)             | NO   |     | 0       |       |
| colspan       | int(11)             | NO   |     | 0       |       |
| rowspan       | int(11)             | NO   |     | 0       |       |
| elements      | int(11)             | NO   |     | 25      |       |
| valign        | int(11)             | NO   |     | 0       |       |
| halign        | int(11)             | NO   |     | 0       |       |
| style         | int(11)             | NO   |     | 0       |       |
| url           | varchar(255)        | NO   |     |         |       |
| dynamic       | int(11)             | NO   |     | 0       |       |
| sort_triggers | int(11)             | NO   |     | 0       |       |
| application   | varchar(255)        | NO   |     |         |       |
+---------------+---------------------+------+-----+---------+-------+
 

1三、functions表

mysql> DESC functions;
##比較重要的一張表,存有觸發器裏面各類表達式##
+------------+---------------------+------+-----+---------+-------+
| Field      | Type                | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+-------+
| functionid | bigint(20) unsigned | NO   | PRI | NULL    |       |
| itemid     | bigint(20) unsigned | NO   | MUL | NULL    |       |
| triggerid  | bigint(20) unsigned | NO   | MUL | NULL    |       |
| function   | varchar(12)         | NO   |     |         |       |
| parameter  | varchar(255)        | NO   |     | 0       |       |
+------------+---------------------+------+-----+---------+-------+
 

1四、sessions表

mysql> DESC sessions;
##存有各個用戶的session,登入登出都會操做該表##
+------------+---------------------+------+-----+---------+-------+
| Field      | Type                | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+-------+
| sessionid  | varchar(32)         | NO   | PRI |         |       |
| userid     | bigint(20) unsigned | NO   | MUL | NULL    |       |
| lastaccess | int(11)             | NO   |     | 0       |       |
| status     | int(11)             | NO   |     | 0       |       |
+------------+---------------------+------+-----+---------+-------+
 

 
» 轉載保留版權:IT辰逸 » 《Zabbix 數據庫表結構》
» 本文連接地址:http://www.ipython.me/centos/zabbix-datatable-struc.html
» 本文版權採起: BY-NC-SA 協議進行受權,轉載註明出處。除IT-Tools、News以及特別標註,本站全部文章均爲原創。
» 若是喜歡能夠: 點此訂閱本站html

相關文章
相關標籤/搜索