Explorar o código

[monitor] 支持PING监控类型

tomsun28 %!s(int64=4) %!d(string=hai) anos
pai
achega
987032f552

+ 6 - 0
common/src/main/java/com/usthe/common/entity/job/protocol/IcmpProtocol.java

@@ -15,9 +15,15 @@ import lombok.NoArgsConstructor;
 @AllArgsConstructor
 @NoArgsConstructor
 public class IcmpProtocol {
+
     /**
      * 对端主机ip或域名
      */
     private String host;
 
+    /**
+     * 超时时间
+     */
+    private String timeout;
+
 }

+ 1 - 1
manager/src/main/resources/define/app/A-example.yml

@@ -1,5 +1,5 @@
 # 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
-app: exapmle_type
+app: exapmle
 # 参数映射map. type是参数类型: 0-number数字, 1-string明文字符串, 2-secret加密字符串
 # 强制固定必须参数 - host
 configmap:

+ 28 - 0
manager/src/main/resources/define/app/ping.yml

@@ -0,0 +1,28 @@
+# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
+app: ping
+# 参数映射map. type是参数类型: 0-number数字, 1-string明文字符串, 2-secret加密字符串
+# 强制固定必须参数 - host
+configmap:
+  - key: host
+    type: 1
+  - key: timeout
+    type: 0
+metrics:
+  # 第一个监控指标组 cpu
+  # 注意:内置监控指标有 (responseTime - 响应时间)
+  - name: summary
+    # 指标组调度优先级(0-127)越小优先级越高,优先级低的指标组会等优先级高的指标组采集完成后才会被调度,相同优先级的指标组会并行调度采集
+    # 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度
+    priority: 0
+    # 指标组中的具体监控指标
+    fields:
+      # 指标信息 包括 field名称   type字段类型:0-number数字,1-string字符串   instance是否为实例主键   unit:指标单位
+      - field: responseTime
+        type: 0
+        unit: ms
+# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
+    protocol: icmp
+# 当protocol为ping协议时具体的采集配置
+    icmp:
+      host: ^_^host^_^
+      timeout: ^_^timeout^_^

+ 1 - 1
manager/src/main/resources/define/param/A-example.yml

@@ -1,5 +1,5 @@
 # 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
-app: exapmle_type
+app: exapmle
 # 强制固定必须参数 - host(ipv4,ipv6,域名)
 param:
     # field-字段名称标识符

+ 12 - 6
manager/src/main/resources/define/param/api.yml

@@ -24,10 +24,18 @@ param:
     required: true
   - field: method
     name: 请求方式
-    type: text
-    # 当type为text时,用limit表示字符串限制大小
-    limit: 20
+    type: radio
     required: true
+    # 当type为radio单选框,checkbox复选框时,option表示可选项值列表 {name1:value1,name2:value2}
+    options:
+      - label: GET请求
+        value: GET
+      - label: POST请求
+        value: POST
+      - label: PUT请求
+        value: PUT
+      - label: DELETE请求
+        value: DELETE
   - field: username
     name: 用户名
     type: text
@@ -40,8 +48,6 @@ param:
     required: false
   - field: ssl
     name: 使用SSL
+    # 当type为boolean时,前端用switch展示开关
     type: boolean
     required: true
-    # 当type为boolean时,前端用switch展示开关
-    # 当type为radio单选框,checkbox复选框时,option表示可选项值列表
-    # option: Yes,No

+ 20 - 0
manager/src/main/resources/define/param/ping.yml

@@ -0,0 +1,20 @@
+# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
+app: ping
+# 强制固定必须参数 - host(ipv4,ipv6,域名)
+param:
+    # field-字段名称标识符
+  - field: host
+    # name-参数字段显示名称
+    name: 主机Host
+    # type-字段类型,样式(大部分映射input标签type属性)
+    type: host
+    # 是否是必输项 true-必填 false-可选
+    required: true
+  - field: timeout
+    name: Ping超时时间
+    type: number
+    # 当type为number时,用range表示范围
+    range: '[0,100000]'
+    required: true
+    placeholder: '请输入超时时间,单位毫秒'
+    defaultValue: 3000

+ 2 - 2
web-app/src/assets/tmp/app-data.json

@@ -42,7 +42,7 @@
             {
               "text": "api",
               "link": "/monitors?app=api",
-              "i18n": "monitor.app.http"
+              "i18n": "monitor.app.api"
             },
             {
               "text": "ping",
@@ -51,7 +51,7 @@
             },
             {
               "text": "telnet",
-              "link": "/monitors",
+              "link": "/monitors?app=telnet",
               "i18n": "monitor.app.telnet"
             }
           ]