diff --git a/collector/src/main/java/org/dromara/hertzbeat/collector/collect/common/cache/CommonCache.java b/collector/src/main/java/org/dromara/hertzbeat/collector/collect/common/cache/CommonCache.java index 35c5557ea62..dd7334b9820 100644 --- a/collector/src/main/java/org/dromara/hertzbeat/collector/collect/common/cache/CommonCache.java +++ b/collector/src/main/java/org/dromara/hertzbeat/collector/collect/common/cache/CommonCache.java @@ -159,6 +159,7 @@ private void cleanTimeoutCache() { * @param timeDiff 缓存对象保存时间 millis */ public void addCache(Object key, Object value, Long timeDiff) { + removeCache(key); if (timeDiff == null) { timeDiff = DEFAULT_CACHE_TIMEOUT; } diff --git a/collector/src/main/java/org/dromara/hertzbeat/collector/collect/common/ssh/CommonSshClient.java b/collector/src/main/java/org/dromara/hertzbeat/collector/collect/common/ssh/CommonSshClient.java index b9223ec9933..f06ec8701c8 100644 --- a/collector/src/main/java/org/dromara/hertzbeat/collector/collect/common/ssh/CommonSshClient.java +++ b/collector/src/main/java/org/dromara/hertzbeat/collector/collect/common/ssh/CommonSshClient.java @@ -14,23 +14,25 @@ @Slf4j public class CommonSshClient { - private static SshClient sshClient; + private static final SshClient SSH_CLIENT; static { - sshClient = SshClient.setUpDefaultClient(); + SSH_CLIENT = SshClient.setUpDefaultClient(); // 接受所有服务端公钥校验,会打印warn日志 Server at {} presented unverified {} key: {} AcceptAllServerKeyVerifier verifier = AcceptAllServerKeyVerifier.INSTANCE; - sshClient.setServerKeyVerifier(verifier); - // 设置链接保活心跳2000毫秒一次, 客户端等待保活心跳响应超时时间300_0000毫秒 + SSH_CLIENT.setServerKeyVerifier(verifier); + // 设置链接保活心跳2000毫秒一次, 客户端等待保活心跳响应超时时间300_000毫秒 PropertyResolverUtils.updateProperty( - sshClient, CoreModuleProperties.HEARTBEAT_INTERVAL.getName(), 2000); + SSH_CLIENT, CoreModuleProperties.HEARTBEAT_INTERVAL.getName(), 2000); PropertyResolverUtils.updateProperty( - sshClient, CoreModuleProperties.HEARTBEAT_REPLY_WAIT.getName(), 300_000); - sshClient.start(); + SSH_CLIENT, CoreModuleProperties.HEARTBEAT_REPLY_WAIT.getName(), 300_000); + PropertyResolverUtils.updateProperty( + SSH_CLIENT, CoreModuleProperties.SOCKET_KEEPALIVE.getName(), true); + SSH_CLIENT.start(); } public static SshClient getSshClient() { - return sshClient; + return SSH_CLIENT; } } diff --git a/collector/src/main/java/org/dromara/hertzbeat/collector/collect/mongodb/MongodbSingleCollectImpl.java b/collector/src/main/java/org/dromara/hertzbeat/collector/collect/mongodb/MongodbSingleCollectImpl.java index 487e3607865..cd4d5436a85 100644 --- a/collector/src/main/java/org/dromara/hertzbeat/collector/collect/mongodb/MongodbSingleCollectImpl.java +++ b/collector/src/main/java/org/dromara/hertzbeat/collector/collect/mongodb/MongodbSingleCollectImpl.java @@ -17,8 +17,8 @@ package org.dromara.hertzbeat.collector.collect.mongodb; -import java.io.UnsupportedEncodingException; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Optional; @@ -47,20 +47,18 @@ * Mongodb 单机指标收集器 * * @author liudonghua - * @version 1.0 - * Created by liudonghua on 2023/01/01 - * see also https://www.mongodb.com/languages/java, - * https://www.mongodb.com/docs/manual/reference/command/serverStatus/#metrics + * see also https://www.mongodb.com/languages/java, + * https://www.mongodb.com/docs/manual/reference/command/serverStatus/#metrics */ @Slf4j public class MongodbSingleCollectImpl extends AbstractCollect { /** * 支持的 mongodb diagnostic 命令,排除internal/deprecated相关的命令 - * 可参考 https://www.mongodb.com/docs/manual/reference/command/nav-diagnostic/, - * https://www.mongodb.com/docs/mongodb-shell/run-commands/ + * 可参考 ..., + * ... * 注意:一些命令需要相应的权限才能执行,否则执行虽然不会报错,但是返回的结果是空的, - * 详见 https://www.mongodb.com/docs/manual/reference/built-in-roles/ + * 详见 ... */ private static final String[] SUPPORTED_MONGODB_DIAGNOSTIC_COMMANDS = { "buildInfo", @@ -199,14 +197,10 @@ private MongoClient getClient(Metrics metrics) { } // 复用失败则新建连接 connect to mongodb String url; - try { - // 密码可能包含特殊字符,需要使用类似js的encodeURIComponent进行编码,这里使用java的URLEncoder - url = String.format("mongodb://%s:%s@%s:%s/%s?authSource=%s", mongodbProtocol.getUsername(), - URLEncoder.encode(mongodbProtocol.getPassword(), "UTF-8"), mongodbProtocol.getHost(), mongodbProtocol.getPort(), - mongodbProtocol.getDatabase(), mongodbProtocol.getAuthenticationDatabase()); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } + // 密码可能包含特殊字符,需要使用类似js的encodeURIComponent进行编码,这里使用java的URLEncoder + url = String.format("mongodb://%s:%s@%s:%s/%s?authSource=%s", mongodbProtocol.getUsername(), + URLEncoder.encode(mongodbProtocol.getPassword(), StandardCharsets.UTF_8), mongodbProtocol.getHost(), mongodbProtocol.getPort(), + mongodbProtocol.getDatabase(), mongodbProtocol.getAuthenticationDatabase()); mongoClient = MongoClients.create(url); MongodbConnect mongodbConnect = new MongodbConnect(mongoClient); CommonCache.getInstance().addCache(identifier, mongodbConnect); diff --git a/collector/src/main/java/org/dromara/hertzbeat/collector/collect/ssh/SshCollectImpl.java b/collector/src/main/java/org/dromara/hertzbeat/collector/collect/ssh/SshCollectImpl.java index 3bc3027a432..04f8d7673e8 100644 --- a/collector/src/main/java/org/dromara/hertzbeat/collector/collect/ssh/SshCollectImpl.java +++ b/collector/src/main/java/org/dromara/hertzbeat/collector/collect/ssh/SshCollectImpl.java @@ -17,6 +17,9 @@ package org.dromara.hertzbeat.collector.collect.ssh; +import org.apache.sshd.common.SshException; +import org.apache.sshd.common.channel.exception.SshChannelOpenException; +import org.apache.sshd.common.util.io.output.NoCloseOutputStream; import org.apache.sshd.common.util.security.SecurityUtils; import org.dromara.hertzbeat.collector.collect.AbstractCollect; import org.dromara.hertzbeat.collector.collect.common.cache.CacheIdentifier; @@ -43,9 +46,11 @@ import java.io.FileInputStream; import java.io.IOException; import java.net.ConnectException; +import java.net.SocketTimeoutException; import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -83,24 +88,24 @@ public void collect(CollectRep.MetricsData.Builder builder, long appId, String a return; } SshProtocol sshProtocol = metrics.getSsh(); + boolean reuseConnection = Boolean.parseBoolean(sshProtocol.getReuseConnection()); int timeout = CollectUtil.getTimeout(sshProtocol.getTimeout(), DEFAULT_TIMEOUT); ClientChannel channel = null; + ClientSession clientSession = null; try { - ClientSession clientSession = getConnectSession(sshProtocol, timeout); + clientSession = getConnectSession(sshProtocol, timeout, reuseConnection); channel = clientSession.createExecChannel(sshProtocol.getScript()); ByteArrayOutputStream response = new ByteArrayOutputStream(); channel.setOut(response); - if (!channel.open().verify(timeout).isOpened()) { - removeConnectSessionCache(sshProtocol); - channel.close(); - clientSession.close(); - throw new Exception("ssh channel open failed"); - } + channel.setErr(new NoCloseOutputStream(System.err)); + channel.open().verify(timeout); List list = new ArrayList<>(); list.add(ClientChannelEvent.CLOSED); - channel.waitFor(list, timeout); + Collection waitEvents = channel.waitFor(list, timeout); + if (waitEvents.contains(ClientChannelEvent.TIMEOUT)) { + throw new SocketTimeoutException("Failed to retrieve command result in time: " + sshProtocol.getScript()); + } Long responseTime = System.currentTimeMillis() - startTime; - channel.close(); String result = response.toString(); if (!StringUtils.hasText(result)) { builder.setCode(CollectRep.Code.FAIL); @@ -126,11 +131,19 @@ public void collect(CollectRep.MetricsData.Builder builder, long appId, String a log.info(errorMsg); builder.setCode(CollectRep.Code.UN_CONNECTABLE); builder.setMsg("The peer refused to connect: service port does not listening or firewall: " + errorMsg); + } catch (SshException sshException) { + Throwable throwable = sshException.getCause(); + if (throwable instanceof SshChannelOpenException) { + log.warn("Remote ssh server no more session channel, please increase sshd_config MaxSessions."); + } + String errorMsg = CommonUtil.getMessageFromThrowable(sshException); + builder.setCode(CollectRep.Code.UN_CONNECTABLE); + builder.setMsg("Peer ssh connection failed: " + errorMsg); } catch (IOException ioException) { String errorMsg = CommonUtil.getMessageFromThrowable(ioException); log.info(errorMsg); builder.setCode(CollectRep.Code.UN_CONNECTABLE); - builder.setMsg("Peer connection failed: " + errorMsg); + builder.setMsg("Peer io connection failed: " + errorMsg); } catch (Exception exception) { String errorMsg = CommonUtil.getMessageFromThrowable(exception); log.warn(errorMsg, exception); @@ -144,6 +157,13 @@ public void collect(CollectRep.MetricsData.Builder builder, long appId, String a log.error(e.getMessage(), e); } } + if (clientSession != null && !reuseConnection) { + try { + clientSession.close(); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } } } @@ -247,28 +267,31 @@ private void removeConnectSessionCache(SshProtocol sshProtocol) { CommonCache.getInstance().removeCache(identifier); } - private ClientSession getConnectSession(SshProtocol sshProtocol, int timeout) throws IOException, GeneralSecurityException { + private ClientSession getConnectSession(SshProtocol sshProtocol, int timeout, boolean reuseConnection) + throws IOException, GeneralSecurityException { CacheIdentifier identifier = CacheIdentifier.builder() - .ip(sshProtocol.getHost()).port(sshProtocol.getPort()) - .username(sshProtocol.getUsername()).password(sshProtocol.getPassword()) - .build(); - Optional cacheOption = CommonCache.getInstance().getCache(identifier, true); + .ip(sshProtocol.getHost()).port(sshProtocol.getPort()) + .username(sshProtocol.getUsername()).password(sshProtocol.getPassword()) + .build(); ClientSession clientSession = null; - if (cacheOption.isPresent()) { - clientSession = ((SshConnect) cacheOption.get()).getConnection(); - try { - if (clientSession == null || clientSession.isClosed() || clientSession.isClosing()) { + if (reuseConnection) { + Optional cacheOption = CommonCache.getInstance().getCache(identifier, true); + if (cacheOption.isPresent()) { + clientSession = ((SshConnect) cacheOption.get()).getConnection(); + try { + if (clientSession == null || clientSession.isClosed() || clientSession.isClosing()) { + clientSession = null; + CommonCache.getInstance().removeCache(identifier); + } + } catch (Exception e) { + log.warn(e.getMessage()); clientSession = null; CommonCache.getInstance().removeCache(identifier); } - } catch (Exception e) { - log.warn(e.getMessage()); - clientSession = null; - CommonCache.getInstance().removeCache(identifier); } - } - if (clientSession != null) { - return clientSession; + if (clientSession != null) { + return clientSession; + } } SshClient sshClient = CommonSshClient.getSshClient(); clientSession = sshClient.connect(sshProtocol.getUsername(), sshProtocol.getHost(), Integer.parseInt(sshProtocol.getPort())) @@ -286,8 +309,10 @@ private ClientSession getConnectSession(SshProtocol sshProtocol, int timeout) th clientSession.close(); throw new IllegalArgumentException("ssh auth failed."); } - SshConnect sshConnect = new SshConnect(clientSession); - CommonCache.getInstance().addCache(identifier, sshConnect); + if (reuseConnection) { + SshConnect sshConnect = new SshConnect(clientSession); + CommonCache.getInstance().addCache(identifier, sshConnect); + } return clientSession; } diff --git a/collector/src/main/java/org/dromara/hertzbeat/collector/collect/strategy/CollectStrategyFactory.java b/collector/src/main/java/org/dromara/hertzbeat/collector/collect/strategy/CollectStrategyFactory.java index 301e7a95443..cca99136753 100644 --- a/collector/src/main/java/org/dromara/hertzbeat/collector/collect/strategy/CollectStrategyFactory.java +++ b/collector/src/main/java/org/dromara/hertzbeat/collector/collect/strategy/CollectStrategyFactory.java @@ -3,6 +3,8 @@ import org.dromara.hertzbeat.collector.collect.AbstractCollect; import org.springframework.boot.CommandLineRunner; import org.springframework.context.annotation.Configuration; +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; import java.util.ServiceLoader; import java.util.concurrent.ConcurrentHashMap; @@ -14,6 +16,7 @@ * */ @Configuration +@Order(value = Ordered.HIGHEST_PRECEDENCE) public class CollectStrategyFactory implements CommandLineRunner { /** diff --git a/common/src/main/java/org/dromara/hertzbeat/common/entity/job/protocol/SshProtocol.java b/common/src/main/java/org/dromara/hertzbeat/common/entity/job/protocol/SshProtocol.java index b6424b1a5ff..1271f6a7cb6 100644 --- a/common/src/main/java/org/dromara/hertzbeat/common/entity/job/protocol/SshProtocol.java +++ b/common/src/main/java/org/dromara/hertzbeat/common/entity/job/protocol/SshProtocol.java @@ -63,6 +63,11 @@ public class SshProtocol { * 私钥(可选) */ private String privateKey; + + /** + * reuse connection session + */ + private String reuseConnection = "true"; /** * SSH执行脚本 diff --git a/manager/src/main/java/org/dromara/hertzbeat/manager/service/JobSchedulerInit.java b/manager/src/main/java/org/dromara/hertzbeat/manager/service/JobSchedulerInit.java index 5c7dcb31f94..cb3d5703ef8 100644 --- a/manager/src/main/java/org/dromara/hertzbeat/manager/service/JobSchedulerInit.java +++ b/manager/src/main/java/org/dromara/hertzbeat/manager/service/JobSchedulerInit.java @@ -22,6 +22,7 @@ import org.dromara.hertzbeat.common.entity.job.Job; import org.dromara.hertzbeat.common.entity.manager.Monitor; import org.dromara.hertzbeat.common.entity.manager.Param; +import org.dromara.hertzbeat.common.entity.manager.ParamDefine; import org.dromara.hertzbeat.common.util.JsonUtil; import org.dromara.hertzbeat.manager.dao.MonitorDao; import org.dromara.hertzbeat.manager.dao.ParamDao; @@ -30,6 +31,7 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; import java.util.Arrays; import java.util.List; @@ -65,8 +67,6 @@ public void run(String... args) throws Exception { try { // 构造采集任务Job实体 Job appDefine = appService.getAppDefine(monitor.getApp()); - // todo 这里暂时是深拷贝处理 - appDefine = JsonUtil.fromJson(JsonUtil.toJson(appDefine), Job.class); appDefine.setId(monitor.getJobId()); appDefine.setMonitorId(monitor.getId()); appDefine.setInterval(monitor.getIntervals()); @@ -75,6 +75,16 @@ public void run(String... args) throws Exception { List params = paramDao.findParamsByMonitorId(monitor.getId()); List configmaps = params.stream().map(param -> new Configmap(param.getField(), param.getValue(), param.getType())).collect(Collectors.toList()); + List paramDefaultValue = appDefine.getParams().stream() + .filter(item -> StringUtils.hasText(item.getDefaultValue())) + .collect(Collectors.toList()); + paramDefaultValue.forEach(defaultVar -> { + if (configmaps.stream().noneMatch(item -> item.getKey().equals(defaultVar.getField()))) { + // todo type + Configmap configmap = new Configmap(defaultVar.getField(), defaultVar.getDefaultValue(), (byte) 1); + configmaps.add(configmap); + } + }); appDefine.setConfigmap(configmaps); // 下发采集任务 long jobId = collectJobService.addAsyncCollectJob(appDefine); diff --git a/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/MonitorServiceImpl.java b/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/MonitorServiceImpl.java index 435b33afeba..20ced6df925 100644 --- a/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/MonitorServiceImpl.java +++ b/manager/src/main/java/org/dromara/hertzbeat/manager/service/impl/MonitorServiceImpl.java @@ -593,6 +593,16 @@ public void enableManageMonitors(HashSet ids) { List params = paramDao.findParamsByMonitorId(monitor.getId()); List configmaps = params.stream().map(param -> new Configmap(param.getField(), param.getValue(), param.getType())).collect(Collectors.toList()); + List paramDefaultValue = appDefine.getParams().stream() + .filter(item -> StringUtils.hasText(item.getDefaultValue())) + .collect(Collectors.toList()); + paramDefaultValue.forEach(defaultVar -> { + if (configmaps.stream().noneMatch(item -> item.getKey().equals(defaultVar.getField()))) { + // todo type + Configmap configmap = new Configmap(defaultVar.getField(), defaultVar.getDefaultValue(), (byte) 1); + configmaps.add(configmap); + } + }); appDefine.setConfigmap(configmaps); // Issue collection tasks 下发采集任务 long newJobId = collectJobService.addAsyncCollectJob(appDefine); diff --git a/manager/src/main/resources/define/app-almalinux.yml b/manager/src/main/resources/define/app-almalinux.yml index 2e7e6469310..cef4ff6bdfe 100644 --- a/manager/src/main/resources/define/app-almalinux.yml +++ b/manager/src/main/resources/define/app-almalinux.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}' # ssh response data parse type: oneRow, multiRow @@ -217,6 +233,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "LANG=C lscpu | awk -F: '/Model name/ {print $2}' | awk 'NR==1';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -262,6 +279,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: free -m | awk 'BEGIN{print "total used free buff_cache available"} NR==2{print $2,$3,$4,$6,$7}' parseType: multiRow @@ -290,6 +308,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: vmstat -D | awk 'NR==1{print $1}';vmstat -D | awk 'NR==2{print $1}';vmstat 1 1 | awk 'NR==3{print $10}';vmstat 1 1 | awk 'NR==3{print $9}';vmstat 1 1 | awk 'NR==3{print $16}' parseType: oneRow @@ -313,6 +332,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}' parseType: multiRow @@ -341,6 +361,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -366,6 +387,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -391,5 +413,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/main/resources/define/app-centos.yml b/manager/src/main/resources/define/app-centos.yml index a0b1fc6657e..73a614eab0b 100644 --- a/manager/src/main/resources/define/app-centos.yml +++ b/manager/src/main/resources/define/app-centos.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}' # ssh response data parse type: oneRow, multiRow @@ -217,6 +233,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "LANG=C lscpu | awk -F: '/Model name/ {print $2}' | awk 'NR==1';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -262,6 +279,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: free -m | awk 'BEGIN{print "total used free buff_cache available"} NR==2{print $2,$3,$4,$6,$7}' parseType: multiRow @@ -290,6 +308,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: vmstat -D | awk 'NR==1{print $1}';vmstat -D | awk 'NR==2{print $1}';vmstat 1 1 | awk 'NR==3{print $10}';vmstat 1 1 | awk 'NR==3{print $9}';vmstat 1 1 | awk 'NR==3{print $16}' parseType: oneRow @@ -313,6 +332,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}' parseType: multiRow @@ -341,6 +361,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -366,6 +387,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -391,5 +413,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/main/resources/define/app-coreos.yml b/manager/src/main/resources/define/app-coreos.yml index 75002545542..c1d45f7d8b9 100644 --- a/manager/src/main/resources/define/app-coreos.yml +++ b/manager/src/main/resources/define/app-coreos.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}' # ssh response data parse type: oneRow, multiRow @@ -217,6 +233,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "LANG=C lscpu | awk -F: '/Model name/ {print $2}' | awk 'NR==1';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -262,6 +279,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: free -m | awk 'BEGIN{print "total used free buff_cache available"} NR==2{print $2,$3,$4,$6,$7}' parseType: multiRow @@ -290,6 +308,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: vmstat -D | awk 'NR==1{print $1}';vmstat -D | awk 'NR==2{print $1}';vmstat 1 1 | awk 'NR==3{print $10}';vmstat 1 1 | awk 'NR==3{print $9}';vmstat 1 1 | awk 'NR==3{print $16}' parseType: oneRow @@ -313,6 +332,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}' parseType: multiRow @@ -341,6 +361,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -366,6 +387,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -391,5 +413,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/main/resources/define/app-debian.yml b/manager/src/main/resources/define/app-debian.yml index d823c4354c8..11bc515da95 100644 --- a/manager/src/main/resources/define/app-debian.yml +++ b/manager/src/main/resources/define/app-debian.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}' # ssh response data parse type: oneRow, multiRow @@ -217,6 +233,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "LANG=C lscpu | awk -F: '$1==\"Model name\" {print $2}';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -262,6 +279,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: free -m | awk 'BEGIN{print "total used free buff_cache available"} NR==2{print $2,$3,$4,$6,$7}' parseType: multiRow @@ -290,6 +308,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: vmstat -D | awk 'NR==1{print $1}';vmstat -D | awk 'NR==2{print $1}';vmstat 1 1 | awk 'NR==3{print $10}';vmstat 1 1 | awk 'NR==3{print $9}';vmstat 1 1 | awk 'NR==3{print $16}' parseType: oneRow @@ -313,6 +332,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}' parseType: multiRow @@ -341,6 +361,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -366,6 +387,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -391,5 +413,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/main/resources/define/app-euleros.yml b/manager/src/main/resources/define/app-euleros.yml index 61d9a9c00d0..db5d4f92a01 100644 --- a/manager/src/main/resources/define/app-euleros.yml +++ b/manager/src/main/resources/define/app-euleros.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}' # ssh response data parse type: oneRow, multiRow @@ -217,6 +233,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "LANG=C lscpu | awk -F: '$1==\"Model name\" {print $2}';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -262,6 +279,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: free -m | awk 'BEGIN{print "total used free buff_cache available"} NR==2{print $2,$3,$4,$6,$7}' parseType: multiRow @@ -290,6 +308,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: vmstat -D | awk 'NR==1{print $1}';vmstat -D | awk 'NR==2{print $1}';vmstat 1 1 | awk 'NR==3{print $10}';vmstat 1 1 | awk 'NR==3{print $9}';vmstat 1 1 | awk 'NR==3{print $16}' parseType: oneRow @@ -313,6 +332,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}' parseType: multiRow @@ -341,6 +361,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -366,6 +387,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -391,5 +413,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/main/resources/define/app-freebsd.yml b/manager/src/main/resources/define/app-freebsd.yml index 10d288c6699..fdc9cf53cf1 100644 --- a/manager/src/main/resources/define/app-freebsd.yml +++ b/manager/src/main/resources/define/app-freebsd.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g" # ssh response data parse type: oneRow, multiRow @@ -217,6 +233,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "dmesg | grep -i cpu | awk 'NR==1';sysctl hw.ncpu | awk '{print $2}';uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -262,6 +279,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: sysctl hw | egrep 'hw.(phys|user|real)' | awk '{print $2}';dmesg | grep memory | grep avail | awk '{print $4}'; parseType: oneRow @@ -290,6 +308,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -315,6 +334,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -340,5 +360,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/main/resources/define/app-linux.yml b/manager/src/main/resources/define/app-linux.yml index 94c41d41a7f..a5dd06ce2b4 100644 --- a/manager/src/main/resources/define/app-linux.yml +++ b/manager/src/main/resources/define/app-linux.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}' # ssh response data parse type: oneRow, multiRow @@ -217,6 +233,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "LANG=C lscpu | awk -F: '$1==\"Model name\" {print $2}';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -262,6 +279,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: free -m | awk 'BEGIN{print "total used free buff_cache available"} NR==2{print $2,$3,$4,$6,$7}' parseType: multiRow @@ -290,6 +308,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: vmstat -D | awk 'NR==1{print $1}';vmstat -D | awk 'NR==2{print $1}';vmstat 1 1 | awk 'NR==3{print $10}';vmstat 1 1 | awk 'NR==3{print $9}';vmstat 1 1 | awk 'NR==3{print $16}' parseType: oneRow @@ -313,6 +332,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}' parseType: multiRow @@ -341,6 +361,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -mP | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -366,6 +387,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -391,5 +413,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/main/resources/define/app-opensuse.yml b/manager/src/main/resources/define/app-opensuse.yml index aceeeae4b95..55326942e6a 100644 --- a/manager/src/main/resources/define/app-opensuse.yml +++ b/manager/src/main/resources/define/app-opensuse.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}' # ssh response data parse type: oneRow, multiRow @@ -217,6 +233,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "LANG=C lscpu | awk -F: '$1==\"Model name\" {print $2}';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -262,6 +279,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: free -m | awk 'BEGIN{print "total used free buff_cache available"} NR==2{print $2,$3,$4,$6,$7}' parseType: multiRow @@ -290,6 +308,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: vmstat -D | awk 'NR==1{print $1}';vmstat -D | awk 'NR==2{print $1}';vmstat 1 1 | awk 'NR==3{print $10}';vmstat 1 1 | awk 'NR==3{print $9}';vmstat 1 1 | awk 'NR==3{print $16}' parseType: oneRow @@ -313,6 +332,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}' parseType: multiRow @@ -341,6 +361,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -366,6 +387,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -391,5 +413,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/main/resources/define/app-oracle.yml b/manager/src/main/resources/define/app-oracle.yml index 2ef38d8f8f2..c39c9a9ff28 100644 --- a/manager/src/main/resources/define/app-oracle.yml +++ b/manager/src/main/resources/define/app-oracle.yml @@ -313,11 +313,11 @@ metrics: type: 1 instance: true - field: total - type: 1 + type: 0 - field: used - type: 1 + type: 0 - field: free - type: 1 + type: 0 - field: used_percentage type: 0 unit: '%' diff --git a/manager/src/main/resources/define/app-redhat.yml b/manager/src/main/resources/define/app-redhat.yml index 1b9b87b5373..5c68b92e753 100644 --- a/manager/src/main/resources/define/app-redhat.yml +++ b/manager/src/main/resources/define/app-redhat.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}' # ssh response data parse type: oneRow, multiRow @@ -217,6 +233,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "LANG=C lscpu | awk -F: '$1==\"Model name\" {print $2}';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -262,6 +279,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: free -m | awk 'BEGIN{print "total used free buff_cache available"} NR==2{print $2,$3,$4,$6,$7}' parseType: multiRow @@ -290,6 +308,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: vmstat -D | awk 'NR==1{print $1}';vmstat -D | awk 'NR==2{print $1}';vmstat 1 1 | awk 'NR==3{print $10}';vmstat 1 1 | awk 'NR==3{print $9}';vmstat 1 1 | awk 'NR==3{print $16}' parseType: oneRow @@ -313,6 +332,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}' parseType: multiRow @@ -341,6 +361,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -366,6 +387,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -391,5 +413,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/main/resources/define/app-rockylinux.yml b/manager/src/main/resources/define/app-rockylinux.yml index 38ac8792516..47e5654df05 100644 --- a/manager/src/main/resources/define/app-rockylinux.yml +++ b/manager/src/main/resources/define/app-rockylinux.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}' # ssh response data parse type: oneRow, multiRow @@ -217,6 +233,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "LANG=C lscpu | awk -F: '/Model name/ {print $2}' | awk 'NR==1';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -262,6 +279,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: free -m | awk 'BEGIN{print "total used free buff_cache available"} NR==2{print $2,$3,$4,$6,$7}' parseType: multiRow @@ -290,6 +308,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: vmstat -D | awk 'NR==1{print $1}';vmstat -D | awk 'NR==2{print $1}';vmstat 1 1 | awk 'NR==3{print $10}';vmstat 1 1 | awk 'NR==3{print $9}';vmstat 1 1 | awk 'NR==3{print $16}' parseType: oneRow @@ -313,6 +332,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}' parseType: multiRow @@ -341,6 +361,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -366,6 +387,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -391,5 +413,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/main/resources/define/app-ubuntu.yml b/manager/src/main/resources/define/app-ubuntu.yml index 735d664343d..e6f48320ea7 100644 --- a/manager/src/main/resources/define/app-ubuntu.yml +++ b/manager/src/main/resources/define/app-ubuntu.yml @@ -83,6 +83,21 @@ params: defaultValue: 6000 # field-param field key # field-变量字段标识符 + - field: reuseConnection + # name-param field display i18n name + # name-参数字段显示名称 + name: + zh-CN: 复用连接 + en-US: Reuse Connection + # type-param field type(most mapping the html input type) + # type-字段类型,样式(大部分映射input标签type属性) + type: boolean + # required-true or false + # required-是否是必输项 true-必填 false-可选 + required: true + defaultValue: true + # field-param field key + # field-变量字段标识符 - field: username # name-param field display i18n name # name-参数字段显示名称 @@ -169,6 +184,7 @@ metrics: # ssh private key privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ # ssh run collect script script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}' # ssh response data parse type: oneRow, multiRow @@ -220,6 +236,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: "LANG=C lscpu | awk -F: '/Model name/ {print $2}';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}';vmstat 1 2 | awk 'NR==4{print $15}'" parseType: oneRow @@ -265,6 +282,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: free -m | awk 'BEGIN{print "total used free buff_cache available"} NR==2{print $2,$3,$4,$6,$7}' parseType: multiRow @@ -294,6 +312,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: vmstat -D | awk 'NR==1{print $1}';vmstat -D | awk 'NR==2{print $1}';vmstat 1 1 | awk 'NR==3{print $10}';vmstat 1 1 | awk 'NR==3{print $9}';vmstat 1 1 | awk 'NR==3{print $16}' parseType: oneRow @@ -317,6 +336,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}' parseType: multiRow @@ -345,6 +365,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}' parseType: multiRow @@ -370,6 +391,7 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k3nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow @@ -395,5 +417,6 @@ metrics: password: ^_^password^_^ privateKey: ^_^privateKey^_^ timeout: ^_^timeout^_^ + reuseConnection: ^_^reuseConnection^_^ script: ps -aux | sort -k4nr | awk 'BEGIN{ print "pid cpu_usage mem_usage command" } {print $2, $3, $4, $11}'| head -n 10 parseType: multiRow diff --git a/manager/src/test/java/org/dromara/hertzbeat/manager/service/MonitorServiceTest.java b/manager/src/test/java/org/dromara/hertzbeat/manager/service/MonitorServiceTest.java index c8f84e764b6..80b08738df1 100644 --- a/manager/src/test/java/org/dromara/hertzbeat/manager/service/MonitorServiceTest.java +++ b/manager/src/test/java/org/dromara/hertzbeat/manager/service/MonitorServiceTest.java @@ -649,6 +649,7 @@ void enableManageMonitors() { when(monitorDao.findMonitorsByIdIn(ids)).thenReturn(monitors); Job job = new Job(); job.setMetrics(new ArrayList<>()); + job.setParams(new ArrayList<>()); when(appService.getAppDefine(monitors.get(0).getApp())).thenReturn(job); List params = Collections.singletonList(new Param()); when(paramDao.findParamsByMonitorId(monitors.get(0).getId())).thenReturn(params); diff --git a/web-app/src/app/routes/monitor/monitor-edit/monitor-edit.component.ts b/web-app/src/app/routes/monitor/monitor-edit/monitor-edit.component.ts index 59a0992fd52..0cf74817332 100644 --- a/web-app/src/app/routes/monitor/monitor-edit/monitor-edit.component.ts +++ b/web-app/src/app/routes/monitor/monitor-edit/monitor-edit.component.ts @@ -101,10 +101,17 @@ export class MonitorEditComponent implements OnInit { param.type = 1; } if (define.type === 'boolean') { - param.value = false; - } - if (param.field === 'host') { + param.value = define.defaultValue == 'true'; + } else if (param.field === 'host') { param.value = this.monitor.host; + } else if (define.defaultValue != undefined) { + if (define.type === 'number') { + param.value = Number(define.defaultValue); + } else if (define.type === 'boolean') { + param.value = define.defaultValue.toLowerCase() == 'true'; + } else { + param.value = define.defaultValue; + } } } else { if (define.type === 'boolean') {