dbeaver的官方文档并没说明怎么去自定义内部的 dashboard 模版。
但是,他是开源的,有源代码可查的。
而且,他是java的,即使没有源代码,你也可以简单的去反编译class来读取源代码!
#==========================================================
以下是我的一点研究。
#==========================================================
不得不说 dbeaver 的实现真的很优雅。这种普遍的、灵活的、繁琐的需求,人家早就通过一套机制简单的处理了。 dashboard 模版自定义可以简单的通过修改 [DBEAVER_INSTALL_HOME]\plugins\org.jkiss.dbeaver.ext.mysql_????????.jar\plugin.xml 文件来实现。 说明:<mapQuery id="mysql.query.status" updatePeriod="1000">SHOW GLOBAL STATUS</mapQuery>这是dbeaver全局的查询(注意其id="mysql.query.status",sql语句是"SHOW GLOBAL STATUS"),这个查询具有全局的查询频次(updatePeriod="1000")
<dashboard id="mysql.traffic" mapQuery="mysql.query.status" label="MySQL Net Traffic" defaultView="timeseries" group="Status" calc="delta" value="bytes" mapKeys="Bytes_sent,Bytes_received" mapLabels="Sent,Received" measure="Kb/s" showByDefault="true" description="Server outbound traffic"> <datasource id="mysql"/> </dashboard>
这是dbeaver内置的、不可编辑的内置dashboard。每个属性,基本上可以通过字面意思明白。
需要注意的是:他们的查询都是通过调用全局的查询(mapQuery)来获取数据源的 ,其字段来源于全局查询的行记录,标题可以通过对应数量的自定了标签来实现。
值得注意的是:这种通过mapQuery的方式,本质上还是适用于类似 show global status的查询;其特点是【n行2列:n行中的每一行都有其独立的意义】,我们可以只观测自己关心的某一行或多行,不需要关注整体的意义。
#==========================================================
例子: 绿色背景的是我自己自定义的。<extension point="org.jkiss.dbeaver.dashboard"> <mapQuery id="mysql.query.status" updatePeriod="1000">SHOW GLOBAL STATUS</mapQuery> <mapQuery id="mysql.query.connect" updatePeriod="5000"> select t.PROCESSLIST_USER as user,count(t.PROCESSLIST_HOST) as hosts from performance_schema.threads t where t.PROCESSLIST_USER is not null group by t.PROCESSLIST_USER order by 1 </mapQuery> <dashboard id="mysql.user_connect" mapQuery="mysql.query.connect" label="MySQL user connect" defaultView="timeseries" group="Status" calc="value" value="integer" mapKeys="root" mapLabels="root user" showByDefault="false" description="MySQL root user"> <datasource id="mysql"/> </dashboard> <dashboard id="mysql.traffic" mapQuery="mysql.query.status" label="MySQL Net Traffic" defaultView="timeseries" group="Status" calc="delta" value="bytes" mapKeys="Bytes_sent,Bytes_received" mapLabels="Sent,Received" measure="Kb/s" showByDefault="true" description="Server outbound traffic"> <datasource id="mysql"/> </dashboard> <dashboard id="mysql.innodb.data" mapQuery="mysql.query.status" label="InnoDB data IO" defaultView="timeseries" group="Status" calc="delta" value="bytes" mapKeys="Innodb_data_read,Innodb_data_written" mapLabels="Read,Write" measure="Kb/s" showByDefault="true" description="InnoDB data stats"> <datasource id="mysql"/> </dashboard> <dashboard id="mysql.innodb.lock_cw" mapQuery="mysql.query.status" label="InnoDB lock" defaultView="timeseries" group="Status" calc="value" value="integer" mapKeys="Innodb_row_lock_current_waits" mapLabels="Innodb_row_lock_current_waits" showByDefault="false" description="Innodb_row_lock_current_waits"> <datasource id="mysql"/> </dashboard> <dashboard id="mysql.innodb.memory" mapQuery="mysql.query.status" label="InnoDB memory" defaultView="timeseries" group="Status" calc="value" value="bytes" mapKeys="Innodb_mem_total,Innodb_mem_dictionary,Innodb_mem_adaptive_hash" mapLabels="Total,Dict,Hash" showByDefault="false" description="InnoDB memory stats"> <datasource id="mysql"/> </dashboard> <dashboard id="mysql.com.queries" mapQuery="mysql.query.status" label="DML Queries" defaultView="timeseries" group="Status" calc="delta" value="integer" mapKeys="Com_select,Com_insert,Com_update,Com_delete" mapLabels="Select,Insert,Update,Delete" showByDefault="true" description="Queries stats"> <datasource id="mysql"/> </dashboard> <dashboard id="mysql.Threads_running" mapQuery="mysql.query.status" label="Threads_running" defaultView="timeseries" group="Status" updatePeriod="1000" calc="value" value="integer" mapKeys="Threads_running" mapLabels="Threads_running" showByDefault="true" description="Threads_running"> <datasource id="mysql"/> </dashboard> </extension>
标签:自定义,模版,dbeaver,Community,查询,dashboard,PROCESSLIST From: https://www.cnblogs.com/jinzhenshui/p/17670961.html