【Zabbix】 Zabbix表结构说明【转载】
本文转自【https://www.cnblogs.com/shhnwangjian/p/5484352.html】
参考文【https://www.cnblogs.com/learningJAVA/p/7886164.html】
■ zabbix数据库表结构的重要性
想理解zabbix的前端代码、做深入的二次开发,甚至的调优,那就不能不了解数据库的表结构了。
我们这里采用的zabbix1.8、mysql,所以简单的说下我们mysql这边的表结构,其他环境不保证正确。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
mysql> show tables; +-----------------------+ | Tables_in_zabbix | +-----------------------+ | acknowledges | | actions | | alerts | | application_template | | applications | | auditlog | | auditlog_details | | autoreg_host | | conditions | | config | | dbversion | | dchecks | | dhosts | | drules | | dservices | | escalations | | events | | expressions | | functions | | globalmacro | | globalvars | | graph_discovery | | graph_theme | | graphs | | graphs_items | | group_discovery | | group_prototype | | groups | | history | | history_log | | history_str | | history_text | | history_uint | | host_discovery | | host_inventory | | hostmacro | | hosts | | hosts_groups | | hosts_templates | | housekeeper | | httpstep | | httpstepitem | | httptest | | httptestitem | | icon_map | | icon_mapping | | ids | | images | | interface | | interface_discovery | | item_condition | | item_discovery | | items | | items_applications | | maintenances | | maintenances_groups | | maintenances_hosts | | maintenances_windows | | mappings | | media | | media_type | | opcommand | | opcommand_grp | | opcommand_hst | | opconditions | | operations | | opgroup | | opmessage | | opmessage_grp | | opmessage_usr | | optemplate | | profiles | | proxy_autoreg_host | | proxy_dhistory | | proxy_history | | regexps | | rights | | screens | | screens_items | | scripts | | service_alarms | | services | | services_links | | services_times | | sessions | | slides | | slideshows | | sysmap_element_url | | sysmap_url | | sysmaps | | sysmaps_elements | | sysmaps_link_triggers | | sysmaps_links | | timeperiods | | trends | | trends_uint | | trigger_depends | | trigger_discovery | | triggers | | user_history | | users | | users_groups | | usrgrp | | valuemaps | +-----------------------+ |
■ actions
actions表记录了当触发器触发时,需要采用的动作。
mysql> desc actions;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| actionid | bigint(20) unsigned | NO | PRI | 0 | |
| name | varchar(255) | NO | | | |
| eventsource | int(11) | NO | MUL | 0 | |
| evaltype | int(11) | NO | | 0 | |
| status | int(11) | NO | | 0 | |
| esc_period | int(11) | NO | | 0 | |
| def_shortdata | varchar(255) | NO | | | |
| def_longdata | blob | NO | | NULL | |
| recovery_msg | int(11) | NO | | 0 | |
| r_shortdata | varchar(255) | NO | | | |
| r_longdata | blob | NO | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
■ alerts
alerts 表保存了历史的告警事件,可以从这个表里面去做一些统计分析,例如某个部门、
某人、某类时间的告警统计,以及更深入的故障发生、恢复时间,看你想怎么用了。
mysql> desc alerts;
+-------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| alertid | bigint(20) unsigned | NO | PRI | 0 | |
| actionid | bigint(20) unsigned | NO | MUL | 0 | |
| eventid | bigint(20) unsigned | NO | MUL | 0 | |
| userid | bigint(20) unsigned | NO | MUL | 0 | |
| clock | int(11) | NO | PRI | 0 | |
| mediatypeid | bigint(20) unsigned | NO | MUL | 0 | |
| sendto | varchar(100) | NO | | | |
| subject | varchar(255) | NO | | | |
| message | blob | NO | | NULL | |
| status | int(11) | NO | MUL | 0 | |
| retries | int(11) | NO | | 0 | |
| error | varchar(128) | NO | | | |
| nextcheck | int(11) | NO | | 0 | |
| esc_step | int(11) | NO | | 0 | |
| alerttype | int(11) | NO | | 0 | |
+-------------+---------------------+------+-----+---------+-------+
■ config
config表保存了全局的参数,前端包括后端也是,很多情况下会查询改表的参数的,例如用户的自定义主题、
登陆认证类型等,非常重要,
不过对我们做数据分析意义不大。
mysql> desc config;
+-------------------------+---------------------+------+-----+-----------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------------+---------------------+------+-----+-----------------+-------+
| configid | bigint(20) unsigned | NO | PRI | 0 | |
| alert_history | int(11) | NO | | 0 | |
| event_history | int(11) | NO | | 0 | |
| refresh_unsupported | int(11) | NO | | 0 | |
| work_period | varchar(100) | NO | | 1-5,00:00-24:00 | |
| alert_usrgrpid | bigint(20) unsigned | NO | | 0 | |
| event_ack_enable | int(11) | NO | | 1 | |
| event_expire | int(11) | NO | | 7 | |
| event_show_max | int(11) | NO | | 100 | |
| default_theme | varchar(128) | NO | | default.css | |
| authentication_type | int(11) | NO | | 0 | |
| ldap_host | varchar(255) | NO | | | |
| ldap_port | int(11) | NO | | 389 | |
| ldap_base_dn | varchar(255) | NO | | | |
| ldap_bind_dn | varchar(255) | NO | | | |
| ldap_bind_password | varchar(128) | NO | | | |
| ldap_search_attribute | varchar(128) | NO | | | |
| dropdown_first_entry | int(11) | NO | | 1 | |
| dropdown_first_remember | int(11) | NO | | 1 | |
| discovery_groupid | bigint(20) unsigned | NO | | 0 | |
| max_in_table | int(11) | NO | | 50 | |
| search_limit | int(11) | NO | | 1000 | |
+-------------------------+---------------------+------+-----+-----------------+-------+
■ functions
function 表时非常重要的一个表了,记录了trigger中使用的表达式,例如max、last、nodata等函数。
但其实这个表说他重要时因为同时记录了trigger、itemid,那就可以做一些API的开发了,例如根据
IP 茶香改IP的所有trigger,我记得1.8的版本的API是无法实现我说的这个功能的,那只能利用
function表去自己查询了。
mysql> desc functions ;
+------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+-------+
| functionid | bigint(20) unsigned | NO | PRI | 0 | |
| itemid | bigint(20) unsigned | NO | MUL | 0 | |
| triggerid | bigint(20) unsigned | NO | MUL | 0 | |
| lastvalue | varchar(255) | YES | | NULL | |
| function | varchar(12) | NO | | | |
| parameter | varchar(255) | NO | | 0 | |
+------------+---------------------+------+-----+---------+-------+
■ graphs
graphs 表包含了用户定义的图表信息,同样的玩法可以是根据IP去查询改IP下的所有图表,
不过似乎是有API的,我只是举例而已。
mysql> desc graphs;
+------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+---------------------+------+-----+---------+-------+
| graphid | bigint(20) unsigned | NO | PRI | 0 | |
| name | varchar(128) | NO | MUL | | |
| width | int(11) | NO | | 0 | |
| height | int(11) | NO | | 0 | |
| yaxismin | double(16,4) | NO | | 0.0000 | |
| yaxismax | double(16,4) | NO | | 0.0000 | |
| templateid | bigint(20) unsigned | NO | | 0 | |
| show_work_period | int(11) | NO | | 1 | |
| show_triggers | int(11) | NO | | 1 | |
| graphtype | int(11) | NO | | 0 | |
| show_legend | int(11) | NO | | 0 | |
| 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 | NO | | 0 | |
| ymax_itemid | bigint(20) unsigned | NO | | 0 | |
+------------------+---------------------+------+-----+---------+-------+
■ graphs_items
graphs_items 保存了属于某个图表的所有的监控项信息。
mysql> desc graphs_items;
+-------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| gitemid | bigint(20) unsigned | NO | PRI | 0 | |
| graphid | bigint(20) unsigned | NO | MUL | 0 | |
| itemid | bigint(20) unsigned | NO | MUL | 0 | |
| drawtype | int(11) | NO | | 0 | |
| sortorder | int(11) | NO | | 0 | |
| color | varchar(6) | NO | | 009600 | |
| yaxisside | int(11) | NO | | 1 | |
| calc_fnc | int(11) | NO | | 2 | |
| type | int(11) | NO | | 0 | |
| periods_cnt | int(11) | NO | | 5 | |
+-------------+---------------------+------+-----+---------+-------+
■ groups
groups 没啥说的,都懂,就是保存了组名和组的ID 。
mysql> desc groups ;
+----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| groupid | bigint(20) unsigned | NO | PRI | 0 | |
| name | varchar(64) | NO | MUL | | |
| internal | int(11) | NO | | 0 | |
+----------+---------------------+------+-----+---------+-------+
■ history 、history_str、history_log 、history_uint_sync等
这部分表都差不多,唯一不同的是保存的数据类型,history_str保存的数据
类型就算str即字符类型的。这个是和采集时设置的数据类型一致的。
需要注意的时,因为history表有这么多的类型,那自己写报表系统等去查询
数据时,就需要判断下数据的采集类型,如果查错了表,那肯定时没有数据的。
mysql> desc history;
+--------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------------------+------+-----+---------+-------+
| itemid | bigint(20) unsigned | NO | PRI | 0 | |
| clock | int(11) | NO | PRI | 0 | |
| value | double(16,4) | NO | | 0.0000 | |
+--------+---------------------+------+-----+---------+-------+ mysql> desc history_str;
+--------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------------------+------+-----+---------+-------+
| itemid | bigint(20) unsigned | NO | MUL | 0 | |
| clock | int(11) | NO | | 0 | |
| value | varchar(255) | NO | | | |
+--------+---------------------+------+-----+---------+-------+
接收item值时的时间值存放在两个字段内,大于1秒的部分存放找clock字段单位是秒(s),小于一秒的部分存放在ns字段单位是纳秒(ns)。
两个字段相加的值才是接收item值时的时间值,一般不用关心小于1秒的部分。
■ trends、trends_uint
trends 也是保存了历史数据用的,和history不同的时,trends表仅仅保存了
小时平均的值,即你可以理解为是history表的数据压缩。所以trends表也有
很多的类型,对应history。
值的注意的trends和history表这两类表数据量都非常大,我们一天大概就要有
40G 的数据。
所以注意定是去做压缩、删除。
mysql> desc trends;
+-----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------------+------+-----+---------+-------+
| itemid | bigint(20) unsigned | NO | PRI | 0 | |
| 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 | |
+-----------+---------------------+------+-----+---------+-------+ mysql> desc trends_uint;
+-----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------------+------+-----+---------+-------+
| itemid | bigint(20) unsigned | NO | PRI | 0 | |
| 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 | |
+-----------+---------------------+------+-----+---------+-------+
■ hosts
hosts 非常重要,保存了每个agent、proxy等的IP 、hostid、状态、IPMI等信息,
几乎是记录了一台设备的所有的信息。
当然hostid是当中非常非常重要的信息,其他的表一般都时关联hostid的。
mysql> desc hosts;
+--------------------+---------------------+------+-----+-----------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------------+------+-----+-----------+-------+
| hostid | bigint(20) unsigned | NO | PRI | 0 | |
| proxy_hostid | bigint(20) unsigned | NO | MUL | 0 | |
| host | varchar(64) | NO | MUL | | |
| dns | varchar(64) | NO | | | |
| useip | int(11) | NO | | 1 | |
| ip | varchar(39) | NO | | 127.0.0.1 | |
| port | int(11) | NO | | 10050 | |
| 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 | |
| inbytes | bigint(20) unsigned | NO | | 0 | |
| outbytes | bigint(20) unsigned | NO | | 0 | |
| useipmi | int(11) | NO | | 0 | |
| ipmi_port | int(11) | NO | | 623 | |
| 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 | NO | | 0 | |
| maintenance_status | int(11) | NO | | 0 | |
| maintenance_type | int(11) | NO | | 0 | |
| maintenance_from | int(11) | NO | | 0 | |
| ipmi_ip | varchar(64) | NO | | 127.0.0.1 | |
| ipmi_errors_from | int(11) | NO | | 0 | |
| snmp_errors_from | int(11) | NO | | 0 | |
| ipmi_error | varchar(128) | NO | | | |
| snmp_error | varchar(128) | NO | | | |
+--------------------+---------------------+------+-----+-----------+-------+
其实1.0的版本中,是没有这么多的字段的,好像只有hostid、host、status、disable_until
等几个字段,但1.8已经如此丰富了。
■
hosts_groups
hosts_groups 保存了host(主机)与host groups(主机组)的关联关系。
这部分信息可以在我们自己做一些批量查询,例如查询关联到某个主机组的所有
设备的IP 、存活状态等,进一步去查询该批量设备的load、IO、mem等统计信息。
我之前做的一个简单的报表就是例如了这部分的信息去查询某个业务线下所有设备
的一周统计信息,当然了是在同一个主机组或者模版组才可以的。
mysql> desc hosts_groups ;
+-------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| hostgroupid | bigint(20) unsigned | NO | PRI | 0 | |
| hostid | bigint(20) unsigned | NO | MUL | 0 | |
| groupid | bigint(20) unsigned | NO | MUL | 0 | |
+-------------+---------------------+------+-----+---------+-------+
■ items
items 表保存了采集项的信息。
mysql> desc items ;
+-----------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+---------------------+------+-----+---------+-------+
| itemid | bigint(20) unsigned | NO | PRI | 0 | |
| type | int(11) | NO | | 0 | |
| snmp_community | varchar(64) | NO | | | |
| snmp_oid | varchar(255) | NO | | | |
| snmp_port | int(11) | NO | | 161 | |
| hostid | bigint(20) unsigned | NO | MUL | 0 | |
| description | varchar(255) | NO | | | |
| key_ | varchar(255) | NO | | | |
| delay | int(11) | NO | | 0 | |
| history | int(11) | NO | | 90 | |
| trends | int(11) | NO | | 365 | |
| lastvalue | varchar(255) | YES | | NULL | |
| lastclock | int(11) | YES | | NULL | |
| prevvalue | varchar(255) | YES | | NULL | |
| status | int(11) | NO | MUL | 0 | |
| value_type | int(11) | NO | | 0 | |
| trapper_hosts | varchar(255) | NO | | | |
| units | varchar(10) | NO | | | |
| multiplier | int(11) | NO | | 0 | |
| delta | int(11) | NO | | 0 | |
| prevorgvalue | varchar(255) | YES | | NULL | |
| 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 | int(11) | NO | | 0 | |
| logtimefmt | varchar(64) | NO | | | |
| templateid | bigint(20) unsigned | NO | MUL | 0 | |
| valuemapid | bigint(20) unsigned | NO | | 0 | |
| 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 | |
+-----------------------+---------------------+------+-----+---------+-------+
■ media
media 保存了某个用户的media配置项,即对应的告警方式。
mysql> desc media;
+-------------+---------------------+------+-----+-----------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+-----------------+-------+
| mediaid | bigint(20) unsigned | NO | PRI | 0 | |
| userid | bigint(20) unsigned | NO | MUL | 0 | |
| mediatypeid | bigint(20) unsigned | NO | MUL | 0 | |
| sendto | varchar(100) | NO | | | |
| active | int(11) | NO | | 0 | |
| severity | int(11) | NO | | 63 | |
| period | varchar(100) | NO | | 1-7,00:00-23:59 | |
+-------------+---------------------+------+-----+-----------------+-------+
■ media_type
media_type 表与media 表不同的是media_type 记录了某个告警方式对应的脚步等的存放路径。
mysql> desc media_type;
+-------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| mediatypeid | bigint(20) unsigned | NO | PRI | 0 | |
| 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 | | | |
+-------------+---------------------+------+-----+---------+-------+
media 与media_type 通过mediatypeid 键关联。
■ profiles
profiles 表保存了用户的一些配置项。
mysql> desc profiles ;
+-----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------------+------+-----+---------+-------+
| profileid | bigint(20) unsigned | NO | PRI | 0 | |
| userid | bigint(20) unsigned | NO | MUL | 0 | |
| idx | varchar(96) | NO | | | |
| idx2 | bigint(20) unsigned | NO | | 0 | |
| value_id | bigint(20) unsigned | NO | | 0 | |
| value_int | int(11) | NO | | 0 | |
| value_str | varchar(255) | NO | | | |
| source | varchar(96) | NO | | | |
| type | int(11) | NO | | 0 | |
+-----------+---------------------+------+-----+---------+-------+
■ rights
rights 表保存了用户组的权限信息,zabbix的权限一直也是我理不太清的地方,
其实这个表里面有详细的记录。
mysql> desc rights;
+------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+-------+
| rightid | bigint(20) unsigned | NO | PRI | 0 | |
| groupid | bigint(20) unsigned | NO | MUL | 0 | |
| permission | int(11) | NO | | 0 | |
| id | bigint(20) unsigned | YES | MUL | NULL | |
+------------+---------------------+------+-----+---------+-------+
■ screens
screens 表保存了用户定义的图片。
mysql> desc graphs;
+------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+---------------------+------+-----+---------+-------+
| graphid | bigint(20) unsigned | NO | PRI | 0 | |
| name | varchar(128) | NO | MUL | | |
| width | int(11) | NO | | 0 | |
| height | int(11) | NO | | 0 | |
| yaxismin | double(16,4) | NO | | 0.0000 | |
| yaxismax | double(16,4) | NO | | 0.0000 | |
| templateid | bigint(20) unsigned | NO | | 0 | |
| show_work_period | int(11) | NO | | 1 | |
| show_triggers | int(11) | NO | | 1 | |
| graphtype | int(11) | NO | | 0 | |
| show_legend | int(11) | NO | | 0 | |
| 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 | NO | | 0 | |
| ymax_itemid | bigint(20) unsigned | NO | | 0 | |
+------------------+---------------------+------+-----+---------+-------+
■ screens_items
同graphs_items。
mysql> desc screens_items;
+--------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+---------------------+------+-----+---------+-------+
| screenitemid | bigint(20) unsigned | NO | PRI | 0 | |
| screenid | bigint(20) unsigned | NO | | 0 | |
| 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 | |
+--------------+---------------------+------+-----+---------+-------+
■ sessions
sessions 表很重要,保存了每个用户的sessions,在登陆、注销的时候均会操作
该张表的。
做cas等统一认证时,需要了解下该表和相关的登陆、验证流程。有兴趣的看我
前面的文章吧。
mysql> desc sessions;
+------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+-------+
| sessionid | varchar(32) | NO | PRI | | |
| userid | bigint(20) unsigned | NO | MUL | 0 | |
| lastaccess | int(11) | NO | | 0 | |
| status | int(11) | NO | | 0 | |
+------------+---------------------+------+-----+---------+-------+
■ triggers
triggers 顾名思义保存了trigger的所有信息。
mysql> desc triggers;
+-------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| triggerid | bigint(20) unsigned | NO | PRI | 0 | |
| expression | varchar(255) | 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 | |
| dep_level | int(11) | NO | | 0 | |
| comments | blob | NO | | NULL | |
| error | varchar(128) | NO | | | |
| templateid | bigint(20) unsigned | NO | | 0 | |
| type | int(11) | NO | | 0 | |
+-------------+---------------------+------+-----+---------+-------+
■ trigger_depends
trigger_depends 保存了trigger的依赖关系。
mysql> desc trigger_depends;
+----------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+---------+-------+
| triggerdepid | bigint(20) unsigned | NO | PRI | 0 | |
| triggerid_down | bigint(20) unsigned | NO | MUL | 0 | |
| triggerid_up | bigint(20) unsigned | NO | MUL | 0 | |
+----------------+---------------------+------+-----+---------+-------+
■ users
不需要解释了,值的一提的部分用户配置会在该表中,例如auotlogin、autologout、
url、theme等信息。
mysql> desc users;
+----------------+---------------------+------+-----+-------------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+-------------+-------+
| userid | bigint(20) unsigned | NO | PRI | 0 | |
| alias | varchar(100) | NO | MUL | | |
| name | varchar(100) | NO | | | |
| surname | varchar(100) | NO | | | |
| passwd | char(32) | NO | | | |
| url | varchar(255) | NO | | | |
| autologin | int(11) | NO | | 0 | |
| autologout | int(11) | NO | | 900 | |
| lang | varchar(5) | NO | | en_gb | |
| refresh | int(11) | NO | | 30 | |
| type | int(11) | NO | | 0 | |
| theme | varchar(128) | NO | | default.css | |
| attempt_failed | int(11) | NO | | 0 | |
| attempt_ip | varchar(39) | NO | | | |
| attempt_clock | int(11) | NO | | 0 | |
| rows_per_page | int(11) | NO | | 50 | |
+----------------+---------------------+------+-----+-------------+-------+
■ 转载:http://www.furion.info/623.html
使用python获取表中TCP连接数,生成Execl文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#/usr/bin/env python # -*- coding: utf-8 -*- import MySQLdb import xlsxwriter import time host_list = [ '192.168.0.1' , '192.168.0.2' , '192.168.0.3' , ] def sql_login(ip): conn = MySQLdb.connect(host = '地址' , port = 3306 , user = '账号' , passwd = '密码' , db = '库名' ) cur = conn.cursor() sql_context = "select itemid, FROM_UNIXTIME(clock, '%Y-%m-%d %H:%i:%S'), value " \ "from history_uint where itemid = (select itemid from items where items.key_ = 'tcpconn' " \ "and items.hostid = (select hostid from hosts where host = '" + ip + \ "')) and clock >= UNIX_TIMESTAMP('2016-04-22 18:00:00') and clock < UNIX_TIMESTAMP('2016-04-24 00:00:00')" reCount = cur.execute(sql_context) nRet = cur.fetchall() cur.close() conn.close() print reCount #print nRet perfix = time.strftime( '%y%m%d%H%M%S' ) xfilename = "./data/" + ip + "_conn_" + perfix + ".xlsx" workbook = xlsxwriter.Workbook(xfilename) worksheet1 = workbook.add_worksheet() worksheet1.write( 'A1' , u '主机地址' ) worksheet1.write( 'B1' , u '时间' ) worksheet1.write( 'C1' , u 'TCP连接数' ) row = 1 for i in nRet: print i[ 0 ], i[ 1 ], i[ 2 ] worksheet1.write(row, 0 , ip) worksheet1.write(row, 1 , i[ 1 ]) worksheet1.write(row, 2 , i[ 2 ]) row + = 1 if row = = reCount: break workbook.close() def run(): for ip in host_list: sql_login(ip) if __name__ = = '__main__' : run() |
【Zabbix】 Zabbix表结构说明【转载】的更多相关文章
- 15.5 自学Zabbix之路15.5 Zabbix数据库表结构简单解析-其他 表
点击返回:自学Zabbix之路 自学Zabbix之路15.5 Zabbix数据库表结构简单解析-其他 表 1. Actions表 actions表记录了当触发器触发时,需要采用的动作. 2.Aler ...
- 自学Zabbix之路15.1 Zabbix数据库表结构简单解析-Hosts表、Hosts_groups表、Interface表
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 自学Zabbix之路15.1 Zabbix数据库表结构简单解析-Hosts表.Hosts_grou ...
- 自学Zabbix之路15.2 Zabbix数据库表结构简单解析-Items表
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 自学Zabbix之路15.2 Zabbix数据库表结构简单解析-Items表 Items表记录了i ...
- 自学Zabbix之路15.3 Zabbix数据库表结构简单解析-Triggers表、Applications表、 Mapplings表
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 自学Zabbix之路15.3 Zabbix数据库表结构简单解析-Triggers表.Applica ...
- 自学Zabbix之路15.4 Zabbix数据库表结构简单解析-Expressions表、Media表、 Events表
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 自学Zabbix之路15.4 Zabbix数据库表结构简单解析-Expressions表.Medi ...
- 自学Zabbix之路15.5 Zabbix数据库表结构简单解析-其他 表
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 自学Zabbix之路15.5 Zabbix数据库表结构简单解析-其他 表 1. Actions表 ...
- zabbix数据库表结构解析
下面开始介绍: 1.添加监控表结构详解 (1)hosts,存储被监控的机器的信息,表结构如下: (2)items (3)hosts_templates,存储机器和模版或者模版和模版之间的关系 由于模 ...
- Zabbix数据库表结构
上一篇:Zabbix分布式监控 acknowledges 当出现报错的时候记录 查看着张表记录了一个事件 actions 动作 自动发现 问题告警 恢复告警 自动注册 alerts 报警信息 同web ...
- SQL Server 修改表结构(转载)
SQL Server 修改表结构 本文链接:https://blog.csdn.net/petezh/article/details/81744374 查看指定表结构 exec sp_help Rep ...
- 【Oracle 数据迁移】环境oracle 11gR2,exp无法导出空表的表结构【转载】
今天做数据迁移,但是发现有些空表无法exp,后来找到问题所在. [原文]:http://www.cnblogs.com/wenlong/p/3684230.html 11GR2中有个新特性,当表无数据 ...
随机推荐
- WIN7下PS/2等键盘失灵无法使用的解决办法
WIN7下PS/2等键盘失灵无法使用的解决办法 装了win7,无意中一天开机,发现键盘不能用了.开始以为键盘坏了,重启看机,一看能进bios,各键正常.然后再重启,进系统,看设备管理器,发现键盘为黄色 ...
- linux 更改用户的默认shell
由于卸载了zsh.导致用户的bash没有更新 用户无法登录.后来通过grup更改.修改/etc/passwd中的用户的shell成功 将下面的红色的更改成bash即可. root:x:::root:/ ...
- 数据结构--hashtable(散列表)
散列 散列又叫hash.是通过关键字把数据映射到指定位置的一种数据结构.理想的散列表,是一个包含关键字的固定大小的数组 哈希表存储的是键值对,其查找的时间复杂度与元素数量多少无关,哈希表在查找元素时是 ...
- 解决 Cannot find OpenSSL's <evp.h> 和sasl.h not found!
编译mongodb拓展出现 Cannot find OpenSSL's <evp.h> 解决方法:安装openssl yum install openssl openssl-devel 出 ...
- Java中的“&”和“&&”的区别
Java中的"&"和"&&"的区别 1."&"是位运算符,"&&"是逻辑 ...
- JustMock .NET单元测试利器(一)
1.什么是Mock? Mock一词是指模仿或者效仿,用于创建实例和静态模拟.安排和验证行为.在软件开发中提及"mock",通常理解为模拟对象.模拟对象的概念就是我们想要创建一个可以 ...
- jQuery.isPlainObject()的作用
jQuery.isPlainObject()函数用于判断指定参数是否是一个纯粹的对象. 所谓"纯粹的对象",就是该对象是通过"{}"或"new Obj ...
- spring配置datasource三种方式及具体信息
1.使用org.springframework.jdbc.datasource.DriverManagerDataSource说明:DriverManagerDataSource建立连接是只要有连接就 ...
- C# wav语音文件合并
开发完成语音播报产品,由于客户所使用的播放产品种类繁多,在使用HDMI接口播放音频时,由于采用的声卡不同,个别机器会出现播报声音过小,或者不播报的情况.所以采用将语音文件合并播放的方式,来解决此问题. ...
- Python基础_文件的的处理及异常处理
今天主要讲讲文件读写及异常处理. 一.文件操作 1.1 文件的创建及读 打开文件 open 函数 open(file,[option]) file 是要打开的文件 option是可选择的参数文件的打 ...