Merge branch 'logmngr' into 'devel'

logmngr: config option to run with single instance

See merge request feed/iopsys!2115
This commit is contained in:
Vivek Dutta 2026-03-05 16:54:43 +05:30 committed by IOPSYS Dev
commit fd82cd615b
No known key found for this signature in database
5 changed files with 73 additions and 47 deletions

View file

@ -40,4 +40,11 @@ config LOGMNGR_VENDOR_LOG_FILE
help
It adds support for Device.DeviceInfo.VendorLogFile. Object.
config LOGMNGR_SINGLE_INSTANCE
bool "Run all local and remote log instances together"
depends on PACKAGE_logmngr
default y
help
Run a single instance of logmngr backend to optimize ram usages
endif

View file

@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=logmngr
PKG_VERSION:=1.1.5
PKG_VERSION:=1.1.6
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
@ -18,6 +18,7 @@ endif
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=LICENSE
PKG_CONFIG_DEPENDS:CONFIG_LOGMNGR_BACKEND_FLUENTBIT CONFIG_LOGMNGR_BACKEND_SYSLOG_NG CONFIG_LOGMNGR_SINGLE_INSTANCE
include $(INCLUDE_DIR)/package.mk
include ../bbfdm/bbfdm.mk
@ -55,7 +56,6 @@ define Package/logmngr/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/etc/init.d/logmngr $(1)/etc/init.d/
$(INSTALL_DATA) ./files/etc/config/logmngr $(1)/etc/config/
$(INSTALL_DATA) ./files/etc/uci-defaults/10-logmngr_config_migrate $(1)/etc/uci-defaults/
@ -64,19 +64,23 @@ ifeq ($(CONFIG_LOGMNGR_SYSLOG),y)
$(BBFDM_INSTALL_MS_DM) $(PKG_BUILD_DIR)/bbf_plugin/libbbfsyslog.so $(1) $(PKG_NAME)
endif
ifeq ($(CONFIG_LOGMNGR_SINGLE_INSTANCE),y)
$(INSTALL_DIR) $(1)/etc/logmngr
touch $(1)/etc/logmngr/.SingleInstance
endif
# Install logmngr service backend
$(INSTALL_DIR) $(1)/lib/logmngr
ifeq ($(CONFIG_LOGMNGR_BACKEND_FLUENTBIT),y)
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_DIR) $(1)/etc/fluent-bit
$(INSTALL_DIR) $(1)/etc/hotplug.d/ntp/
$(INSTALL_BIN) ./files/etc/fluent-bit/syslog_facility.lua $(1)/etc/fluent-bit/syslog_facility.lua
$(INSTALL_BIN) ./files/logread $(1)/sbin/
$(INSTALL_DATA) ./files/lib/logmngr/fluent-bit.sh $(1)/lib/logmngr/
$(INSTALL_BIN) ./files/etc/init.d/logmngr_fluent-bit $(1)/etc/init.d/logmngr
$(INSTALL_BIN) ./files/etc/hotplug.d/ntp/20-reload_fluent_bit $(1)/etc/hotplug.d/ntp/
$(INSTALL_DATA) ./files/etc/uci-defaults/20-add-parser $(1)/etc/uci-defaults/
else ifeq ($(CONFIG_LOGMNGR_BACKEND_SYSLOG_NG),y)
$(INSTALL_DATA) ./files/lib/logmngr/syslog-ng.sh $(1)/lib/logmngr/
$(INSTALL_DATA) ./files/etc/init.d/logmngr_syslog-ng $(1)/etc/init.d/logmngr
endif
ifeq ($(CONFIG_LOGMNGR_LOGROTATE),y)

View file

@ -1,16 +0,0 @@
#!/bin/sh /etc/rc.common
START=09
USE_PROCD=1
. /lib/functions.sh
include /lib/logmngr
start_service() {
logmngr_init
}
service_triggers() {
procd_add_reload_trigger logmngr
}

View file

