Copilot commented on code in PR #3899:
URL: https://github.com/apache/hertzbeat/pull/3899#discussion_r2607174904
##########
hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/database/JdbcCommonCollect.java:
##########
@@ -529,6 +529,8 @@ private String constructDatabaseUrl(JdbcProtocol
jdbcProtocol, String host, Stri
case "mysql", "mariadb" -> "jdbc:mysql://" + host + ":" + port
+ "/" + (jdbcProtocol.getDatabase() == null ? "" :
jdbcProtocol.getDatabase())
+ "?useUnicode=true&characterEncoding=utf-8&useSSL=false";
+ case "xugu" -> "jdbc:xugu://" + jdbcProtocol.getHost() + ":" +
jdbcProtocol.getPort()
Review Comment:
The xugu case uses `jdbcProtocol.getHost()` and `jdbcProtocol.getPort()`
instead of the local `host` and `port` parameters. This is inconsistent with
all other database platforms in the switch statement. Use the method parameters
`host` and `port` directly for consistency:
```java
case "xugu" -> "jdbc:xugu://" + host + ":" + port
+ "/" + (jdbcProtocol.getDatabase() == null ? "" :
jdbcProtocol.getDatabase());
```
```suggestion
case "xugu" -> "jdbc:xugu://" + host + ":" + port
```
##########
home/docs/help/xugu.md:
##########
@@ -0,0 +1,68 @@
+---
+id: xugu
+title: Monitoring xuguDB Database Monitoring
Review Comment:
The title contains redundant wording. "Monitoring xuguDB Database
Monitoring" should be simplified to "Monitoring xuguDB Database" or "xuguDB
Database Monitoring" to avoid repetition.
```suggestion
title: xuguDB Database Monitoring
```
##########
home/docs/help/xugu.md:
##########
@@ -0,0 +1,68 @@
+---
+id: xugu
+title: Monitoring xuguDB Database Monitoring
+sidebar_label: xugu Database
+keywords: [ Open Source Monitoring System, Open Source Database Monitoring,
xugu Database Monitoring ]
+---
+
+> Collect and monitor common performance metrics of the xugu database.
Supports xuguDB.v12.
+
+### Note: You must add the xugu JDBC driver JAR
+
+- Download the xugu JDBC driver JAR, for example: xugu-jdbc-12.3.5.jar.
<https://mvnrepository.com/artifact/com.xugudb/xugu-jdbc/12.3.5>
+- Copy this JAR file to the `ext-lib` directory under the HertzBeat
installation directory.
+- Restart the HertzBeat service.
+
+### Configuration Parameters
+
+| Parameter Name | Description
|
+|----------------|------------------------------------------------------------------------------|
+| Monitoring Host | The IPv4, IPv6, or domain name of the monitored target. ⚠️
Do not include protocol headers (e.g., https://, http://). |
+| Task Name | The name that identifies this monitoring task. The name
must be unique. |
+| Port | The port exposed by the database, default is 5138.
|
+| Query Timeout | The timeout for SQL queries when no response is received,
in milliseconds. Default is 3000 ms. |
+| Database Name | The database instance name, optional.
|
+| Username | Database connection username.
|
+| Password | Database connection password.
|
+| URL | Database connection URL, optional. If configured, the
database name, username, password and other parameters in the URL will override
the above settings. |
+| Collection Interval | The interval for periodically collecting monitoring
data, in seconds. The minimum configurable interval is 30 seconds. |
+| Enable Detection | Whether to probe and check availability before adding
monitoring. The add/modify operation proceeds only if the probe succeeds. |
+| Description | Additional notes and descriptions for this monitoring,
where users can add remarks. |
+
+### Collected Metrics
+
+#### Metric Set: Session Information
+
+| Metric Name | Unit | Description |
+|--------------------------------|------|-----------------------------|
+| Idle_Connection | N/A | Idle connections |
+| Active_Connections | N/A | Active connections |
+| Connection_being_created | N/A | Connections being created |
+| Null_Read_Connection | N/A | Empty read connections |
+| Complete_data_input_connection | N/A | Connections with completed data
input |
+| Other | N/A | Others |
+
+#### Metric Set: Memory Information
+
+| Metric Name | Unit | Description |
+|------------|------|-------------------------------------|
+| G_MEM | B | Global memory consumption |
+| CATA_MEM | B | CATALOG memory consumption |
+| TRAN_MEM | B | Transaction memory consumption |
+| NET_MEM | B | User connection memory consumption |
+| TASK_MEM | B | Task thread memory consumption |
+| MSG_MEM | B | Internal communication message memory consumption |
+| LOCK_MEM | B | Local lock memory consumption |
+| GLOCK_MEM | B | Global lock memory consumption |
+| DLCHK_MEM | B | Deadlock detection memory consumption|
+| MODI_MEM | B | Change log memory consumption |
+| PROC_MEM | B | Procedure execution engine memory consumption |
+
+#### Metric Set: Disk Information
+
+| Metric Name | Unit | Description |
+|-------------------|------|-------------------------------------|
+| DISK_READ_NUM | N/A | Number of disk block read operations |
+| DISK_WRITE_NUM | N/A | Number of disk block write operations |
Review Comment:
Inconsistency between documentation and configuration: The documentation
shows "N/A" for the unit of DISK_READ_NUM and DISK_WRITE_NUM, but the
configuration file (app-xugu.yml lines 273, 279) specifies "Times" as the unit.
These should be aligned. Either update the documentation to show "Times" or
update the configuration to not specify a unit (which would display as N/A).
```suggestion
| DISK_READ_NUM | Times | Number of disk block read operations |
| DISK_WRITE_NUM | Times | Number of disk block write operations |
```
##########
hertzbeat-manager/src/main/resources/define/app-xugu.yml:
##########
@@ -0,0 +1,306 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# The monitoring type category:service-application service monitoring
db-database monitoring custom-custom monitoring os-operating system monitoring
+category: db
+app: xugu
+# The monitoring i18n name
+name:
+ zh-CN: 虚谷数据库
+ en-US: Xugu DB
+# The description and help of this monitoring type
+help:
+ zh-CN: HertzBeat 使用 <a class='help_module_content'
href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> JDBC 协议</a> 通过配置
SQL 对 虚谷 数据库的通用性能指标(会话 信息、内存 信息、磁盘 信息)进行采集监控,支持版本为 XuguDB V12。<br>您可以点击“<i>新建
虚谷数据库</i>”并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
+ en-US: HertzBeat uses <a class='help_module_content'
href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> The JDBC
protocol enables the collection and monitoring of general performance metrics
(session information, memory information, disk information) for Xugu
Database by configuring SQL. It supports XuguDB V12..
Review Comment:
The English help text has several issues:
1. The sentence structure is awkward - "The JDBC protocol enables..."
appears after an incomplete link tag
2. Contains extra zero-width characters around "Xugu Database" and "XuguDB
V12" ()
3. Double period at the end (..)
Suggested correction: Remove the extra article "The", fix the sentence
structure, remove zero-width characters, and fix the double period.
```suggestion
en-US: HertzBeat uses the <a class='help_module_content'
href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'>JDBC protocol</a>
to collect and monitor general performance metrics (session information, memory
information, disk information) for Xugu Database by configuring SQL. It
supports XuguDB V12.
```
##########
hertzbeat-manager/src/main/resources/define/app-xugu.yml:
##########
@@ -0,0 +1,306 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# The monitoring type category:service-application service monitoring
db-database monitoring custom-custom monitoring os-operating system monitoring
+category: db
+app: xugu
+# The monitoring i18n name
+name:
+ zh-CN: 虚谷数据库
+ en-US: Xugu DB
+# The description and help of this monitoring type
+help:
+ zh-CN: HertzBeat 使用 <a class='help_module_content'
href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> JDBC 协议</a> 通过配置
SQL 对 虚谷 数据库的通用性能指标(会话 信息、内存 信息、磁盘 信息)进行采集监控,支持版本为 XuguDB V12。<br>您可以点击“<i>新建
虚谷数据库</i>”并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
+ en-US: HertzBeat uses <a class='help_module_content'
href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> The JDBC
protocol enables the collection and monitoring of general performance metrics
(session information, memory information, disk information) for Xugu
Database by configuring SQL. It supports XuguDB V12..
+helpLink:
+ zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/xugu
+ en-US: https://hertzbeat.apache.org/docs/help/xugu
+# Input params define for monitoring(render web ui by the definition)
+params:
+ # field-param field key
+ - field: host
+ # name-param field display i18n name
+ name:
+ zh-CN: 目标Host
+ en-US: Target Host
+ # type-param field type(most mapping the html input type)
+ type: host
+ # required-true or false
+ required: true
+ # field-param field key
+ - field: port
+ # name-param field display i18n name
+ name:
+ zh-CN: 端口
+ en-US: Port
+ # type-param field type(most mapping the html input type)
+ type: number
+ # when type is number, range is required
+ range: '[0,65535]'
+ # required-true or false
+ required: true
+ # default value
+ defaultValue: 5138
+ # field-param field key
+ - field: timeout
+ # name-param field display i18n name
+ name:
+ zh-CN: 查询超时时间(ms)
+ en-US: Query Timeout(ms)
+ # type-param field type(most mapping the html input type)
+ type: number
+ # when type is number, range is required
+ range: '[400,200000]'
+ # required-true or false
+ required: false
+ # hide param-true or false
+ hide: true
+ # default value
+ defaultValue: 6000
+ # field-param field key
+ - field: database
+ # name-param field display i18n name
+ name:
+ zh-CN: 数据库名称
+ en-US: Database Name
+ # type-param field type(most mapping the html input tag)
+ type: text
+ # required-true or false
+ required: false
+ # field-param field key
+ - field: username
+ # name-param field display i18n name
+ name:
+ zh-CN: 用户名
+ en-US: Username
+ # type-param field type(most mapping the html input tag)
+ type: text
+ # when type is text, use limit to limit string length
+ limit: 50
+ # required-true or false
+ required: false
+ # field-param field key
+ - field: password
+ # name-param field display i18n name
+ name:
+ zh-CN: 密码
+ en-US: Password
+ # type-param field type(most mapping the html input tag)
+ type: password
+ # required-true or false
+ required: false
+ # field-param field key
+
+# collect metrics config list
+metrics:
+ # metrics - basic
+ - name: Session Information
+ priority: 0
+ i18n:
+ zh-CN: 会话 信息
+ en-US: Session Info
+ # collect metrics content
+ fields:
+ # field-metric name, type-metric type(0-number,1-string), unit-metric
unit('%','ms','MB'), label-whether it is a metrics label field
+ - field: Idle_Connection
+ type: 0
+ label: true
+ i18n:
+ zh-CN: 空闲连接
+ en-US: Idle Connection
+ - field: Active_Connections
+ type: 0
+ i18n:
+ zh-CN: 活跃连接
+ en-US: Active Connections
+ - field: Connection_being_created
+ type: 0
+ i18n:
+ zh-CN: 正在创建的连接
+ en-US: Connection being created
+ - field: Null_Read_Connection
+ type: 0
+ i18n:
+ zh-CN: 空读连接
+ en-US: Null Read Connection
+ - field: Complete_data_input_connection
+ type: 0
+ i18n:
+ zh-CN: 完成数据输入连接
+ en-US: Complete data input connection
+ - field: Other
+ type: 0
+ i18n:
+ zh-CN: 其他
+ en-US: Other
+ protocol: jdbc
+ jdbc:
+ host: ^_^host^_^
+ port: ^_^port^_^
+ platform: xugu
+ # username
+ username: ^_^username^_^
+ # password
+ password: ^_^password^_^
+ # database name
+ database: ^_^database^_^
+ # timeout unit:ms
+ timeout: ^_^timeout^_^
+ queryType: columns
+ # sql
+ sql: SELECT CASE status WHEN 112 THEN 'Idle_Connection' WHEN 114 THEN
'Active_Connections' WHEN 111 THEN 'Connection_being_created' WHEN 113 THEN
'Null_Read_Connection' WHEN 115 THEN 'Complete_data_input_connection' ELSE
'Other' END AS 状态, COUNT(*) AS 数量 FROM sys_sessions GROUP BY status;
Review Comment:
The SQL query contains Chinese column aliases "状态" and "数量". For better
maintainability and consistency with other database configurations in the
codebase, consider using English column aliases that match the expected field
names. Since the queryType is "columns", the column names should match the
field names defined in the fields section (Idle_Connection, Active_Connections,
etc.). For example:
```sql
SELECT
CASE status
WHEN 112 THEN 'Idle_Connection'
WHEN 114 THEN 'Active_Connections'
WHEN 111 THEN 'Connection_being_created'
WHEN 113 THEN 'Null_Read_Connection'
WHEN 115 THEN 'Complete_data_input_connection'
ELSE 'Other'
END AS status_type,
COUNT(*) AS count
FROM sys_sessions
GROUP BY status;
```
```suggestion
sql: SELECT CASE status WHEN 112 THEN 'Idle_Connection' WHEN 114
THEN 'Active_Connections' WHEN 111 THEN 'Connection_being_created' WHEN 113
THEN 'Null_Read_Connection' WHEN 115 THEN 'Complete_data_input_connection'
ELSE 'Other' END AS status_type, COUNT(*) AS count FROM sys_sessions GROUP
BY status;
```
##########
home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/xugu.md:
##########
@@ -0,0 +1,68 @@
+---
+id: xugu
+title: 监控:xuguDB数据库监控
+sidebar_label: xugu数据库
+keywords: [ 开源监控系统, 开源数据库监控, xugu数据库监控 ]
+---
+
+> 对xugu数据库的通用性能指标进行采集监控。支持xuguDB.v12。
+
+### 注意,必须添加 xugu jdbc 驱动 jar
+
+- 下载 xugu jdbc driver jar, 例如 xugu-jdbc-12.3.5.jar.
<https://mvnrepository.com/artifact/com.xugudb/xugu-jdbc/12.3.5>
+- 将此 jar 包拷贝放入 HertzBeat 的安装目录下的 `ext-lib` 目录下.
+- 重启 HertzBeat 服务。
+
+### 配置参数
+
+| 参数名称 | 参数帮助描述 |
+|--------|------------------------------------------------------|
+| 监控Host | 被监控的对端IPV4,IPV6或域名。注意⚠️不带协议头(eg: https://, http://)。 |
+| 任务名称 | 标识此监控的名称,名称需要保证唯一性。 |
+| 端口 | 数据库对外提供的端口,默认为5138。 |
+| 查询超时时间 | 设置SQL查询未响应数据时的超时时间,单位ms毫秒,默认3000毫秒。 |
+| 数据库名称 | 数据库实例名称,可选。 |
+| 用户名 | 数据库连接用户 |
+| 密码 | 数据库连接密码 |
+| URL | 数据库连接URL,可选,若配置,则URL里面的数据库名称,用户名密码等参数会覆盖上面配置的参数 |
+| 采集间隔 | 监控周期性采集数据间隔时间,单位秒,可设置的最小间隔为30秒 |
+| 是否探测 | 新增监控前是否先探测检查监控可用性,探测成功才会继续新增修改操作 |
+| 描述备注 | 更多标识和描述此监控的备注信息,用户可以在这里备注信息 |
+
+### 采集指标
+
+#### 指标集合:会话 信息
+
+| 指标名称 | 指标单位 | 指标帮助描述 |
+|--------------------------------|------|----------|
+| Idle_Connection | 无 | 空闲连接 |
+| Active_Connections | 无 | 活跃连接 |
+| Connection_being_created | 无 | 正在创建的连接 |
+| Null_Read_Connection | 无 | 空读连接 |
+| Complete_data_input_connection | 无 | 完成数据输入连接 |
+| Other | 无 | 其他 |
+
+#### 指标集合:内存 信息
+
+| 指标名称 | 指标单位 | 指标帮助描述 |
+|-----------|------|-------------|
+| G_MEM | B | 全局内存消耗 |
+| CATA_MEM | B | CATALOG内存消耗 |
+| TRAN_MEM | B | 事务内存消耗 |
+| NET_MEM | B | 用户连接用内存消耗 |
+| TASK_MEM | B | 任务线程消耗 |
+| MSG_MEM | B | 内部通讯消息内存消耗 |
+| LOCK_MEM | B | 局部锁内存消耗 |
+| GLOCK_MEM | B | 全局锁内存消耗 |
+| DLCHK_MEM | B | 死锁检测内存消耗 |
+| MODI_MEM | B | 变更日志内存消耗 |
+| PROC_MEM | B | 过程执行机内存消耗 |
+
+#### 指标集合:磁盘 信息
+
+| 指标名称 | 指标单位 | 指标帮助描述 |
+|------------------|------|-----------|
+| DISK_READ_NUM | 无 | 数据块磁盘读取次数 |
+| DISK_WRITE_NUM | 无 | 磁盘写入数据块次数 |
Review Comment:
Inconsistency between documentation and configuration: The documentation
shows "无" (N/A) for the unit of DISK_READ_NUM and DISK_WRITE_NUM, but the
configuration file (app-xugu.yml lines 273, 279) specifies "Times" as the unit.
These should be aligned. Either update the documentation to show the actual
unit or update the configuration to not specify a unit (which would display as
N/A).
```suggestion
| DISK_READ_NUM | 次 | 数据块磁盘读取次数 |
| DISK_WRITE_NUM | 次 | 磁盘写入数据块次数 |
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]