diff --git a/logmngr/Makefile b/logmngr/Makefile index 8a1bbf84a..566769bda 100644 --- a/logmngr/Makefile +++ b/logmngr/Makefile @@ -65,8 +65,10 @@ define Package/logmngr/install $(INSTALL_DIR) $(1)/lib/logmngr ifeq ($(CONFIG_LOGMNGR_BACKEND_FLUENTBIT),y) $(INSTALL_DIR) $(1)/sbin + $(INSTALL_DIR) $(1)/etc/hotplug.d/ntp/ $(INSTALL_BIN) ./files/logread $(1)/sbin/ $(INSTALL_DATA) ./files/lib/logmngr/fluent-bit.sh $(1)/lib/logmngr/ + $(INSTALL_BIN) ./files/etc/hotplug.d/ntp/45-reload_fluent_bit $(1)/etc/hotplug.d/ntp/ else ifeq ($(CONFIG_LOGMNGR_BACKEND_SYSLOG_NG),y) $(INSTALL_DATA) ./files/lib/logmngr/syslog-ng.sh $(1)/lib/logmngr/ endif diff --git a/logmngr/files/etc/hotplug.d/ntp/20-reload_fluent_bit b/logmngr/files/etc/hotplug.d/ntp/20-reload_fluent_bit new file mode 100644 index 000000000..8e5469b39 --- /dev/null +++ b/logmngr/files/etc/hotplug.d/ntp/20-reload_fluent_bit @@ -0,0 +1,14 @@ +#!/bin/sh +# This hotplug script reloads fluent-bit, so that kmsg logs' timestamp gets in sync + +[ "$ACTION" = stratum ] || exit 0 + +# only once +if ! uci -q get time.global.first_use_date > /dev/null 2>&1; then + flb_pid="$(pidof fluent-bit)" + + if [ -n "$flb_pid" ]; then + logger -t "logmngr.hotplug" -p info "reload fluent-bit due to ntp sync" + kill -SIGHUP "$flb_pid" + fi +fi