@ -1,4 +1,8 @@
#!/bin/sh
#!/bin/sh /etc/rc.common
START=09
USE_PROCD=1
. /lib/functions.sh
@ -7,6 +11,7 @@ CONF_FILE=/etc/fluent-bit/fluent-bit.conf
FLUENT_BIT_TMP_DIR=/tmp/fluent-bit
MAIN_CONF="${FLUENT_BIT_TMP_DIR}/main.fluent-bit.conf"
USER_CONF="${FLUENT_BIT_TMP_DIR}/user.fluent-bit.conf"
SINGLE_INSTANCE_MARKER="/etc/logmngr/.SingleInstance"
# in future if USER_TAG has to be changed
# we will need to check that no file in FLUENT_BIT_CONF_DIR uses it
USER_TAG="user_logs"
@ -82,14 +87,25 @@ create_user_config_file() {
create_service_section() {
# the service section of the fluent-bit.conf file has hardcoded values,
# no need to lookup any uci section to configure this section
append_both_conf "[SERVICE]"
append_both_conf " flush 1"
append_both_conf " daemon off"
append_both_conf " log_level info"
append_both_conf " coro_stack_size 1048576"
append_both_conf " parsers_file /etc/fluent-bit/parsers.conf"
append_both_conf " hot_reload on"
append_both_conf ""
if [ -f "${SINGLE_INSTANCE_MARKER}" ]; then
append_conf "[SERVICE]"
append_conf " flush 1"
append_conf " daemon off"
append_conf " log_level info"
append_conf " coro_stack_size 1048576"
append_conf " parsers_file /etc/fluent-bit/parsers.conf"
append_conf " hot_reload on"
append_conf ""
else
append_both_conf "[SERVICE]"
append_both_conf " flush 1"
append_both_conf " daemon off"
append_both_conf " log_level info"
append_both_conf " coro_stack_size 1048576"
append_both_conf " parsers_file /etc/fluent-bit/parsers.conf"
append_both_conf " hot_reload on"
append_both_conf ""
fi
}
create_lua_filter_for_severity_facility() {
@ -573,8 +589,8 @@ handle_action_section() {
# It has a single hard coded input tail plugin which reads from /var/log/messages.
# Any filter that is applied will act on the main config and thus only filtered logs
# will be available to both fluent-bit instances.
logmngr_init() {
local enabled
start_service() {
local enabled CONF
config_load logmngr
config_get_bool enabled globals enable "1"
@ -589,16 +605,16 @@ logmngr_init() {
return
fi
procd_open_instance logmngr_main
if [ -s "${MAIN_CONF}" ]; then
procd_set_param command $PROG -c ${MAIN_CONF}
procd_set_param file ${MAIN_CONF}
CONF="${MAIN_CONF}"
elif [ -s "${CONF_FILE}" ]; then
procd_set_param command $PROG -c ${CONF_FILE}
procd_set_param file ${CONF_FILE}
CONF="${CONF_FILE}"
fi
procd_open_instance logmngr
procd_set_param command $PROG -c ${CONF}
procd_set_param file ${CONF}
# if process finishes later than respawn_threshold, it is restarted unconditionally, regardless of error code
# wait 5 seconds before respawning
# for example, if proto is udp in syslog output and url is not resolved then fluent-bit stops
@ -615,12 +631,19 @@ logmngr_init() {
append_user_conf "@INCLUDE ${FLUENT_BIT_CONF_DIR}/*"
fi
procd_open_instance logmngr_user
procd_set_param command $PROG -c ${USER_CONF}
procd_set_param file ${USER_CONF}
# same logic as above
procd_set_param respawn ${respawn_threshold:-1} ${respawn_timeout:-5}
procd_close_instance
if [ -f "${SINGLE_INSTANCE_MARKER}" ]; then
cat "${USER_CONF}" >> ${CONF}
else
procd_open_instance logmngr_user
procd_set_param command $PROG -c ${USER_CONF}
procd_set_param file ${USER_CONF}
# same logic as above
procd_set_param respawn ${respawn_threshold:-1} ${respawn_timeout:-5}
procd_close_instance
fi
fi
}
service_triggers() {
procd_add_reload_trigger logmngr
}

View file

@ -1,4 +1,8 @@
#!/bin/sh
#!/bin/sh /etc/rc.common
START=09
USE_PROCD=1
. /lib/functions.sh
@ -326,7 +330,7 @@ apply_config_file() {
cp ${TMP_CONF_FILE} ${CONF_FILE}
}
logmngr_init() {
start_service() {
create_config_file
config_load logmngr
@ -347,3 +351,7 @@ logmngr_init() {
/etc/init.d/syslog-ng start
fi
}
service_triggers() {
procd_add_reload_trigger logmngr
}