瀏覽代碼

[manager,webapp]bugfix#5 website monitor path Illegal character in path

[manager,webapp]bugfix website monitor path Illegal character in path
tomsun28 3 年之前
父節點
當前提交
ff8f99c567

+ 2 - 0
collector/src/main/java/com/usthe/collector/dispatch/timer/WheelTimerTask.java

@@ -55,6 +55,8 @@ public class WheelTimerTask implements TimerTask {
                             log.error("Aes Decode value {} error.", item.getValue());
                         }
                         item.setValue(decodeValue);
+                    } else if (item.getValue() != null && item.getValue() instanceof String) {
+                        item.setValue(((String) item.getValue()).trim());
                     }
                 })
                 .collect(Collectors.toMap(Configmap::getKey, item -> item));

+ 1 - 0
common/src/main/java/com/usthe/common/util/IpDomainUtil.java

@@ -33,6 +33,7 @@ public class IpDomainUtil {
         if (ipDomain == null || "".equals(ipDomain)) {
             return false;
         }
+        ipDomain = ipDomain.trim();
         if (LOCALHOST.equalsIgnoreCase(ipDomain)) {
             return true;
         }

+ 7 - 1
manager/src/main/java/com/usthe/manager/service/impl/MonitorServiceImpl.java

@@ -126,9 +126,15 @@ public class MonitorServiceImpl implements MonitorService {
     public void validate(MonitorDto monitorDto, Boolean isModify) throws IllegalArgumentException {
         // 请求监控参数与监控参数定义映射校验匹配
         Monitor monitor = monitorDto.getMonitor();
+        monitor.setHost(monitor.getHost().trim());
+        monitor.setName(monitor.getName().trim());
         Map<String, Param> paramMap = monitorDto.getParams()
                 .stream()
-                .peek(param -> param.setMonitorId(monitor.getId()))
+                .peek(param -> {
+                    param.setMonitorId(monitor.getId());
+                    String value = param.getValue() == null ? null : param.getValue().trim();
+                    param.setValue(value);
+                })
                 .collect(Collectors.toMap(Param::getField, param -> param));
         // 校验名称唯一性
         if (isModify != null) {

+ 10 - 0
web-app/src/app/routes/monitor/monitor-edit/monitor-edit.component.ts

@@ -112,11 +112,16 @@ export class MonitorEditComponent implements OnInit {
       });
       return;
     }
+    this.monitor.host = this.monitor.host.trim();
+    this.monitor.name = this.monitor.name.trim();
     // todo 暂时单独设置host属性值
     this.params.forEach(param => {
       if (param.field === 'host') {
         param.value = this.monitor.host;
       }
+      if (param.value != null && typeof param.value == 'string') {
+        param.value = (param.value as string).trim();
+      }
     });
     let addMonitor = {
       detected: this.detected,
@@ -151,11 +156,16 @@ export class MonitorEditComponent implements OnInit {
       });
       return;
     }
+    this.monitor.host = this.monitor.host.trim();
+    this.monitor.name = this.monitor.name.trim();
     // todo 暂时单独设置host属性值
     this.params.forEach(param => {
       if (param.field === 'host') {
         param.value = this.monitor.host;
       }
+      if (param.value != null && typeof param.value == 'string') {
+        param.value = (param.value as string).trim();
+      }
     });
     let detectMonitor = {
       detected: this.detected,

+ 10 - 0
web-app/src/app/routes/monitor/monitor-new/monitor-new.component.ts

@@ -93,11 +93,16 @@ export class MonitorNewComponent implements OnInit {
       });
       return;
     }
+    this.monitor.host = this.monitor.host.trim();
+    this.monitor.name = this.monitor.name.trim();
     // todo 暂时单独设置host属性值
     this.params.forEach(param => {
       if (param.field === 'host') {
         param.value = this.monitor.host;
       }
+      if (param.value != null && typeof param.value == 'string') {
+        param.value = (param.value as string).trim();
+      }
     });
     let addMonitor = {
       detected: this.detected,
@@ -132,11 +137,16 @@ export class MonitorNewComponent implements OnInit {
       });
       return;
     }
+    this.monitor.host = this.monitor.host.trim();
+    this.monitor.name = this.monitor.name.trim();
     // todo 暂时单独设置host属性值
     this.params.forEach(param => {
       if (param.field === 'host') {
         param.value = this.monitor.host;
       }
+      if (param.value != null && typeof param.value == 'string') {
+        param.value = (param.value as string).trim();
+      }
     });
     let detectMonitor = {
       detected: true,