logmngr: reload fluent-bit on ntp sync event (via hotplug)

(cherry picked from commit bdc435c392)

Co-authored-by: Mohd Husaam Mehdi <husaam.mehdi@iopsys.eu>
This commit is contained in:
Vivek Dutta 2025-12-04 19:41:25 +05:30 committed by IOPSYS Dev
parent 9bb0da51cf
commit 362bb8b1cf
No known key found for this signature in database
2 changed files with 16 additions and 0 deletions

View file

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

View file

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