Compare commits
19 Commits
rel-22.07.
...
dev-3.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6edf086b06 | ||
|
|
bff7a87e51 | ||
|
|
c6efffee85 | ||
|
|
8e7b0c7940 | ||
|
|
b6b925644f | ||
|
|
d07d63fa64 | ||
|
|
5f7d1942ed | ||
|
|
a81ebe861f | ||
|
|
c011b6b548 | ||
|
|
d47d736df9 | ||
|
|
55e9084a46 | ||
|
|
de3347b3c5 | ||
|
|
27f46633fc | ||
|
|
bdede80059 | ||
|
|
12a9e25835 | ||
|
|
77394e8ab9 | ||
|
|
128d4f8418 | ||
|
|
d23a48be48 | ||
|
|
e70e687298 |
@@ -2,7 +2,7 @@
|
||||
image: git.mesalab.cn:7443/nezha/nz-build-env:1.3
|
||||
# 定义全局变量
|
||||
variables:
|
||||
MINIO_HOST: 'http://192.168.41.160:2020/'
|
||||
MINIO_HOST: 'http://192.168.40.48:2020/'
|
||||
MINIO_USER: 'admin'
|
||||
MINIO_PWD: "Nezha@02!"
|
||||
MAVEN_REPO: "/etc/maven/repository/"
|
||||
@@ -55,8 +55,19 @@ dev_build:
|
||||
script:
|
||||
- env | sort
|
||||
- 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/**/*
|
||||
- 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
|
||||
- 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
|
||||
- cd ../
|
||||
artifacts:
|
||||
name: "$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
|
||||
when: on_success
|
||||
|
||||
24
pom.xml
24
pom.xml
@@ -121,7 +121,17 @@
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<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>
|
||||
<id>public</id>
|
||||
@@ -149,7 +159,17 @@
|
||||
<pluginRepository>
|
||||
<id>nexus</id>
|
||||
<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>
|
||||
<id>public</id>
|
||||
|
||||
@@ -40,16 +40,16 @@ public class PromtailController extends BaseController{
|
||||
@Value("${confagent.promtail.query.auth:true}")
|
||||
private Boolean queryAuth;
|
||||
|
||||
@Value("${confagent.promtail.restart:systemctl restart promtail}")
|
||||
@Value("${confagent.promtail.restart:systemctl restart nz-promtail}")
|
||||
private String restartCmd;
|
||||
|
||||
@Value("${confagent.versionFile:promtail.version}")
|
||||
private String versionFile;
|
||||
|
||||
@Value("${confagent.promtail.startCmd:systemctl start promtail.service}")
|
||||
@Value("${confagent.promtail.startCmd:systemctl start nz-promtail.service}")
|
||||
private String startCmd;
|
||||
|
||||
@Value("${confagent.promtail.stopCmd:systemctl stop promtail.service}")
|
||||
@Value("${confagent.promtail.stopCmd:systemctl stop nz-promtail.service}")
|
||||
private String stopCmd;
|
||||
|
||||
private final String[] QUERY_API_SUFFIX = {"query","query_range","series","labels","label","values"};
|
||||
|
||||
@@ -163,6 +163,7 @@ public class OSHIUtils {
|
||||
procsData.put("path",proc.getPath());
|
||||
procsData.put("virtualSize",proc.getVirtualSize());
|
||||
procsData.put("residentSetSize",proc.getResidentSetSize());
|
||||
procsData.put("runTime",proc.getUpTime());
|
||||
result.add(procsData);
|
||||
}
|
||||
|
||||
@@ -208,11 +209,13 @@ public class OSHIUtils {
|
||||
map.put("receiveQueue",connection.getReceiveQueue());
|
||||
if (connection.getowningProcessId() == -1 ){
|
||||
//未知进程 getowningProcessId 返回 -1 为避免获取进程name error
|
||||
map.put("processId","unknown");
|
||||
map.put("processName","unknown");
|
||||
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);
|
||||
|
||||
@@ -3,8 +3,8 @@ confagent:
|
||||
cmdLine: /opt/nezha/promtail/config.conf
|
||||
config: /opt/nezha/promtail/promtail.yaml
|
||||
defaultIP: 127.0.0.1
|
||||
startCmd: systemctl start promtail
|
||||
stopCmd: systemctl stop promtail
|
||||
startCmd: systemctl start nz-promtail
|
||||
stopCmd: systemctl stop nz-promtail
|
||||
|
||||
logging:
|
||||
config: config/logback-spring.xml
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
<configuration scan="true" scanPeriod="60 seconds">
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||
<logger name="org.springframework.web" level="info" />
|
||||
<logger name="org.springboot.sample" level="info" />
|
||||
<logger name="org.apache" level="info" />
|
||||
<logger name="org.apache" level="warn" />
|
||||
<logger name="org.springframework" level="info" />
|
||||
<logger name="druid.sql" level="info" />
|
||||
<logger name="com.springboot" level="debug" />
|
||||
|
||||
<property name="log.path" value="./logs/" />
|
||||
<!-- 输出格式 -->
|
||||
@@ -65,4 +63,4 @@
|
||||
<appender-ref ref="ERROR_FILE" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
||||
@@ -1,7 +1,59 @@
|
||||
#!/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
|
||||
}
|
||||
|
||||
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
|
||||
if [ -f $1/${i} ];then
|
||||
echo 'return config file '$1/${i}
|
||||
cp -f $2/$i $1/$i
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 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"
|
||||
elif type -p java > /dev/null 2>&1; then
|
||||
JAVA_EXE=$(type -p java)
|
||||
@@ -28,7 +80,7 @@ Restart=always
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
cat > /usr/lib/systemd/system/promtail.service <<"EOF"
|
||||
cat > /usr/lib/systemd/system/nz-promtail.service <<"EOF"
|
||||
[Unit]
|
||||
Description=nz-talon
|
||||
After=network.target
|
||||
@@ -38,56 +90,116 @@ EnvironmentFile=/opt/nezha/promtail/config.conf
|
||||
ExecStart=/opt/nezha/promtail/promtail $OPTION
|
||||
RestartSec=5s
|
||||
Restart=always
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
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
|
||||
|
||||
systemctl daemon-reload
|
||||
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
|
||||
echo 'install nz-talon success !'
|
||||
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
|
||||
if [ 2 -eq $1 ];then
|
||||
TALON_PATH=/opt/nezha/nz-talon
|
||||
TMP_PATH=/tmp/nezha/nz-talon
|
||||
PROMTAIL_PATH=/opt/nezha/promtail
|
||||
TELEGRAF_PATH=/opt/nezha/telegraf
|
||||
echo 'move backup config file...'
|
||||
if [ -d $TMP_PATH ];then
|
||||
# 恢复 nz-talon 配置文件
|
||||
for i in $(ls $TALON_PATH/config);do
|
||||
if [ 1 -eq `compareMD5 $WEB_PATH/config/$i $TMP_PATH/config/$i` ];then
|
||||
echo 'return config file '${i}
|
||||
cp -f $TMP_PATH/config/$i $TALON_PATH/config/$i
|
||||
fi
|
||||
done
|
||||
# 恢复 promtail 配置文件
|
||||
for n in $(ls $TMP_PATH/promtail);do
|
||||
if [ -f "$PROMTAIL_PATH/$n" ];then
|
||||
echo 'return config file '${n}
|
||||
cp -f $TMP_PATH/promtail/$n $PROMTAIL_PATH/$n
|
||||
fi
|
||||
done
|
||||
# nz-talon config
|
||||
restoreComponentConfig $TALON_PATH/config $TMP_PATH/config
|
||||
|
||||
# promtail.service 名称改为 nz-promtail.service
|
||||
# 这里重新替换下 application-prod.yml 中的 systemctl start|stop promtail 命令
|
||||
sed -i 's/systemctl start promtail/systemctl start nz-promtail/g' $TALON_PATH/config/application-prod.yml
|
||||
sed -i 's/systemctl stop promtail/systemctl stop nz-promtail/g' $TALON_PATH/config/application-prod.yml
|
||||
|
||||
# promtail config
|
||||
restoreComponentConfig $PROMTAIL_PATH $TMP_PATH/promtail
|
||||
|
||||
# telegraf config
|
||||
if [ -d $TELEGRAF_PATH ];then
|
||||
restoreComponentConfig $TELEGRAF_PATH $TMP_PATH/telegraf
|
||||
restoreComponentConfig $TELEGRAF_PATH/telegraf.d $TMP_PATH/telegraf/telegraf.d
|
||||
fi
|
||||
fi
|
||||
systemctl restart nz-talon
|
||||
systemctl restart promtail
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
@@ -1,20 +1,46 @@
|
||||
#!/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
|
||||
|
||||
echo 'start remove nz-talon module from disk...'
|
||||
|
||||
systemctl stop nz-talon.service
|
||||
systemctl stop promtail.service
|
||||
systemctl stop nz-telegraf.service
|
||||
|
||||
rm -rf /opt/nezha/nz-talon
|
||||
rm -rf /opt/nezha/promtail
|
||||
rm -rf /opt/nezha/telegraf
|
||||
|
||||
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}
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
echo 'uninstall success!'
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,18 @@
|
||||
|
||||
TALON_PATH=/opt/nezha/nz-talon
|
||||
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
|
||||
|
||||
@@ -10,23 +22,47 @@ if [ 2 -eq $1 ];then
|
||||
fi
|
||||
|
||||
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
|
||||
rm -rf $TMP_PATH
|
||||
|
||||
mkdir -p $TMP_PATH
|
||||
mkdir -p $TMP_PATH/promtail
|
||||
mkdir -p $TMP_PATH/telegraf
|
||||
|
||||
cp -rf $TALON_PATH/config $TMP_PATH
|
||||
[ -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 "$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}
|
||||
|
||||
if [ 0 -lt $(rpm -aq nz-talon|wc -w) ];then
|
||||
echo 'clean before install...'
|
||||
rm -rf $TALON_PATH
|
||||
rm -rf $PROMTAIL_PATH
|
||||
rm -rf $TELEGRAF_PATH
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ if [[ "${BRANCH_ARRAY[0]}" == "rel" ]] ; then
|
||||
fi
|
||||
RPM_FULL_NAME=${PACKAGE_NAME}-${PACKAGE_VERSION}-${ITERATION}.x86_64.rpm
|
||||
|
||||
# 依赖jdk 文件名
|
||||
JDK_FILENAME=jdk-8u202-linux-x64.tar.gz
|
||||
|
||||
# 初始化 minio
|
||||
mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD
|
||||
@@ -19,9 +21,12 @@ mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD
|
||||
BUILD_PATH=$CUR_PWD/build
|
||||
RPM_TALON_PATH=$BUILD_PATH/opt/nezha/nz-talon
|
||||
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_JDK_PATH
|
||||
|
||||
echo 'packaging nz-talon ...'
|
||||
#添加版本信息
|
||||
@@ -41,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
|
||||
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
|
||||
mc cp nz/depends/loki/promtail-linux-amd64.zip ./
|
||||
unzip -o promtail-linux-amd64.zip -d $RPM_PROMTAIL_PATH
|
||||
mc cp nz/depends/loki/promtail-2.9.0.linux-amd64.zip ./
|
||||
unzip -o promtail-2.9.0.linux-amd64.zip -d $RPM_PROMTAIL_PATH
|
||||
mv $RPM_PROMTAIL_PATH/promtail-linux-amd64 $RPM_PROMTAIL_PATH/promtail
|
||||
cp -f ./tools/config.conf $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
|
||||
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