feat: NEZ-3158 nz-talon 内置组件增加 rsyslog&logrotate 配置
This commit is contained in:
@@ -12,6 +12,45 @@ service_exists(){
|
||||
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
|
||||
@@ -116,10 +155,14 @@ LimitMEMLOCK=8M:8M
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
fn_init_syslog_logrotate_config
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable nz-talon && systemctl restart nz-talon
|
||||
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 !'
|
||||
fi
|
||||
|
||||
@@ -148,7 +191,13 @@ if [ 2 -eq $1 ];then
|
||||
restoreComponentConfig $TELEGRAF_PATH/telegraf.d $TMP_PATH/telegraf/telegraf.d
|
||||
fi
|
||||
fi
|
||||
|
||||
fn_init_syslog_logrotate_config
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl restart nz-talon
|
||||
systemctl enable crond && systemctl restart crond
|
||||
systemctl enable rsyslog && systemctl restart rsyslog
|
||||
|
||||
# nz-promtail.service
|
||||
if service_exists nz-promtail; then
|
||||
|
||||
@@ -37,8 +37,11 @@ if [ 0 -eq $1 ];then
|
||||
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 restart rsyslog
|
||||
|
||||
echo 'uninstall success!'
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user