|
|
|
|
@@ -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
|
|
|
|
|
|