未验证 提交 fd2f058a 编写于 作者: sinat_25235033's avatar sinat_25235033 提交者: GitHub

support ssh protocol config choose if reuse connection (#1136)

上级 ac08d041
......@@ -159,6 +159,7 @@ public class CommonCache {
* @param timeDiff 缓存对象保存时间 millis
*/
public void addCache(Object key, Object value, Long timeDiff) {
removeCache(key);
if (timeDiff == null) {
timeDiff = DEFAULT_CACHE_TIMEOUT;
}
......
......@@ -14,23 +14,25 @@ import org.apache.sshd.core.CoreModuleProperties;
@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;
}
}
......@@ -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 @@ import lombok.extern.slf4j.Slf4j;
* Mongodb 单机指标收集器
*
* @author <a href="mailto:liudonghua123@gmail.com">liudonghua</a>
* @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/
* 可参考 <a href="https://www.mongodb.com/docs/manual/reference/command/nav-diagnostic/">...</a>,
* <a href="https://www.mongodb.com/docs/mongodb-shell/run-commands/">...</a>
* 注意:一些命令需要相应的权限才能执行,否则执行虽然不会报错,但是返回的结果是空的,
* 详见 https://www.mongodb.com/docs/manual/reference/built-in-roles/
* 详见 <a href="https://www.mongodb.com/docs/manual/reference/built-in-roles/">...</a>
*/
private static final String[] SUPPORTED_MONGODB_DIAGNOSTIC_COMMANDS = {
"buildInfo",
......@@ -199,14 +197,10 @@ public class MongodbSingleCollectImpl extends AbstractCollect {
}
// 复用失败则新建连接 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);
......
......@@ -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.ByteArrayOutputStream;
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 class SshCollectImpl extends AbstractCollect {
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<ClientChannelEvent> list = new ArrayList<>();
list.add(ClientChannelEvent.CLOSED);
channel.waitFor(list, timeout);
Collection<ClientChannelEvent> 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 class SshCollectImpl extends AbstractCollect {
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 class SshCollectImpl extends AbstractCollect {
log.error(e.getMessage(), e);
}
}
if (clientSession != null && !reuseConnection) {
try {
clientSession.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
......@@ -247,28 +267,31 @@ public class SshCollectImpl extends AbstractCollect {
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<Object> 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<Object> 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 @@ public class SshCollectImpl extends AbstractCollect {
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;
}
......
......@@ -3,6 +3,8 @@ package org.dromara.hertzbeat.collector.collect.strategy;
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 @@ import java.util.concurrent.ConcurrentHashMap;
*
*/
@Configuration
@Order(value = Ordered.HIGHEST_PRECEDENCE)
public class CollectStrategyFactory implements CommandLineRunner {
/**
......
......@@ -63,6 +63,11 @@ public class SshProtocol {
* 私钥(可选)
*/
private String privateKey;
/**
* reuse connection session
*/
private String reuseConnection = "true";
/**
* SSH执行脚本
......
......@@ -22,6 +22,7 @@ import org.dromara.hertzbeat.common.entity.job.Configmap;
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.beans.factory.annotation.Autowired;
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 class JobSchedulerInit implements CommandLineRunner {
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 class JobSchedulerInit implements CommandLineRunner {
List<Param> params = paramDao.findParamsByMonitorId(monitor.getId());
List<Configmap> configmaps = params.stream().map(param ->
new Configmap(param.getField(), param.getValue(), param.getType())).collect(Collectors.toList());
List<ParamDefine> 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);
......
......@@ -593,6 +593,16 @@ public class MonitorServiceImpl implements MonitorService {
List<Param> params = paramDao.findParamsByMonitorId(monitor.getId());
List<Configmap> configmaps = params.stream().map(param ->
new Configmap(param.getField(), param.getValue(), param.getType())).collect(Collectors.toList());
List<ParamDefine> 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);
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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: '%'
......
......@@ -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
......@@ -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
......@@ -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
......@@ -649,6 +649,7 @@ class MonitorServiceTest {
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<Param> params = Collections.singletonList(new Param());
when(paramDao.findParamsByMonitorId(monitors.get(0).getId())).thenReturn(params);
......
......@@ -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') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册