Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58a61ff40c | ||
|
|
7d7f350e4d | ||
|
|
fc3a2b4591 | ||
|
|
0d9e0d5be4 | ||
|
|
4bd4109faa | ||
|
|
77439ea58a | ||
|
|
ed091f73ac | ||
|
|
6edf086b06 | ||
|
|
665daa1107 | ||
|
|
bff7a87e51 | ||
|
|
c6efffee85 | ||
|
|
8e7b0c7940 | ||
|
|
b6b925644f | ||
|
|
d07d63fa64 | ||
|
|
5f7d1942ed | ||
|
|
a81ebe861f | ||
|
|
c011b6b548 | ||
|
|
d47d736df9 | ||
|
|
55e9084a46 | ||
|
|
de3347b3c5 | ||
|
|
27f46633fc | ||
|
|
bdede80059 | ||
|
|
12a9e25835 | ||
|
|
77394e8ab9 | ||
|
|
128d4f8418 | ||
|
|
d23a48be48 | ||
|
|
e70e687298 | ||
|
|
4eddf0e0dc | ||
|
|
fca66d553f | ||
|
|
1b998e9100 | ||
|
|
b47a61f605 | ||
|
|
42589f6477 | ||
|
|
b773755d92 | ||
|
|
1740497163 | ||
|
|
737a0a9985 | ||
|
|
4853fff587 | ||
|
|
8be974983c |
@@ -1,11 +1,11 @@
|
|||||||
# docker镜像
|
# docker镜像
|
||||||
image: git.mesalab.cn:7443/nezha/nz-build-env:1.2
|
image: git.mesalab.cn:7443/nezha/nz-build-env:1.5
|
||||||
# 定义全局变量
|
# 定义全局变量
|
||||||
variables:
|
variables:
|
||||||
MINIO_HOST: 'http://192.168.44.36:2020/'
|
MINIO_HOST: 'http://192.168.40.48:2020/'
|
||||||
MINIO_USER: 'admin'
|
MINIO_USER: 'admin'
|
||||||
MINIO_PWD: "Nezha@02!"
|
MINIO_PWD: "Nezha@02!"
|
||||||
MAVEN_REPO: "/etc/maven/repository"
|
MAVEN_REPO: "/etc/maven/repository/"
|
||||||
# 依赖的docker服务
|
# 依赖的docker服务
|
||||||
services:
|
services:
|
||||||
# - mariadb
|
# - mariadb
|
||||||
@@ -35,7 +35,7 @@ build_rpm:
|
|||||||
- chmod +x ./tools/package.sh
|
- chmod +x ./tools/package.sh
|
||||||
- ./tools/package.sh
|
- ./tools/package.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
|
name: "$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
|
||||||
when: on_success
|
when: on_success
|
||||||
paths:
|
paths:
|
||||||
- ./target/*.xjar
|
- ./target/*.xjar
|
||||||
@@ -55,10 +55,23 @@ dev_build:
|
|||||||
script:
|
script:
|
||||||
- env | sort
|
- env | sort
|
||||||
- pwd
|
- pwd
|
||||||
|
- export FILE_NAME=$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA.tar.gz
|
||||||
|
- export BRANCH_ARRAY=(${CI_COMMIT_REF_NAME//-/ })
|
||||||
|
- echo -e "version=${BRANCH_ARRAY[1]}\ncommit=$CI_COMMIT_SHORT_SHA\nbuildDate=`date +'%Y%m%d%H%m%S'`" >>./src/main/resources/version.properties
|
||||||
- mvn clean install -Dxjar.password=111111 -Dxjar.excludes=/db/*,/static/**/*
|
- mvn clean install -Dxjar.password=111111 -Dxjar.excludes=/db/*,/static/**/*
|
||||||
- cd ./target && go build xjar.go && cd ..
|
- cd ./target
|
||||||
|
- go build xjar.go
|
||||||
|
- chmod +x xjar
|
||||||
|
- "git log -100 --pretty=format:'%ad : %s' >> git-log.html"
|
||||||
|
- tar -zcvf $FILE_NAME xjar nz-talon.xjar git-log.html
|
||||||
|
- md5sum $FILE_NAME > $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-latest.tar.gz.md5sum.txt
|
||||||
|
- mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD
|
||||||
|
- mc cp $FILE_NAME nz/ci-cd/nz-talon/$FILE_NAME
|
||||||
|
- mc cp $FILE_NAME nz/ci-cd/nz-talon/$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-latest.tar.gz
|
||||||
|
- mc cp $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-latest.tar.gz.md5sum.txt nz/ci-cd/nz-talon/$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-latest.tar.gz.md5sum.txt
|
||||||
|
- cd ../
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
|
name: "$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
|
||||||
when: on_success
|
when: on_success
|
||||||
paths:
|
paths:
|
||||||
- ./target/*.xjar
|
- ./target/*.xjar
|
||||||
|
|||||||
43
pom.xml
43
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.4.4</version>
|
<version>3.1.3</version>
|
||||||
<relativePath /> <!-- lookup parent from repository -->
|
<relativePath /> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>net.geedge</groupId>
|
<groupId>net.geedge</groupId>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<name>nz-talon</name>
|
<name>nz-talon</name>
|
||||||
<description>nezha promtail config sync talon</description>
|
<description>nezha promtail config sync talon</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>21</java.version>
|
||||||
<log4j2.version>2.17.0</log4j2.version>
|
<log4j2.version>2.17.0</log4j2.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.30</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -48,6 +49,11 @@
|
|||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.45</version>
|
<version>1.2.45</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.oshi</groupId>
|
||||||
|
<artifactId>oshi-core</artifactId>
|
||||||
|
<version>6.2.2</version>
|
||||||
|
</dependency>
|
||||||
<!-- 添加 XJar 依赖 -->
|
<!-- 添加 XJar 依赖 -->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>com.github.core-lib</groupId>-->
|
<!-- <groupId>com.github.core-lib</groupId>-->
|
||||||
@@ -61,6 +67,15 @@
|
|||||||
<build>
|
<build>
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.11.0</version>
|
||||||
|
<configuration>
|
||||||
|
<release>${java.version}</release>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
@@ -116,7 +131,17 @@
|
|||||||
<repository>
|
<repository>
|
||||||
<id>nexus</id>
|
<id>nexus</id>
|
||||||
<name>Team Nexus Repository</name>
|
<name>Team Nexus Repository</name>
|
||||||
<url>http://192.168.40.125:8099/content/groups/public/</url>
|
<url>http://192.168.40.153:8099/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>nexus-releases</id>
|
||||||
|
<name>Team Nexus Repository</name>
|
||||||
|
<url>http://192.168.40.153:8099/content/repositories/releases/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>nexus-geedge</id>
|
||||||
|
<name>Team Nexus Repository</name>
|
||||||
|
<url>http://192.168.40.153:8099/content/repositories/geedge/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>public</id>
|
<id>public</id>
|
||||||
@@ -144,7 +169,17 @@
|
|||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>nexus</id>
|
<id>nexus</id>
|
||||||
<name>Team Nexus Repository</name>
|
<name>Team Nexus Repository</name>
|
||||||
<url>http://192.168.40.125:8099/content/groups/public/</url>
|
<url>http://192.168.40.153:8099/content/groups/public/</url>
|
||||||
|
</pluginRepository>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>nexus-releases</id>
|
||||||
|
<name>Team Nexus Repository</name>
|
||||||
|
<url>http://192.168.40.153:8099/content/repositories/releases/</url>
|
||||||
|
</pluginRepository>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>nexus-geedge</id>
|
||||||
|
<name>Team Nexus Repository</name>
|
||||||
|
<url>http://192.168.40.153:8099/content/repositories/geedge/</url>
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>public</id>
|
<id>public</id>
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package net.geedge.confagent;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@PropertySource(value = { "classpath:version.properties" }, encoding = "utf-8", ignoreResourceNotFound = true)
|
||||||
public class ConfagentApplication {
|
public class ConfagentApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
package net.geedge.confagent.controller;
|
package net.geedge.confagent.controller;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import cn.hutool.log.Log;
|
import cn.hutool.log.Log;
|
||||||
import net.geedge.confagent.annotation.UnCheckToken;
|
import net.geedge.confagent.annotation.UnCheckToken;
|
||||||
import net.geedge.confagent.entity.AuthEntity;
|
import net.geedge.confagent.entity.AuthEntity;
|
||||||
import net.geedge.confagent.util.R;
|
import net.geedge.confagent.util.R;
|
||||||
import net.geedge.confagent.util.RCode;
|
import net.geedge.confagent.util.RCode;
|
||||||
import net.geedge.confagent.util.Tool;
|
import net.geedge.confagent.util.Tool;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value={"/auth"})
|
@RequestMapping(value={"/auth"})
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.geedge.confagent.controller;
|
package net.geedge.confagent.controller;
|
||||||
|
|
||||||
import cn.hutool.log.Log;
|
import cn.hutool.log.Log;
|
||||||
|
import net.geedge.confagent.util.Tool;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
public abstract class BaseController {
|
public abstract class BaseController {
|
||||||
@@ -23,6 +24,15 @@ public abstract class BaseController {
|
|||||||
@Value("${confagent.promtail.config}")
|
@Value("${confagent.promtail.config}")
|
||||||
protected String promtailConfPath;
|
protected String promtailConfPath;
|
||||||
|
|
||||||
|
@Value("${version}")
|
||||||
|
protected String currentVersion;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aes 对称加密 密钥
|
||||||
|
*/
|
||||||
|
public static final byte[] AES_SECRET_KEY = Tool.HexUtil.decodeHex("bde5430614b21baf1c53bd6f616d1a39");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用 /-/reload 接口,热加载 server 配置文件,
|
* 调用 /-/reload 接口,热加载 server 配置文件,
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.geedge.confagent.util.ConfagentUtil;
|
|||||||
import net.geedge.confagent.util.R;
|
import net.geedge.confagent.util.R;
|
||||||
import net.geedge.confagent.util.RCode;
|
import net.geedge.confagent.util.RCode;
|
||||||
import net.geedge.confagent.util.Tool;
|
import net.geedge.confagent.util.Tool;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ public class HealthyController extends BaseController{
|
|||||||
@UnCheckToken
|
@UnCheckToken
|
||||||
public R checkHealthy(@RequestHeader(value="Authorization",required = false) String token) {
|
public R checkHealthy(@RequestHeader(value="Authorization",required = false) String token) {
|
||||||
|
|
||||||
Map<String,String> result = new HashMap<>();
|
Map<String,Object> result = new HashMap<>();
|
||||||
|
|
||||||
buildHealthyURL(result);
|
buildHealthyURL(result);
|
||||||
|
|
||||||
@@ -47,10 +47,11 @@ public class HealthyController extends BaseController{
|
|||||||
}
|
}
|
||||||
String version = confagentUtil.readVersion();
|
String version = confagentUtil.readVersion();
|
||||||
result.put("version", version);
|
result.put("version", version);
|
||||||
|
result.put("ts", new Date().getTime());
|
||||||
return R.ok(result);
|
return R.ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildHealthyURL(Map<String,String> result){
|
public void buildHealthyURL(Map<String,Object> result){
|
||||||
|
|
||||||
Map<String,Object> promtailConf = Tool.YamlUtil.readAsMap(promtailConfPath);
|
Map<String,Object> promtailConf = Tool.YamlUtil.readAsMap(promtailConfPath);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package net.geedge.confagent.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.geedge.confagent.util.OSHIUtils;
|
||||||
|
import net.geedge.confagent.util.R;
|
||||||
|
import net.geedge.confagent.util.Tool;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class OSHIController extends BaseController{
|
||||||
|
|
||||||
|
@GetMapping("/oshi/info")
|
||||||
|
public R getSystemInfo(HttpServletRequest request){
|
||||||
|
|
||||||
|
Map<String, Object> systemInfo = OSHIUtils.getSystemInfo();
|
||||||
|
|
||||||
|
return R.ok(systemInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/oshi/process")
|
||||||
|
public R getProcessInfo(HttpServletRequest request) throws InterruptedException {
|
||||||
|
|
||||||
|
List<Map> result = OSHIUtils.getProcessInfo();
|
||||||
|
HashMap<Object, Object> data = Tool.MapUtil.newHashMap();
|
||||||
|
data.put("list" ,result);
|
||||||
|
|
||||||
|
return R.ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/oshi/netstat")
|
||||||
|
public R getNetstatInfo(HttpServletRequest request) throws UnknownHostException {
|
||||||
|
List<Map> result = OSHIUtils.getNetInfo();
|
||||||
|
HashMap<Object, Object> data = Tool.MapUtil.newHashMap();
|
||||||
|
data.put("list" ,result);
|
||||||
|
|
||||||
|
return R.ok(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package net.geedge.confagent.controller;
|
||||||
|
|
||||||
|
import cn.hutool.log.Log;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.geedge.confagent.util.ConfagentUtil;
|
||||||
|
import net.geedge.confagent.util.R;
|
||||||
|
import net.geedge.confagent.util.RCode;
|
||||||
|
import net.geedge.confagent.util.Tool;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class OTAController extends BaseController{
|
||||||
|
|
||||||
|
private static Log log = Log.get();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConfagentUtil confagentUtil;
|
||||||
|
|
||||||
|
private static final String UPDATE_PACKAGE_PATH = "/tmp/nezha/nz-talon/%s/%s";
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/ota")
|
||||||
|
public R ota(HttpServletRequest request, @RequestParam(name = "file", required = false) MultipartFile file, String md5 )throws IOException{
|
||||||
|
|
||||||
|
//检查token
|
||||||
|
String token = request.getHeader("Authorization");
|
||||||
|
if (Tool.StrUtil.isBlank(token)) {
|
||||||
|
return R.error(RCode.AUTH_TOKEN_ISNULL);
|
||||||
|
}else {
|
||||||
|
if (confagentUtil.checkToken(token).getCode() != RCode.SUCCESS.getCode())return R.error(RCode.AUTH_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
|
||||||
|
//将文件缓存到 /tmp 目录下
|
||||||
|
String updateFileName = file.getOriginalFilename();
|
||||||
|
File updatePackagePath = Tool.FileUtil.file(String.format(UPDATE_PACKAGE_PATH , UUID.randomUUID().toString().replaceAll("-", ""), updateFileName));
|
||||||
|
updatePackagePath.mkdirs();
|
||||||
|
try {
|
||||||
|
file.transferTo(updatePackagePath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return R.error(RCode.OTA_FILE_CACHE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
//校验MD5
|
||||||
|
String updateFileMd5 = Tool.DigestUtil.md5Hex(new FileInputStream(updatePackagePath));
|
||||||
|
log.info("updateFileMd5 : {}",updateFileMd5);
|
||||||
|
md5 = Tool.AesUtil.decrypt(md5 , AES_SECRET_KEY);
|
||||||
|
if(!updateFileMd5.equals(md5)){
|
||||||
|
return R.error(RCode.OTA_MD5_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
//校验版本号
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
String updateVersion = fileName.split("-")[2];
|
||||||
|
updateVersion = updateVersion.substring(0,updateVersion.lastIndexOf("."));
|
||||||
|
log.info("current version : {} , update version : {}", currentVersion , updateVersion);
|
||||||
|
if( !(Tool.DateUtil.betweenDay(Tool.DateUtil.parseDate(updateVersion),Tool.DateUtil.parseDate(currentVersion), false) > 0)){
|
||||||
|
return R.error(RCode.OTA_VERSION_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//检查atd服务是否启动
|
||||||
|
InputStream atdStatus = Tool.RuntimeUtil.exec("systemctl status atd").getInputStream();
|
||||||
|
String atdStatusStr = Tool.IoUtil.read(atdStatus).toString();
|
||||||
|
if(!atdStatusStr.contains("Active: active (running)")){
|
||||||
|
return R.error(RCode.OTA_ATD_SERVICE_DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
//延迟一分钟更新 使用echo 将更新命令传入at
|
||||||
|
String atCommand ="echo \"rpm -Uvh %s\" | at now +1 minutes";
|
||||||
|
atCommand = String.format(atCommand,updatePackagePath);
|
||||||
|
log.info("update nz-agent : {}", atCommand);
|
||||||
|
new ProcessBuilder("/bin/bash", "-c", atCommand).start();
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,16 +2,18 @@ package net.geedge.confagent.controller;
|
|||||||
|
|
||||||
import cn.hutool.core.net.url.UrlBuilder;
|
import cn.hutool.core.net.url.UrlBuilder;
|
||||||
import cn.hutool.core.net.url.UrlPath;
|
import cn.hutool.core.net.url.UrlPath;
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpConnection;
|
import cn.hutool.http.HttpConnection;
|
||||||
import cn.hutool.log.Log;
|
import cn.hutool.log.Log;
|
||||||
|
import jakarta.servlet.ServletInputStream;
|
||||||
|
import jakarta.servlet.ServletOutputStream;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import net.geedge.confagent.annotation.UnCheckToken;
|
import net.geedge.confagent.annotation.UnCheckToken;
|
||||||
import net.geedge.confagent.util.ConfagentUtil;
|
import net.geedge.confagent.util.ConfagentUtil;
|
||||||
import net.geedge.confagent.util.R;
|
import net.geedge.confagent.util.R;
|
||||||
import net.geedge.confagent.util.RCode;
|
import net.geedge.confagent.util.RCode;
|
||||||
import net.geedge.confagent.util.Tool;
|
import net.geedge.confagent.util.Tool;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -24,11 +26,6 @@ import java.net.HttpURLConnection;
|
|||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import javax.servlet.ServletInputStream;
|
|
||||||
import javax.servlet.ServletOutputStream;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/promtail")
|
@RequestMapping("/promtail")
|
||||||
public class PromtailController extends BaseController{
|
public class PromtailController extends BaseController{
|
||||||
@@ -40,16 +37,16 @@ public class PromtailController extends BaseController{
|
|||||||
@Value("${confagent.promtail.query.auth:true}")
|
@Value("${confagent.promtail.query.auth:true}")
|
||||||
private Boolean queryAuth;
|
private Boolean queryAuth;
|
||||||
|
|
||||||
@Value("${confagent.promtail.restart:systemctl restart promtail}")
|
@Value("${confagent.promtail.restart:systemctl restart nz-promtail}")
|
||||||
private String restartCmd;
|
private String restartCmd;
|
||||||
|
|
||||||
@Value("${confagent.versionFile:promtail.version}")
|
@Value("${confagent.versionFile:promtail.version}")
|
||||||
private String versionFile;
|
private String versionFile;
|
||||||
|
|
||||||
@Value("${confagent.promtail.startCmd:systemctl start promtail.service}")
|
@Value("${confagent.promtail.startCmd:systemctl start nz-promtail.service}")
|
||||||
private String startCmd;
|
private String startCmd;
|
||||||
|
|
||||||
@Value("${confagent.promtail.stopCmd:systemctl stop promtail.service}")
|
@Value("${confagent.promtail.stopCmd:systemctl stop nz-promtail.service}")
|
||||||
private String stopCmd;
|
private String stopCmd;
|
||||||
|
|
||||||
private final String[] QUERY_API_SUFFIX = {"query","query_range","series","labels","label","values"};
|
private final String[] QUERY_API_SUFFIX = {"query","query_range","series","labels","label","values"};
|
||||||
@@ -203,7 +200,7 @@ public class PromtailController extends BaseController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void requestProm(String host, int port, String path, HttpServletRequest request, HttpServletResponse response) {
|
public void requestProm(String host, int port, String path, HttpServletRequest request, HttpServletResponse response) {
|
||||||
String queryString = ReflectUtil.invoke(request, "getQueryString");
|
String queryString = request.getQueryString();
|
||||||
queryString = StrUtil.isNotBlank(queryString)?queryString:"";
|
queryString = StrUtil.isNotBlank(queryString)?queryString:"";
|
||||||
String url = UrlBuilder.create().setScheme("http").setHost(host).setPort(port).setPath(UrlPath.of(path, Charset.forName("UTF-8"))).toURL().toString() + "?" + queryString;
|
String url = UrlBuilder.create().setScheme("http").setHost(host).setPort(port).setPath(UrlPath.of(path, Charset.forName("UTF-8"))).toURL().toString() + "?" + queryString;
|
||||||
|
|
||||||
@@ -224,7 +221,7 @@ public class PromtailController extends BaseController{
|
|||||||
while (headerNames.hasMoreElements()) {
|
while (headerNames.hasMoreElements()) {
|
||||||
String hn = headerNames.nextElement();
|
String hn = headerNames.nextElement();
|
||||||
if(!"authorization".equalsIgnoreCase(hn)) {
|
if(!"authorization".equalsIgnoreCase(hn)) {
|
||||||
ReflectUtil.invoke(conn,"addRequestProperty",hn,request.getHeader(hn));
|
conn.addRequestProperty(hn, request.getHeader(hn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,10 +242,12 @@ public class PromtailController extends BaseController{
|
|||||||
String key = en.getKey();
|
String key = en.getKey();
|
||||||
if (Tool.StrUtil.isEmpty(key) || "Transfer-Encoding".equals(key)) continue;
|
if (Tool.StrUtil.isEmpty(key) || "Transfer-Encoding".equals(key)) continue;
|
||||||
List<String> value = en.getValue();
|
List<String> value = en.getValue();
|
||||||
ReflectUtil.invoke(response,"addHeader",key,Tool.StrUtil.join("; ",value));
|
response.addHeader(key, Tool.StrUtil.join("; ", value));
|
||||||
|
}
|
||||||
|
response.setStatus(responseCode);
|
||||||
|
if (responseCode > 400) {
|
||||||
|
response.sendError(responseCode, responseMessage);
|
||||||
}
|
}
|
||||||
ReflectUtil.invoke(response, "setStatus", responseCode, responseMessage);
|
|
||||||
|
|
||||||
Tool.IoUtil.copy(connInputStream, resOutputStream);
|
Tool.IoUtil.copy(connInputStream, resOutputStream);
|
||||||
resOutputStream.flush();//flush 输出流
|
resOutputStream.flush();//flush 输出流
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
package net.geedge.confagent.interceptor;
|
package net.geedge.confagent.interceptor;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.method.HandlerMethod;
|
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
|
||||||
|
|
||||||
import cn.hutool.log.Log;
|
import cn.hutool.log.Log;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import net.geedge.confagent.annotation.UnCheckToken;
|
import net.geedge.confagent.annotation.UnCheckToken;
|
||||||
import net.geedge.confagent.util.ConfagentUtil;
|
import net.geedge.confagent.util.ConfagentUtil;
|
||||||
import net.geedge.confagent.util.R;
|
import net.geedge.confagent.util.R;
|
||||||
import net.geedge.confagent.util.RCode;
|
import net.geedge.confagent.util.RCode;
|
||||||
import net.geedge.confagent.util.Tool;
|
import net.geedge.confagent.util.Tool;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class TokenInterceptor implements HandlerInterceptor {
|
public class TokenInterceptor implements HandlerInterceptor {
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package net.geedge.confagent.util;
|
package net.geedge.confagent.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
|
import cn.hutool.log.Log;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@@ -8,15 +15,6 @@ import java.util.Map;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.annotation.Order;
|
|
||||||
|
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
|
||||||
import cn.hutool.log.Log;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Order(value = 1)
|
@Order(value = 1)
|
||||||
public class ConfagentUtil {
|
public class ConfagentUtil {
|
||||||
|
|||||||
229
src/main/java/net/geedge/confagent/util/OSHIUtils.java
Normal file
229
src/main/java/net/geedge/confagent/util/OSHIUtils.java
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
package net.geedge.confagent.util;
|
||||||
|
|
||||||
|
import cn.hutool.log.Log;
|
||||||
|
import oshi.SystemInfo;
|
||||||
|
import oshi.hardware.*;
|
||||||
|
import oshi.software.os.InternetProtocolStats;
|
||||||
|
import oshi.software.os.NetworkParams;
|
||||||
|
import oshi.software.os.OSProcess;
|
||||||
|
import oshi.software.os.OperatingSystem;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public class OSHIUtils {
|
||||||
|
|
||||||
|
private static Log log = Log.get();
|
||||||
|
|
||||||
|
private static final SystemInfo si = new SystemInfo();
|
||||||
|
private static final OperatingSystem operatingSystem = si.getOperatingSystem();
|
||||||
|
private static final HardwareAbstractionLayer hal = si.getHardware();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统信息
|
||||||
|
* @return result
|
||||||
|
*/
|
||||||
|
public static Map<String,Object> getSystemInfo(){
|
||||||
|
|
||||||
|
HashMap<Object, Object> os = Tool.MapUtil.newHashMap();
|
||||||
|
NetworkParams networkParams = operatingSystem.getNetworkParams();
|
||||||
|
os.put("versionInfo",operatingSystem.getVersionInfo().toString());
|
||||||
|
os.put("platform",si.getCurrentPlatform());
|
||||||
|
os.put("family",operatingSystem.getFamily());
|
||||||
|
os.put("manufacturer",operatingSystem.getManufacturer());
|
||||||
|
os.put("bitness",operatingSystem.getBitness());
|
||||||
|
os.put("bootTime",operatingSystem.getSystemBootTime());
|
||||||
|
os.put("hostName",networkParams.getHostName());
|
||||||
|
os.put("ipv4DefaultGateway",networkParams.getIpv4DefaultGateway());
|
||||||
|
os.put("ipv6DefaultGateway",networkParams.getIpv6DefaultGateway());
|
||||||
|
os.put("dnsServers",networkParams.getDnsServers());
|
||||||
|
|
||||||
|
HashMap<Object, Object> system = Tool.MapUtil.newHashMap();
|
||||||
|
ComputerSystem computerSystem = hal.getComputerSystem();
|
||||||
|
system.put("serialNumber",computerSystem.getSerialNumber());
|
||||||
|
system.put("model",computerSystem.getModel());
|
||||||
|
system.put("manufacturer",computerSystem.getManufacturer());
|
||||||
|
system.put("hardwareUUID",computerSystem.getHardwareUUID());
|
||||||
|
|
||||||
|
|
||||||
|
HashMap<Object, Object> baseBoardMap = Tool.MapUtil.newHashMap();
|
||||||
|
Baseboard baseboard = computerSystem.getBaseboard();
|
||||||
|
baseBoardMap.put("serialNumber",baseboard.getSerialNumber());
|
||||||
|
baseBoardMap.put("model",baseboard.getModel());
|
||||||
|
baseBoardMap.put("manufacturer",baseboard.getManufacturer());
|
||||||
|
baseBoardMap.put("version",baseboard.getVersion());
|
||||||
|
|
||||||
|
HashMap<Object, Object> cpu = Tool.MapUtil.newHashMap();
|
||||||
|
CentralProcessor processor = hal.getProcessor();
|
||||||
|
cpu.put("physicalPackageCount",processor.getPhysicalPackageCount());
|
||||||
|
cpu.put("physicalProcessorCount",processor.getPhysicalProcessorCount());
|
||||||
|
cpu.put("logicalProcessorCount",processor.getLogicalProcessorCount());
|
||||||
|
cpu.put("contextSwitches",processor.getContextSwitches());
|
||||||
|
cpu.put("interrupts",processor.getInterrupts());
|
||||||
|
cpu.put("maxFreq",processor.getMaxFreq());
|
||||||
|
CentralProcessor.ProcessorIdentifier processorIdentifier = processor.getProcessorIdentifier();
|
||||||
|
cpu.put("family",processorIdentifier.getFamily());
|
||||||
|
cpu.put("identifier",processorIdentifier.getIdentifier());
|
||||||
|
cpu.put("microarchitecture",processorIdentifier.getMicroarchitecture());
|
||||||
|
cpu.put("model",processorIdentifier.getModel());
|
||||||
|
cpu.put("name",processorIdentifier.getName());
|
||||||
|
cpu.put("vendor",processorIdentifier.getVendor());
|
||||||
|
cpu.put("stepping",processorIdentifier.getStepping());
|
||||||
|
cpu.put("cpu64bit",processorIdentifier.isCpu64bit());
|
||||||
|
|
||||||
|
HashMap<Object, Object> memory = Tool.MapUtil.newHashMap();
|
||||||
|
GlobalMemory memoryInfo = hal.getMemory();
|
||||||
|
VirtualMemory virtualMemory = memoryInfo.getVirtualMemory();
|
||||||
|
memory.put("total",memoryInfo.getTotal());
|
||||||
|
memory.put("swapTotal",virtualMemory.getSwapTotal());
|
||||||
|
memory.put("virtualMax",virtualMemory.getVirtualMax());
|
||||||
|
memory.put("pageSize",memoryInfo.getPageSize());
|
||||||
|
|
||||||
|
List<HashMap<Object, Object>> disk = Tool.ListUtil.list(false);
|
||||||
|
List<HWDiskStore> diskStores = hal.getDiskStores();
|
||||||
|
for(HWDiskStore diskStore : diskStores) {
|
||||||
|
if ( diskStore.getSize() > 0){
|
||||||
|
HashMap<Object, Object> diskData = Tool.MapUtil.newHashMap();
|
||||||
|
diskData.put("name",diskStore.getName());
|
||||||
|
diskData.put("model",diskStore.getModel());
|
||||||
|
diskData.put("serial",diskStore.getSerial());
|
||||||
|
diskData.put("size",diskStore.getSize());
|
||||||
|
disk.add(diskData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap<Object, Object>> network = Tool.ListUtil.list(false);
|
||||||
|
List<NetworkIF> networkIFs = hal.getNetworkIFs(true);
|
||||||
|
for (NetworkIF networkIF : networkIFs) {
|
||||||
|
HashMap<Object, Object> networkData = Tool.MapUtil.newHashMap();
|
||||||
|
networkData.put("index", networkIF.getIndex());
|
||||||
|
networkData.put("name",networkIF.getName());
|
||||||
|
networkData.put("ifAlias",networkIF.getIfAlias());
|
||||||
|
networkData.put("ifType",networkIF.getIfType());
|
||||||
|
networkData.put("speed",networkIF.getSpeed());
|
||||||
|
networkData.put("mtu",networkIF.getMTU());
|
||||||
|
networkData.put("ifOperStatus",networkIF.getIfOperStatus().getValue());
|
||||||
|
networkData.put("macaddr",networkIF.getMacaddr());
|
||||||
|
networkData.put("iPv4addr",networkIF.getIPv4addr());
|
||||||
|
networkData.put("subnetMasks",networkIF.getSubnetMasks());
|
||||||
|
networkData.put("iPv6addr",networkIF.getIPv6addr());
|
||||||
|
network.add(networkData);
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<Object, Object> sensor = Tool.MapUtil.newHashMap();
|
||||||
|
Sensors sensors = hal.getSensors();
|
||||||
|
sensor.put("cpuTemperature",sensors.getCpuTemperature());
|
||||||
|
sensor.put("cpuVoltage",sensors.getCpuVoltage());
|
||||||
|
sensor.put("fanSpeeds",sensors.getFanSpeeds());
|
||||||
|
|
||||||
|
HashMap<String, Object> result = Tool.MapUtil.newHashMap();
|
||||||
|
result.put("os",os);
|
||||||
|
result.put("system",system);
|
||||||
|
result.put("baseBoard",baseBoardMap);
|
||||||
|
result.put("cpu",cpu);
|
||||||
|
result.put("memory",memory);
|
||||||
|
result.put("disk",disk);
|
||||||
|
result.put("networkIF",network);
|
||||||
|
result.put("sensor",sensor);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进程信息
|
||||||
|
* @return result
|
||||||
|
*/
|
||||||
|
public static List<Map> getProcessInfo() throws InterruptedException {
|
||||||
|
|
||||||
|
List<Map> result = Tool.ListUtil.list(false);
|
||||||
|
List<OSProcess> oldProcess = operatingSystem.getProcesses();
|
||||||
|
Thread.sleep(500);
|
||||||
|
List<OSProcess> currentProcess = operatingSystem.getProcesses();
|
||||||
|
Map<Integer, Object> cpuUsage = getCpuUsage(currentProcess, oldProcess);
|
||||||
|
GlobalMemory memory = hal.getMemory();
|
||||||
|
|
||||||
|
for (OSProcess proc : currentProcess) {
|
||||||
|
HashMap<String, Object> procsData = Tool.MapUtil.newHashMap();
|
||||||
|
procsData.put("name",proc.getName());
|
||||||
|
procsData.put("commandLine",proc.getCommandLine());
|
||||||
|
procsData.put("processID",proc.getProcessID());
|
||||||
|
procsData.put("parentProcessID",proc.getParentProcessID());
|
||||||
|
procsData.put("startTime",proc.getStartTime());
|
||||||
|
procsData.put("priority",proc.getPriority());
|
||||||
|
procsData.put("cpuUsage",(double)cpuUsage.get(proc.getProcessID()) * 100d);
|
||||||
|
procsData.put("memUsage",Tool.NumberUtil.div(proc.getResidentSetSize(), memory.getTotal()) * 100d);
|
||||||
|
procsData.put("state",proc.getState().toString());
|
||||||
|
procsData.put("openFiles",proc.getOpenFiles());
|
||||||
|
procsData.put("threadCount",proc.getThreadCount());
|
||||||
|
procsData.put("user",proc.getUser());
|
||||||
|
procsData.put("group",proc.getGroup());
|
||||||
|
procsData.put("path",proc.getPath());
|
||||||
|
procsData.put("virtualSize",proc.getVirtualSize());
|
||||||
|
procsData.put("residentSetSize",proc.getResidentSetSize());
|
||||||
|
procsData.put("runTime",proc.getUpTime());
|
||||||
|
result.add(procsData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取进程cpu利用率
|
||||||
|
* @param currentProc
|
||||||
|
* @param oldProcess
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static Map<Integer,Object> getCpuUsage(List<OSProcess> currentProc, List<OSProcess> oldProcess) {
|
||||||
|
|
||||||
|
Map<Integer, OSProcess> procs = oldProcess.stream().collect(Collectors.toMap(OSProcess::getProcessID, Function.identity()));
|
||||||
|
HashMap<Integer, Object> map = Tool.MapUtil.newHashMap();
|
||||||
|
for (OSProcess proc : currentProc) {
|
||||||
|
OSProcess old = procs.get(proc.getProcessID());
|
||||||
|
map.put(proc.getProcessID(),proc.getProcessCpuLoadBetweenTicks(old));
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网络连接信息
|
||||||
|
* @return result
|
||||||
|
*/
|
||||||
|
public static List<Map> getNetInfo() throws UnknownHostException {
|
||||||
|
|
||||||
|
List<Map> result = Tool.ListUtil.list(false);
|
||||||
|
InternetProtocolStats internetProtocolStats = operatingSystem.getInternetProtocolStats();
|
||||||
|
//获取网络连接
|
||||||
|
List<InternetProtocolStats.IPConnection> connections = internetProtocolStats.getConnections();
|
||||||
|
for (InternetProtocolStats.IPConnection connection : connections) {
|
||||||
|
HashMap<String, Object> map = Tool.MapUtil.newHashMap();
|
||||||
|
map.put("type",connection.getType());
|
||||||
|
map.put("localAddress", InetAddress.getByAddress(connection.getLocalAddress()).toString().substring(1));
|
||||||
|
map.put("localPort",connection.getLocalPort());
|
||||||
|
map.put("foreignAddress",InetAddress.getByAddress(connection.getForeignAddress()).toString().substring(1));
|
||||||
|
map.put("foreignPort",connection.getForeignPort());
|
||||||
|
map.put("state",connection.getState().toString());
|
||||||
|
map.put("transmitQueue",connection.getTransmitQueue());
|
||||||
|
map.put("receiveQueue",connection.getReceiveQueue());
|
||||||
|
if (connection.getowningProcessId() == -1 ){
|
||||||
|
//未知进程 getowningProcessId 返回 -1 为避免获取进程name error
|
||||||
|
map.put("processId",-1);
|
||||||
|
map.put("processName","");
|
||||||
|
map.put("processCmd","");
|
||||||
|
}else {
|
||||||
|
map.put("processId",connection.getowningProcessId());
|
||||||
|
map.put("processName",operatingSystem.getProcess(connection.getowningProcessId()).getName());
|
||||||
|
map.put("processCmd",operatingSystem.getProcess(connection.getowningProcessId()).getCommandLine());
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(map);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,6 +18,11 @@ public enum RCode {
|
|||||||
PROMTAIL_START_CMD_ERROR(10009,"The promtail start command is error"),
|
PROMTAIL_START_CMD_ERROR(10009,"The promtail start command is error"),
|
||||||
PROMTAIL_STOP_CMD_ERROR(10010,"The promtail stop command is error"),
|
PROMTAIL_STOP_CMD_ERROR(10010,"The promtail stop command is error"),
|
||||||
|
|
||||||
|
OTA_FILE_CACHE_ERROR(10011,"Cache rpm package failed"),
|
||||||
|
OTA_MD5_ERROR(10012,"MD5 is error"),
|
||||||
|
OTA_VERSION_ERROR(10013,"The updated version is lower than the current version"),
|
||||||
|
OTA_ATD_SERVICE_DOWN(10014,"The ATD service is down"),
|
||||||
|
|
||||||
ERROR(999, "error"); //通用错误/未知错误
|
ERROR(999, "error"); //通用错误/未知错误
|
||||||
private RCode(Integer code, String msg) {
|
private RCode(Integer code, String msg) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
package net.geedge.confagent.util;
|
package net.geedge.confagent.util;
|
||||||
|
|
||||||
import cn.hutool.log.Log;
|
import cn.hutool.log.Log;
|
||||||
import net.geedge.confagent.ConfagentApplication;
|
|
||||||
|
|
||||||
import java.awt.Graphics;
|
import javax.crypto.Cipher;
|
||||||
import java.awt.Robot;
|
import javax.crypto.KeyGenerator;
|
||||||
|
import javax.crypto.SecretKey;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import javax.tools.JavaCompiler;
|
||||||
|
import javax.tools.JavaFileObject;
|
||||||
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.ref.PhantomReference;
|
import java.lang.ref.*;
|
||||||
import java.lang.ref.Reference;
|
|
||||||
import java.lang.ref.ReferenceQueue;
|
|
||||||
import java.lang.ref.SoftReference;
|
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.temporal.Temporal;
|
import java.time.temporal.Temporal;
|
||||||
import java.time.temporal.TemporalAccessor;
|
import java.time.temporal.TemporalAccessor;
|
||||||
@@ -24,9 +26,6 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
|
|
||||||
import javax.tools.JavaCompiler;
|
|
||||||
import javax.tools.JavaFileObject;
|
|
||||||
|
|
||||||
public class Tool {
|
public class Tool {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1103,4 +1102,66 @@ public class Tool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//aes 工具
|
||||||
|
public static class AesUtil {
|
||||||
|
|
||||||
|
private static final String KEY_ALGORITHM = "AES";
|
||||||
|
private static final String DEFAULT_CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";// 默认的加密算法
|
||||||
|
|
||||||
|
public static String encrypt(String content, byte[] key) {
|
||||||
|
try {
|
||||||
|
Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);// 创建密码器
|
||||||
|
|
||||||
|
byte[] byteContent = content.getBytes("utf-8");
|
||||||
|
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, getSecretKey(key));// 初始化为加密模式的密码器
|
||||||
|
|
||||||
|
byte[] result = cipher.doFinal(byteContent);// 加密
|
||||||
|
|
||||||
|
return cn.hutool.core.util.HexUtil.encodeHexStr(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String decrypt(String content, byte[] key) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 实例化
|
||||||
|
Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);
|
||||||
|
|
||||||
|
// 使用密钥初始化,设置为解密模式
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, getSecretKey(key));
|
||||||
|
|
||||||
|
// 执行操作
|
||||||
|
byte[] result = cipher.doFinal(cn.hutool.core.util.HexUtil.decodeHex(content));
|
||||||
|
String s = new String(result, "utf-8");
|
||||||
|
return s;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SecretKeySpec getSecretKey(byte[] key) {
|
||||||
|
// 返回生成指定算法密钥生成器的 KeyGenerator 对象
|
||||||
|
KeyGenerator kg = null;
|
||||||
|
try {
|
||||||
|
kg = KeyGenerator.getInstance(KEY_ALGORITHM);
|
||||||
|
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||||
|
random.setSeed(key);
|
||||||
|
// AES 要求密钥长度为 128
|
||||||
|
kg.init(128, random);
|
||||||
|
// 生成一个密钥
|
||||||
|
SecretKey secretKey = kg.generateKey();
|
||||||
|
return new SecretKeySpec(secretKey.getEncoded(), KEY_ALGORITHM);// 转换为AES专用密钥
|
||||||
|
} catch (NoSuchAlgorithmException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ confagent:
|
|||||||
cmdLine: /opt/nezha/promtail/config.conf
|
cmdLine: /opt/nezha/promtail/config.conf
|
||||||
config: /opt/nezha/promtail/promtail.yaml
|
config: /opt/nezha/promtail/promtail.yaml
|
||||||
defaultIP: 127.0.0.1
|
defaultIP: 127.0.0.1
|
||||||
startCmd: systemctl start promtail
|
startCmd: systemctl start nz-promtail
|
||||||
stopCmd: systemctl stop promtail
|
stopCmd: systemctl stop nz-promtail
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
config: config/logback-spring.xml
|
config: config/logback-spring.xml
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: prod
|
active: prod
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
max-file-size: 100MB
|
||||||
|
max-request-size: 100MB
|
||||||
|
enabled: true
|
||||||
|
|
||||||
confagent:
|
confagent:
|
||||||
tokenFile: ./config/token.auth
|
tokenFile: ./config/token.auth
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration>
|
<configuration scan="true" scanPeriod="60 seconds">
|
||||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||||
<logger name="org.springframework.web" level="info" />
|
<logger name="org.springframework.web" level="info" />
|
||||||
<logger name="org.springboot.sample" level="info" />
|
<logger name="org.apache" level="warn" />
|
||||||
<logger name="org.apache" level="info" />
|
|
||||||
<logger name="org.springframework" level="info" />
|
<logger name="org.springframework" level="info" />
|
||||||
<logger name="druid.sql" level="info" />
|
<logger name="druid.sql" level="info" />
|
||||||
<logger name="com.springboot" level="debug" />
|
|
||||||
|
|
||||||
<property name="log.path" value="./logs/" />
|
<property name="log.path" value="./logs/" />
|
||||||
<!-- 输出格式 -->
|
<!-- 输出格式 -->
|
||||||
|
|||||||
@@ -1,7 +1,96 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
WORK_DIR=/opt/nezha/nz-talon
|
||||||
|
|
||||||
|
|
||||||
|
service_exists(){
|
||||||
|
local n=$1
|
||||||
|
if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | sed 's/^\s*//g' | cut -f1 -d' ') == $n.service ]]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 初始化 rsyslog & logrotate 配置
|
||||||
|
fn_init_syslog_logrotate_config(){
|
||||||
|
# promtail
|
||||||
|
cat > /etc/rsyslog.d/promtail.conf << "EOF"
|
||||||
|
if $programname == 'promtail' then {
|
||||||
|
/var/log/nezha/promtail/promtail.log
|
||||||
|
stop
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
cat > /etc/logrotate.d/promtail << "EOF"
|
||||||
|
/var/log/nezha/promtail/*.log {
|
||||||
|
daily
|
||||||
|
missingok
|
||||||
|
maxsize 100M
|
||||||
|
rotate 7
|
||||||
|
copytruncate
|
||||||
|
compress
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# telegraf
|
||||||
|
cat > /etc/rsyslog.d/telegraf.conf << "EOF"
|
||||||
|
if $programname == 'telegraf' then {
|
||||||
|
/var/log/nezha/telegraf/telegraf.log
|
||||||
|
stop
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
cat > /etc/logrotate.d/telegraf << "EOF"
|
||||||
|
/var/log/nezha/telegraf/*.log {
|
||||||
|
daily
|
||||||
|
missingok
|
||||||
|
maxsize 100M
|
||||||
|
rotate 7
|
||||||
|
copytruncate
|
||||||
|
compress
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
compareMD5(){
|
||||||
|
if [ ! -f $1 ] || [ ! -f $2 ];then
|
||||||
|
echo 1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local f1MD5=`md5sum $1|awk '{print $1}'`
|
||||||
|
local f2MD5=`md5sum $2|awk '{print $1}'`
|
||||||
|
|
||||||
|
if [ ${f1MD5} = ${f2MD5} ];then
|
||||||
|
echo 0
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo 1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 还原配置文件
|
||||||
|
# $1 需要还原的文件目录 /opt/nezha/nz-talon/config /opt/nezha/nz-talon/promtail ...
|
||||||
|
# $2 备份文件目录 /tmp/nezha/nz-talon/config /tmp/nezha/nz-talon/promtail ...
|
||||||
|
restoreComponentConfig(){
|
||||||
|
if [ ! -d $1 ] || [ ! -d $2 ];then
|
||||||
|
echo "Directory does not exist"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in $(ls $2);do
|
||||||
|
if [ 1 -eq `compareMD5 $1/$i $2/$i` ];then
|
||||||
|
echo 'return config file '$1/${i}
|
||||||
|
cp -f $2/$i $1/$i
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Find Java
|
# Find Java
|
||||||
if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
|
if [[ -x "$WORK_DIR/jdk/bin/java" ]]; then
|
||||||
|
JAVA_EXE="$WORK_DIR/jdk/bin/java"
|
||||||
|
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
|
||||||
JAVA_EXE="$JAVA_HOME/bin/java"
|
JAVA_EXE="$JAVA_HOME/bin/java"
|
||||||
elif type -p java > /dev/null 2>&1; then
|
elif type -p java > /dev/null 2>&1; then
|
||||||
JAVA_EXE=$(type -p java)
|
JAVA_EXE=$(type -p java)
|
||||||
@@ -21,14 +110,15 @@ Description=nz-talon
|
|||||||
After=network.target
|
After=network.target
|
||||||
[Service]
|
[Service]
|
||||||
WorkingDirectory=/opt/nezha/nz-talon
|
WorkingDirectory=/opt/nezha/nz-talon
|
||||||
ExecStart=/opt/nezha/nz-talon/xjar ${JAVA_EXE} -Dnz-agent.dir=/opt/nezha/nz-talon -jar /opt/nezha/nz-talon/nz-talon.xjar
|
EnvironmentFile=-/opt/nezha/nz-talon/config/config.conf
|
||||||
|
ExecStart=/opt/nezha/nz-talon/xjar ${JAVA_EXE} --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED -Dnz-agent.dir=/opt/nezha/nz-talon -jar /opt/nezha/nz-talon/nz-talon.xjar
|
||||||
RestartSec=5s
|
RestartSec=5s
|
||||||
Restart=always
|
Restart=always
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat > /usr/lib/systemd/system/promtail.service <<"EOF"
|
cat > /usr/lib/systemd/system/nz-promtail.service <<"EOF"
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=nz-talon
|
Description=nz-talon
|
||||||
After=network.target
|
After=network.target
|
||||||
@@ -42,52 +132,122 @@ Restart=always
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
cat > /usr/lib/systemd/system/nz-telegraf.service <<"EOF"
|
||||||
|
[Unit]
|
||||||
|
Description=Telegraf
|
||||||
|
Documentation=https://github.com/influxdata/telegraf
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=/opt/nezha/telegraf
|
||||||
|
Type=notify
|
||||||
|
EnvironmentFile=/opt/nezha/telegraf/config.conf
|
||||||
|
ExecStart=/opt/nezha/telegraf/telegraf $OPTION
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
Restart=on-failure
|
||||||
|
RestartForceExitStatus=SIGPIPE
|
||||||
|
KillMode=control-group
|
||||||
|
LimitMEMLOCK=8M:8M
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
fn_init_syslog_logrotate_config
|
||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable nz-talon && systemctl restart nz-talon
|
systemctl enable nz-talon && systemctl restart nz-talon
|
||||||
systemctl enable promtail && systemctl restart promtail
|
systemctl enable nz-promtail && systemctl restart nz-promtail
|
||||||
|
systemctl enable nz-telegraf && systemctl restart nz-telegraf
|
||||||
|
systemctl enable crond && systemctl restart crond
|
||||||
|
systemctl enable rsyslog && systemctl restart rsyslog
|
||||||
echo 'install nz-talon success !'
|
echo 'install nz-talon success !'
|
||||||
fi
|
fi
|
||||||
compareMD5()
|
|
||||||
{
|
|
||||||
if [ ! -f $1 ] || [ ! -f $2 ];then
|
|
||||||
echo 1
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local f1MD5=`md5sum $1|awk '{print $1}'`
|
|
||||||
local f2MD5=`md5sum $2|awk '{print $1}'`
|
|
||||||
|
|
||||||
if [ ${f1MD5} = ${f2MD5} ];then
|
|
||||||
echo 0
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo 1
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# update
|
# update
|
||||||
if [ 2 -eq $1 ];then
|
if [ 2 -eq $1 ];then
|
||||||
TALON_PATH=/opt/nezha/nz-talon
|
TALON_PATH=/opt/nezha/nz-talon
|
||||||
TMP_PATH=/tmp/nezha/nz-talon
|
TMP_PATH=/tmp/nezha/nz-talon
|
||||||
PROMTAIL_PATH=/opt/nezha/promtail
|
PROMTAIL_PATH=/opt/nezha/promtail
|
||||||
|
TELEGRAF_PATH=/opt/nezha/telegraf
|
||||||
echo 'move backup config file...'
|
echo 'move backup config file...'
|
||||||
if [ -d $TMP_PATH ];then
|
if [ -d $TMP_PATH ];then
|
||||||
# 恢复 nz-talon 配置文件
|
# nz-talon config
|
||||||
for i in $(ls $TALON_PATH/config);do
|
restoreComponentConfig $TALON_PATH/config $TMP_PATH/config
|
||||||
if [ 1 -eq `compareMD5 $WEB_PATH/config/$i $TMP_PATH/config/$i` ];then
|
|
||||||
echo 'return config file '${i}
|
# promtail.service 名称改为 nz-promtail.service
|
||||||
cp -f $TMP_PATH/config/$i $TALON_PATH/config/$i
|
# 这里重新替换下 application-prod.yml 中的 systemctl start|stop promtail 命令
|
||||||
fi
|
sed -i 's/systemctl start promtail/systemctl start nz-promtail/g' $TALON_PATH/config/application-prod.yml
|
||||||
done
|
sed -i 's/systemctl stop promtail/systemctl stop nz-promtail/g' $TALON_PATH/config/application-prod.yml
|
||||||
# 恢复 promtail 配置文件
|
|
||||||
for n in $(ls $TMP_PATH/promtail);do
|
# promtail config
|
||||||
if [ -f "$PROMTAIL_PATH/$n" ];then
|
restoreComponentConfig $PROMTAIL_PATH $TMP_PATH/promtail
|
||||||
echo 'return config file '${n}
|
|
||||||
cp -f $TMP_PATH/promtail/$n $PROMTAIL_PATH/$n
|
# telegraf config
|
||||||
fi
|
if [ -d $TELEGRAF_PATH ];then
|
||||||
done
|
restoreComponentConfig $TELEGRAF_PATH $TMP_PATH/telegraf
|
||||||
|
restoreComponentConfig $TELEGRAF_PATH/telegraf.d $TMP_PATH/telegraf/telegraf.d
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fn_init_syslog_logrotate_config
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
systemctl restart nz-talon
|
systemctl restart nz-talon
|
||||||
systemctl restart promtail
|
systemctl enable crond && systemctl restart crond
|
||||||
|
systemctl enable rsyslog && systemctl restart rsyslog
|
||||||
|
|
||||||
|
# nz-promtail.service
|
||||||
|
if service_exists nz-promtail; then
|
||||||
|
systemctl restart nz-promtail
|
||||||
|
else
|
||||||
|
cat > /usr/lib/systemd/system/nz-promtail.service <<"EOF"
|
||||||
|
[Unit]
|
||||||
|
Description=nz-talon
|
||||||
|
After=network.target
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=/opt/nezha/promtail
|
||||||
|
EnvironmentFile=/opt/nezha/promtail/config.conf
|
||||||
|
ExecStart=/opt/nezha/promtail/promtail $OPTION
|
||||||
|
RestartSec=5s
|
||||||
|
Restart=always
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable nz-promtail && systemctl restart nz-promtail
|
||||||
|
fi
|
||||||
|
|
||||||
|
# nz-telegraf.service
|
||||||
|
if service_exists nz-telegraf; then
|
||||||
|
systemctl restart nz-telegraf
|
||||||
|
else
|
||||||
|
cat > /usr/lib/systemd/system/nz-telegraf.service <<"EOF"
|
||||||
|
[Unit]
|
||||||
|
Description=Telegraf
|
||||||
|
Documentation=https://github.com/influxdata/telegraf
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=/opt/nezha/telegraf
|
||||||
|
Type=notify
|
||||||
|
EnvironmentFile=/opt/nezha/telegraf/config.conf
|
||||||
|
ExecStart=/opt/nezha/telegraf/telegraf $OPTION
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
Restart=on-failure
|
||||||
|
RestartForceExitStatus=SIGPIPE
|
||||||
|
KillMode=control-group
|
||||||
|
LimitMEMLOCK=8M:8M
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable nz-telegraf && systemctl restart nz-telegraf
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,49 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
service_exists(){
|
||||||
|
local n=$1
|
||||||
|
if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | sed 's/^\s*//g' | cut -f1 -d' ') == $n.service ]]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ 0 -eq $1 ];then
|
if [ 0 -eq $1 ];then
|
||||||
|
|
||||||
echo 'start remove nz-talon module from disk...'
|
echo 'start remove nz-talon module from disk...'
|
||||||
|
|
||||||
systemctl stop nz-talon.service
|
systemctl stop nz-talon.service
|
||||||
systemctl stop promtail.service
|
systemctl stop nz-telegraf.service
|
||||||
|
|
||||||
rm -rf /opt/nezha/nz-talon
|
rm -rf /opt/nezha/nz-talon
|
||||||
rm -rf /opt/nezha/promtail
|
rm -rf /opt/nezha/telegraf
|
||||||
|
|
||||||
systemctl disable nz-talon.service
|
systemctl disable nz-talon.service
|
||||||
systemctl disable promtail.service
|
systemctl disable nz-telegraf.service
|
||||||
|
|
||||||
rm -rf /usr/lib/systemd/system/{nz-talon.service,promtail.service}
|
# promtail.service
|
||||||
|
if service_exists promtail; then
|
||||||
|
systemctl stop promtail.service
|
||||||
|
rm -rf /opt/nezha/promtail
|
||||||
|
systemctl disable promtail.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
# nz-promtail.service
|
||||||
|
if service_exists nz-promtail; then
|
||||||
|
systemctl stop nz-promtail.service
|
||||||
|
rm -rf /opt/nezha/promtail
|
||||||
|
systemctl disable nz-promtail.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf /usr/lib/systemd/system/{nz-talon.service,promtail.service,nz-promtail.service,nz-telegraf.service}
|
||||||
|
rm -rf /etc/rsyslog.d/{promtail.conf,telegraf.conf}
|
||||||
|
rm -rf /etc/logrotate.d/{promtail,telegraf}
|
||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
systemctl restart rsyslog
|
||||||
|
|
||||||
echo 'uninstall success!'
|
echo 'uninstall success!'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
TALON_PATH=/opt/nezha/nz-talon
|
TALON_PATH=/opt/nezha/nz-talon
|
||||||
PROMTAIL_PATH=/opt/nezha/promtail
|
PROMTAIL_PATH=/opt/nezha/promtail
|
||||||
|
TELEGRAF_PATH=/opt/nezha/telegraf
|
||||||
|
|
||||||
|
|
||||||
|
service_exists(){
|
||||||
|
local n=$1
|
||||||
|
if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | sed 's/^\s*//g' | cut -f1 -d' ') == $n.service ]]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if [ 2 -eq $1 ];then
|
if [ 2 -eq $1 ];then
|
||||||
|
|
||||||
@@ -10,23 +22,47 @@ if [ 2 -eq $1 ];then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl stop nz-talon
|
systemctl stop nz-talon
|
||||||
systemctl stop promtail
|
|
||||||
|
# nz-telegraf.service
|
||||||
|
if service_exists nz-telegraf; then
|
||||||
|
systemctl stop nz-telegraf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# promtail.service, deprecated
|
||||||
|
if service_exists promtail; then
|
||||||
|
systemctl stop promtail
|
||||||
|
systemctl disable promtail
|
||||||
|
rm /usr/lib/systemd/system/promtail.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl reset-failed
|
||||||
|
fi
|
||||||
|
|
||||||
|
# nz-promtail.service
|
||||||
|
if service_exists nz-promtail; then
|
||||||
|
systemctl stop nz-promtail
|
||||||
|
fi
|
||||||
|
|
||||||
TMP_PATH=/tmp/nezha/nz-talon
|
TMP_PATH=/tmp/nezha/nz-talon
|
||||||
rm -rf $TMP_PATH
|
rm -rf $TMP_PATH
|
||||||
|
|
||||||
mkdir -p $TMP_PATH
|
mkdir -p $TMP_PATH
|
||||||
mkdir -p $TMP_PATH/promtail
|
mkdir -p $TMP_PATH/promtail
|
||||||
|
mkdir -p $TMP_PATH/telegraf
|
||||||
|
|
||||||
cp -rf $TALON_PATH/config $TMP_PATH
|
cp -rf $TALON_PATH/config $TMP_PATH
|
||||||
[ -f "$PROMTAIL_PATH/promtail.yaml" ] && cp -rf $PROMTAIL_PATH/promtail.yaml $TMP_PATH/promtail
|
[ -f "$PROMTAIL_PATH/promtail.yaml" ] && cp -rf $PROMTAIL_PATH/promtail.yaml $TMP_PATH/promtail
|
||||||
[ -f "$PROMTAIL_PATH/config.conf" ] && cp -rf $PROMTAIL_PATH/config.conf $TMP_PATH/promtail
|
[ -f "$PROMTAIL_PATH/config.conf" ] && cp -rf $PROMTAIL_PATH/config.conf $TMP_PATH/promtail
|
||||||
|
|
||||||
|
[ -f "$TELEGRAF_PATH/config.conf" ] && cp -rf $TELEGRAF_PATH/config.conf $TMP_PATH/telegraf
|
||||||
|
[ -f "$TELEGRAF_PATH/telegraf.conf" ] && cp -rf $TELEGRAF_PATH/telegraf.conf $TMP_PATH/telegraf
|
||||||
|
[ -d "$TELEGRAF_PATH/telegraf.d" ] && cp -rf $TELEGRAF_PATH/telegraf.d $TMP_PATH/telegraf
|
||||||
echo 'backup config file from '${TALON_PATH}
|
echo 'backup config file from '${TALON_PATH}
|
||||||
|
|
||||||
if [ 0 -lt $(rpm -aq nz-talon|wc -w) ];then
|
if [ 0 -lt $(rpm -aq nz-talon|wc -w) ];then
|
||||||
echo 'clean before install...'
|
echo 'clean before install...'
|
||||||
rm -rf $TALON_PATH
|
rm -rf $TALON_PATH
|
||||||
rm -rf $PROMTAIL_PATH
|
rm -rf $PROMTAIL_PATH
|
||||||
|
rm -rf $TELEGRAF_PATH
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ if [[ "${BRANCH_ARRAY[0]}" == "rel" ]] ; then
|
|||||||
fi
|
fi
|
||||||
RPM_FULL_NAME=${PACKAGE_NAME}-${PACKAGE_VERSION}-${ITERATION}.x86_64.rpm
|
RPM_FULL_NAME=${PACKAGE_NAME}-${PACKAGE_VERSION}-${ITERATION}.x86_64.rpm
|
||||||
|
|
||||||
|
# 依赖jdk 文件名
|
||||||
|
JDK_FILENAME=openjdk-21_linux-x64_bin.tar.gz
|
||||||
|
|
||||||
# 初始化 minio
|
# 初始化 minio
|
||||||
mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD
|
mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD
|
||||||
@@ -19,11 +21,20 @@ mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD
|
|||||||
BUILD_PATH=$CUR_PWD/build
|
BUILD_PATH=$CUR_PWD/build
|
||||||
RPM_TALON_PATH=$BUILD_PATH/opt/nezha/nz-talon
|
RPM_TALON_PATH=$BUILD_PATH/opt/nezha/nz-talon
|
||||||
RPM_PROMTAIL_PATH=$BUILD_PATH/opt/nezha/promtail
|
RPM_PROMTAIL_PATH=$BUILD_PATH/opt/nezha/promtail
|
||||||
|
RPM_TELEGRAF_PATH=$BUILD_PATH/opt/nezha/telegraf
|
||||||
|
RPM_JDK_PATH=$RPM_TALON_PATH/jdk
|
||||||
|
|
||||||
mkdir -p $RPM_TALON_PATH $RPM_PROMTAIL_PATH
|
mkdir -p $RPM_TALON_PATH $RPM_PROMTAIL_PATH $RPM_TELEGRAF_PATH
|
||||||
mkdir -p $RPM_TALON_PATH/config
|
mkdir -p $RPM_TALON_PATH/config
|
||||||
|
mkdir -p $RPM_JDK_PATH
|
||||||
|
|
||||||
echo 'packaging nz-talon ...'
|
echo 'packaging nz-talon ...'
|
||||||
|
#添加版本信息
|
||||||
|
cat >./src/main/resources/version.properties<<EOF
|
||||||
|
version=${BRANCH_ARRAY[1]}
|
||||||
|
commit=$CI_COMMIT_SHORT_SHA
|
||||||
|
buildDate=`date +'%Y%m%d%H%m%S'`
|
||||||
|
EOF
|
||||||
# mvn 编译 nz-talon
|
# mvn 编译 nz-talon
|
||||||
mvn clean install -Dxjar.password=111111 -Dxjar.excludes=/db/*,/static/**/*
|
mvn clean install -Dxjar.password=111111 -Dxjar.excludes=/db/*,/static/**/*
|
||||||
cd ./target && go build xjar.go
|
cd ./target && go build xjar.go
|
||||||
@@ -35,13 +46,25 @@ cp -f ./target/xjar $RPM_TALON_PATH
|
|||||||
cp -f ./src/main/resources/{application-prod.yml,application.yml,logback-spring.xml,config/auth.yml,config/token.auth,config/promtail.version} ${RPM_TALON_PATH}/config
|
cp -f ./src/main/resources/{application-prod.yml,application.yml,logback-spring.xml,config/auth.yml,config/token.auth,config/promtail.version} ${RPM_TALON_PATH}/config
|
||||||
sed -i 's/<property name="log.path" value=".*"/<property name="log.path" value="\/var\/log\/nezha\/nz-talon\/"/g' ${RPM_TALON_PATH}/config/logback-spring.xml
|
sed -i 's/<property name="log.path" value=".*"/<property name="log.path" value="\/var\/log\/nezha\/nz-talon\/"/g' ${RPM_TALON_PATH}/config/logback-spring.xml
|
||||||
|
|
||||||
|
# 准备 jdk 编译目录
|
||||||
|
mc cp nz/depends/jdk/$JDK_FILENAME ./
|
||||||
|
tar -xzf ./$JDK_FILENAME --strip-components 1 -C $RPM_JDK_PATH
|
||||||
|
|
||||||
# 下载 promtail
|
# 下载 promtail
|
||||||
mc cp nz/depends/loki/promtail-linux-amd64.zip ./
|
mc cp nz/depends/loki/promtail-2.9.0.linux-amd64.zip ./
|
||||||
unzip -o promtail-linux-amd64.zip -d $RPM_PROMTAIL_PATH
|
unzip -o promtail-2.9.0.linux-amd64.zip -d $RPM_PROMTAIL_PATH
|
||||||
mv $RPM_PROMTAIL_PATH/promtail-linux-amd64 $RPM_PROMTAIL_PATH/promtail
|
mv $RPM_PROMTAIL_PATH/promtail-linux-amd64 $RPM_PROMTAIL_PATH/promtail
|
||||||
cp -f ./tools/config.conf $RPM_PROMTAIL_PATH
|
cp -f ./tools/config.conf $RPM_PROMTAIL_PATH
|
||||||
cp -f ./tools/promtail.yaml $RPM_PROMTAIL_PATH
|
cp -f ./tools/promtail.yaml $RPM_PROMTAIL_PATH
|
||||||
|
|
||||||
|
# telegraf
|
||||||
|
mc cp nz/depends/telegraf/telegraf-1.26.2.tar.gz ./
|
||||||
|
tar -xzf telegraf-1.26.2.tar.gz -C $RPM_TELEGRAF_PATH
|
||||||
|
cat > $RPM_TELEGRAF_PATH/config.conf <<EOF
|
||||||
|
OPTION=" -config /opt/nezha/telegraf/telegraf.conf -config-directory /opt/nezha/telegraf/telegraf.d "
|
||||||
|
EOF
|
||||||
|
cp -f ./tools/telegraf.conf $RPM_TELEGRAF_PATH
|
||||||
|
cp -rf ./tools/telegraf.d $RPM_TELEGRAF_PATH
|
||||||
|
|
||||||
#修改日志地址 2021_08_26
|
#修改日志地址 2021_08_26
|
||||||
sed -i 's/<property name="log.path" value=".*"/<property name="log.path" value="\/var\/log\/nezha\/nz-talon\/"/g' ${RPM_TALON_PATH}/config/logback-spring.xml
|
sed -i 's/<property name="log.path" value=".*"/<property name="log.path" value="\/var\/log\/nezha\/nz-talon\/"/g' ${RPM_TALON_PATH}/config/logback-spring.xml
|
||||||
|
|||||||
24
tools/telegraf.conf
Normal file
24
tools/telegraf.conf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Configuration for the Prometheus client to spawn
|
||||||
|
[[outputs.prometheus_client]]
|
||||||
|
## Address to listen on.
|
||||||
|
listen = ":19273"
|
||||||
|
namepass = ["cpu", "disk", "diskio", "mem", "net", "processes", "swap", "system", "systemd_units", "kernel"]
|
||||||
|
## Metric version controls the mapping from Prometheus metrics into Telegraf metrics.
|
||||||
|
## See "Metric Format Configuration" in plugins/inputs/prometheus/README.md for details.
|
||||||
|
## Valid options: 1, 2
|
||||||
|
# metric_version = 1 ## Use HTTP Basic Authentication.
|
||||||
|
# basic_username = "Foo"
|
||||||
|
# basic_password = "Bar" ## If set, the IP Ranges which are allowed to access metrics.
|
||||||
|
## ex: ip_range = ["192.168.0.0/24", "192.168.1.0/30"]
|
||||||
|
# ip_range = [] ## Path to publish the metrics on.
|
||||||
|
# path = "/metrics" ## Expiration interval for each metric. 0 == no expiration
|
||||||
|
# expiration_interval = "60s" ## Collectors to enable, valid entries are "gocollector" and "process".
|
||||||
|
## If unset, both are enabled.
|
||||||
|
# collectors_exclude = ["gocollector", "process"] ## Send string metrics as Prometheus labels.
|
||||||
|
## Unless set to false all string metrics will be sent as labels.
|
||||||
|
# string_as_label = true ## If set, enable TLS with the given certificate.
|
||||||
|
# tls_cert = "/etc/ssl/telegraf.crt"
|
||||||
|
# tls_key = "/etc/ssl/telegraf.key" ## Set one or more allowed client CA certificate file names to
|
||||||
|
## enable mutually authenticated TLS connections
|
||||||
|
# tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"] ## Export metric collection time.
|
||||||
|
# export_timestamp = false
|
||||||
12
tools/telegraf.d/cpu.conf
Normal file
12
tools/telegraf.d/cpu.conf
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Read metrics about cpu usage
|
||||||
|
[[inputs.cpu]]
|
||||||
|
## Whether to report per-cpu stats or not
|
||||||
|
percpu = true
|
||||||
|
## Whether to report total system cpu stats or not
|
||||||
|
totalcpu = true
|
||||||
|
## If true, collect raw CPU time metrics
|
||||||
|
collect_cpu_time = false
|
||||||
|
## If true, compute and report the sum of all non-idle CPU states
|
||||||
|
report_active = false
|
||||||
|
## If true and the info is available then add core_id and physical_id tags
|
||||||
|
core_tags = false
|
||||||
13
tools/telegraf.d/disk.conf
Normal file
13
tools/telegraf.d/disk.conf
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Read metrics about disk usage by mount point
|
||||||
|
[[inputs.disk]]
|
||||||
|
## By default stats will be gathered for all mount points.
|
||||||
|
## Set mount_points will restrict the stats to only the specified mount points.
|
||||||
|
# mount_points = ["/"]
|
||||||
|
|
||||||
|
## Ignore mount points by filesystem type.
|
||||||
|
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
|
||||||
|
|
||||||
|
## Ignore mount points by mount options.
|
||||||
|
## The 'mount' command reports options of all mounts in parathesis.
|
||||||
|
## Bind mounts can be ignored with the special 'bind' option.
|
||||||
|
# ignore_mount_opts = []
|
||||||
30
tools/telegraf.d/diskio.conf
Normal file
30
tools/telegraf.d/diskio.conf
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Read metrics about disk IO by device
|
||||||
|
# This plugin ONLY supports Linux
|
||||||
|
[[inputs.diskio]]
|
||||||
|
## By default, telegraf will gather stats for all devices including
|
||||||
|
## disk partitions.
|
||||||
|
## Setting devices will restrict the stats to the specified devices.
|
||||||
|
## NOTE: Globbing expressions (e.g. asterix) are not supported for
|
||||||
|
## disk synonyms like '/dev/disk/by-id'.
|
||||||
|
# devices = ["sda", "sdb", "vd*", "/dev/disk/by-id/nvme-eui.00123deadc0de123"]
|
||||||
|
## Uncomment the following line if you need disk serial numbers.
|
||||||
|
# skip_serial_number = false
|
||||||
|
#
|
||||||
|
## On systems which support it, device metadata can be added in the form of
|
||||||
|
## tags.
|
||||||
|
## Currently only Linux is supported via udev properties. You can view
|
||||||
|
## available properties for a device by running:
|
||||||
|
## 'udevadm info -q property -n /dev/sda'
|
||||||
|
## Note: Most, but not all, udev properties can be accessed this way. Properties
|
||||||
|
## that are currently inaccessible include DEVTYPE, DEVNAME, and DEVPATH.
|
||||||
|
# device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"]
|
||||||
|
#
|
||||||
|
## Using the same metadata source as device_tags, you can also customize the
|
||||||
|
## name of the device via templates.
|
||||||
|
## The 'name_templates' parameter is a list of templates to try and apply to
|
||||||
|
## the device. The template may contain variables in the form of '$PROPERTY' or
|
||||||
|
## '${PROPERTY}'. The first template which does not contain any variables not
|
||||||
|
## present for the device is used as the device name tag.
|
||||||
|
## The typical use case is for LVM volumes, to get the VG/LV name instead of
|
||||||
|
## the near-meaningless DM-0 name.
|
||||||
|
# name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"]
|
||||||
4
tools/telegraf.d/kernel.conf
Normal file
4
tools/telegraf.d/kernel.conf
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Get kernel statistics from /proc/stat
|
||||||
|
# This plugin ONLY supports Linux
|
||||||
|
[[inputs.kernel]]
|
||||||
|
# no configuration
|
||||||
3
tools/telegraf.d/mem.conf
Normal file
3
tools/telegraf.d/mem.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Read metrics about memory usage
|
||||||
|
[[inputs.mem]]
|
||||||
|
# no configuration
|
||||||
14
tools/telegraf.d/net.conf
Normal file
14
tools/telegraf.d/net.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Gather metrics about network interfaces
|
||||||
|
[[inputs.net]]
|
||||||
|
## By default, telegraf gathers stats from any up interface (excluding loopback)
|
||||||
|
## Setting interfaces will tell it to gather these explicit interfaces,
|
||||||
|
## regardless of status. When specifying an interface, glob-style
|
||||||
|
## patterns are also supported.
|
||||||
|
##
|
||||||
|
# interfaces = ["eth*", "enp0s[0-1]", "lo"]
|
||||||
|
##
|
||||||
|
## On linux systems telegraf also collects protocol stats.
|
||||||
|
## Setting ignore_protocol_stats to true will skip reporting of protocol metrics.
|
||||||
|
##
|
||||||
|
# ignore_protocol_stats = false
|
||||||
|
##
|
||||||
6
tools/telegraf.d/processes.conf
Normal file
6
tools/telegraf.d/processes.conf
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Get the number of processes and group them by status
|
||||||
|
# This plugin ONLY supports non-Windows
|
||||||
|
[[inputs.processes]]
|
||||||
|
## Use sudo to run ps command on *BSD systems. Linux systems will read
|
||||||
|
## /proc, so this does not apply there.
|
||||||
|
use_sudo = false
|
||||||
3
tools/telegraf.d/swap.conf
Normal file
3
tools/telegraf.d/swap.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Read metrics about swap memory usage
|
||||||
|
[[inputs.swap]]
|
||||||
|
# no configuration
|
||||||
3
tools/telegraf.d/system.conf
Normal file
3
tools/telegraf.d/system.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Read metrics about system load & uptime
|
||||||
|
[[inputs.system]]
|
||||||
|
# no configuration
|
||||||
16
tools/telegraf.d/systemd_units.conf
Normal file
16
tools/telegraf.d/systemd_units.conf
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Gather systemd units state
|
||||||
|
[[inputs.systemd_units]]
|
||||||
|
## Set timeout for systemctl execution
|
||||||
|
# timeout = "1s"
|
||||||
|
#
|
||||||
|
## Filter for a specific unit type, default is "service", other possible
|
||||||
|
## values are "socket", "target", "device", "mount", "automount", "swap",
|
||||||
|
## "timer", "path", "slice" and "scope ":
|
||||||
|
# unittype = "service"
|
||||||
|
#
|
||||||
|
## Filter for a specific pattern, default is "" (i.e. all), other possible
|
||||||
|
## values are valid pattern for systemctl, e.g. "a*" for all units with
|
||||||
|
## names starting with "a"
|
||||||
|
# pattern = ""
|
||||||
|
## pattern = "telegraf* influxdb*"
|
||||||
|
## pattern = "a*"
|
||||||
Reference in New Issue
Block a user