starryCoder commented on code in PR #3857:
URL: https://github.com/apache/hertzbeat/pull/3857#discussion_r2538247629


##########
hertzbeat-manager/src/main/resources/define/app-db2.yml:
##########
@@ -0,0 +1,382 @@
+# 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
+# The monitoring type eg: linux windows tomcat mysql aws...
+app: db2
+# The monitoring i18n name
+name:
+  zh-CN: DB2数据库
+  en-US: DB2 DB
+  ja-JP: DB2 データベース
+# 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 对 DB2 数据库的通用性能指标(表空间、性能状态、用户连接、缓存、慢SQL等)进行采集监控。<br>您可以点击“<i>新建 DB2 
数据库</i>”并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
+  en-US: HertzBeat uses <a class='help_module_content' 
href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> JDBC 
Protocol</a> to configure SQL for collecting general metrics of DB2 database 
(tablespace、user connect、performance、slow SQL etc.). <br>You can click "<i>New 
DB2 Database</i>" and configure it, or select "<i>More Operations"</i> to 
import the existing configuration.
+  zh-TW: HertzBeat 使用 <a class='help_module_content' 
href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> JDBC 協議</a> 通過配置 
SQL 對 DB2 數據庫的通用性能指標(表空間、性能狀態、用戶連接、緩存、慢SQL等)進行采集監控。<br>您可以點擊“<i>新建 DB2 
數據庫</i>”並進行配置,或者選擇“<i>更多操作</i>”,導入已有配置。
+  ja-JP: Hertzbeat は <a class='help_module_content' 
href='https://hertzbeat.apache.org/docs/advanced/extend-jdbc'> 
JDBCプロトコルを介して</a> DB2 データベースの一般的なパフォーマンスのメトリクスを監視します。<br>「<i>新規 DB2 
データベース</i>」をクリックしてパラメタを設定した後、新規することができます。
+helpLink:
+  zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/db2/
+  en-US: https://hertzbeat.apache.org/docs/help/db2/
+# 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
+      ja-JP: 目標ホスト
+    # 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
+      ja-JP: ポート
+    # 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: 50000 # DB2 default port
+  - field: timeout
+    name:
+      zh-CN: 查询超时时间(ms)
+      en-US: Query Timeout(ms)
+      ja-JP: クエリタイムアウト(ms)
+    type: number
+    range: '[400,200000]'
+    required: false
+    hide: true
+    defaultValue: 6000
+  - field: reuseConnection
+    name:
+      zh-CN: 复用连接
+      en-US: Reuse Connection
+      ja-JP: 接続再利用
+    type: boolean
+    required: false
+    defaultValue: true
+  - field: database
+    name:
+      zh-CN: 数据库名
+      en-US: Database Name
+      ja-JP: データベース名
+    type: text
+    required: true # Database Name is typically mandatory for DB2 JDBC 
connection
+  - field: username
+    name:
+      zh-CN: 用户名
+      en-US: Username
+      ja-JP: ユーザー名
+    type: text
+    limit: 50
+    required: false
+  - field: password
+    name:
+      zh-CN: 密码
+      en-US: Password
+      ja-JP: パスワード
+    type: password
+    required: false
+  - field: url
+    name:
+      zh-CN: URL
+      en-US: URL
+      ja-JP: URL
+    type: text
+    required: false
+    hide: true
+
+# collect metrics config list
+metrics:
+  # metrics - basic
+  - name: basic
+    i18n:
+      zh-CN: 基本信息
+      en-US: Basic Info
+      ja-JP: 基礎情報
+    priority: 0
+    fields:
+      - field: database_version
+        type: 1
+        label: true
+        i18n:
+          zh-CN: 数据库版本
+          en-US: Database Version
+          ja-JP: データベースバージョン
+      - field: instance_name
+        type: 1
+        i18n:
+          zh-CN: 实例名
+          en-US: Instance Name
+          ja-JP: インスタンス名
+      - field: status
+        type: 1
+        i18n:
+          zh-CN: 实例状态
+          en-US: Instance Status
+          ja-JP: インスタンス的状态
+      - field: num_db
+        type: 0
+        i18n:
+          zh-CN: 数据库数量
+          en-US: Number of Databases
+          ja-JP: データベースの数
+    aliasFields:
+      - INSTANCE_NAME
+      - INSTANCE_STATUS
+      - NUM_DB
+      - CURRENT_USER
+    calculates:
+      - database_version=INSTANCE_NAME
+      - instance_name=INSTANCE_NAME
+      - status=INSTANCE_STATUS
+      - num_db=NUM_DB
+    protocol: jdbc
+    jdbc:
+      host: ^_^host^_^
+      port: ^_^port^_^
+      platform: db2
+      username: ^_^username^_^
+      password: ^_^password^_^
+      database: ^_^database^_^
+      timeout: ^_^timeout^_^
+      reuseConnection: ^_^reuseConnection^_^
+      queryType: oneRow
+      sql: "SELECT CURRENT SERVER AS INSTANCE_NAME, 'ACTIVE' AS 
INSTANCE_STATUS, 1 AS NUM_DB, CURRENT USER AS CURRENT_USER FROM 
SYSIBM.SYSDUMMY1"
+      url: ^_^url^_^
+
+  # Combined tablespace capacity and usage
+  - name: tablespace_usage
+    i18n:
+      zh-CN: 表空间使用率
+      en-US: Tablespace Usage
+      ja-JP: 表領域使用率
+    priority: 1
+    fields:
+      - field: tablespace_name
+        type: 1
+        i18n:
+          zh-CN: 表空间名
+          en-US: Tablespace Name
+          ja-JP: 表領域名
+        label: true
+      - field: status
+        type: 1
+        i18n:
+          zh-CN: 类型
+          en-US: Type
+          ja-JP: タイプ
+      - field: total
+        type: 0
+        i18n:
+          zh-CN: 总容量
+          en-US: Total Size
+          ja-JP: 総容量
+        unit: MB
+      - field: used
+        type: 0
+        i18n:
+          zh-CN: 已使用
+          en-US: Used Size
+          ja-JP: 使用済み
+        unit: MB
+      - field: free
+        type: 0
+        i18n:
+          zh-CN: 空闲
+          en-US: Free Size
+          ja-JP: 利用可能
+        unit: MB
+      - field: used_percentage
+        type: 0
+        i18n:
+          zh-CN: 已用百分比
+          en-US: Used Percentage
+          ja-JP: 使用した比率
+        unit: '%'
+    aliasFields:
+      - TBSP_NAME
+      - TBSP_TYPE
+      - TBSP_TOTAL_SIZE_KB
+      - TBSP_USED_SIZE_KB
+      - TBSP_FREE_SIZE_KB
+    calculates:
+      - tablespace_name=TBSP_NAME
+      - status=TBSP_TYPE
+      - total=TBSP_TOTAL_SIZE_KB / 1024
+      - used=TBSP_USED_SIZE_KB / 1024
+      - free=TBSP_FREE_SIZE_KB / 1024
+      - used_percentage=TBSP_USED_SIZE_KB / TBSP_TOTAL_SIZE_KB * 100
+    protocol: jdbc
+    jdbc:
+      host: ^_^host^_^
+      port: ^_^port^_^
+      platform: db2
+      username: ^_^username^_^
+      password: ^_^password^_^
+      database: ^_^database^_^
+      timeout: ^_^timeout^_^
+      reuseConnection: ^_^reuseConnection^_^
+      queryType: multiRow
+      sql: "SELECT TBSP_NAME, TBSP_TYPE, TBSP_TOTAL_SIZE_KB, 
TBSP_USED_SIZE_KB, TBSP_FREE_SIZE_KB FROM SYSIBMADM.TBSP_UTILIZATION"
+      url: ^_^url^_^
+
+  # Sessions/Applications status distribution
+  - name: sessions_status
+    i18n:
+      zh-CN: 会话状态
+      en-US: Session Status
+      ja-JP: セッション状態
+    priority: 2
+    fields:
+      - field: status_type
+        type: 1
+        i18n:
+          zh-CN: 状态类型
+          en-US: Status Type
+          ja-JP: 状態タイプ
+        label: true
+      - field: count
+        type: 0
+        i18n:
+          zh-CN: 数量
+          en-US: Count
+          ja-JP: 数
+    protocol: jdbc
+    jdbc:
+      host: ^_^host^_^
+      port: ^_^port^_^
+      platform: db2
+      username: ^_^username^_^
+      password: ^_^password^_^
+      database: ^_^database^_^
+      timeout: ^_^timeout^_^
+      reuseConnection: ^_^reuseConnection^_^
+      queryType: multiRow
+      sql: "SELECT APPL_STATUS AS STATUS_TYPE, COUNT(*) AS COUNT FROM 
SYSIBMADM.APPLICATIONS GROUP BY APPL_STATUS"
+      url: ^_^url^_^
+
+
+  # Total number of applications/sessions
+  - name: process
+    i18n:
+      zh-CN: 应用进程数
+      en-US: Application Process Count
+      ja-JP: アプリケーションプロセス数
+    priority: 5
+    fields:
+      - field: process_count
+        type: 0
+        i18n:
+          zh-CN: 进程数
+          en-US: Process Count
+          ja-JP: プロセス数
+    protocol: jdbc
+    jdbc:
+      host: ^_^host^_^
+      port: ^_^port^_^
+      platform: db2
+      username: ^_^username^_^
+      password: ^_^password^_^
+      database: ^_^database^_^
+      timeout: ^_^timeout^_^
+      reuseConnection: ^_^reuseConnection^_^
+      queryType: oneRow
+      # Count of all running applications
+      sql: "select count(*) as process_count from SYSIBMADM.APPLICATIONS"
+      url: ^_^url^_^
+
+  - name: locks
+    i18n:
+      zh-CN: 锁
+      en-US: Locks
+      ja-JP: ロック
+    priority: 10
+    fields:
+      - field: waiting_locks
+        type: 0
+        i18n:
+          zh-CN: 当前等待锁数
+          en-US: Current Waiting Locks
+          ja-JP: 現在の待機中ロック数
+    aliasFields:
+      - WAITING_LOCKS
+    calculates:
+      - waiting_locks=WAITING_LOCKS
+    protocol: jdbc
+    jdbc:
+      host: ^_^host^_^
+      port: ^_^port^_^
+      platform: db2
+      username: ^_^username^_^
+      password: ^_^password^_^
+      database: ^_^database^_^
+      timeout: ^_^timeout^_^
+      reuseConnection: ^_^reuseConnection^_^
+      queryType: oneRow
+      sql: "SELECT COUNT(*) AS WAITING_LOCKS FROM SYSIBMADM.MON_LOCKWAITS"
+      url: ^_^url^_^
+
+  # Slow Query / Top Statements (by Total CPU Time)
+  - name: slow_query
+    i18n:
+      zh-CN: 慢查询
+      en-US: Slow Query
+      ja-JP: スロークエリ
+    priority: 14
+    fields:
+      - field: avg_exe_time
+        type: 0
+        i18n:
+          zh-CN: 平均执行时间
+          en-US: Avg Execution Time
+          ja-JP: 平均実行時間
+        unit: ms
+      # 替换为新的指标字段:SQL文本

Review Comment:
   I've removed unnecessary comments from the code.



-- 
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]

Reply via email to