Syslog server not working after reboot

Hello,

I have downloaded OpenWRT 24.10-rc4 with some additional packages for my Netgear WNDR3800, packet details see end of this post. I have set up a server connection for remote logging, which was working quite fine, until I restarted the router. It simply doesn't send the logs to the server any more.

A different router (GL-MT6000) has the same configuration, but does not have this issue.

in the syslog I can see the following lines related to syslog:
logread[1248]: Failed to send log data to 172.16.1.16:510 via udp
but later:
logread[1248]: Logread connected to 172.16.1.16:510 via udp

Did I miss a package accitentally? But as far as I know remote logging shall work out of the box.

When I restart logging using:
/etc/init.d/log restart
It is working again, but all current log messages get lost. With the following workaround remote logging is working after a restart:

# get process
process=$(ps | grep logread | grep -v grep)
pid=$(echo $process |  sed -e 's/^[[:space:]]*//' | cut -d ' ' -f 1)
pos=$(expr index "$process" /sbin)
len=${#process}
# calculate
pos=$((pos - 1))
len=$((len - pos + 1))
# extract command
command=${process:$pos:$len}

# restart process
kill -9  $pid > /dev/null
$command &

For some reason this script is not working correctly when called from /etc/rc.local, it needs to be called from an ssh shell.
Anyway, it would be nice to work without a work around. :slightly_smiling_face:

regards,
nieroster

installed packets:

base-files busybox ca-bundle dnsmasq dropbear firewall4 fstools kmod-ath9k kmod-gpio-button-hotplug kmod-nft-offload libc libgcc libustream-mbedtls logd mtd netifd nftables odhcp6c odhcpd-ipv6only opkg ppp ppp-mod-pppoe procd procd-seccomp procd-ujail swconfig uboot-envtools uci uclient-fetch urandom-seed urngd wpad-basic-mbedtls kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport kmod-leds-reset kmod-owl-loader kmod-switch-rtl8366s luci
6in4 6rd 6to4 ccrypt collectd-mod-conntrack collectd-mod-entropy collectd-mod-ping collectd-mod-uptime diffutils hostapd-utils htop ip6tables-mod-nat iptables-mod-ipsec iptables-nft kmod-ip6tables kmod-ipt-conntrack kmod-ipt-ipsec kmod-ipt-nat kmod-ipt-nat6 kmod-nf-nat6 kmod-nft-compat kmod-nls-cp1250 kmod-nls-cp437 kmod-nls-cp850 kmod-nls-iso8859-1 kmod-nls-iso8859-15 kmod-nls-utf8 kmod-pptp kmod-usb-storage luci-app-acme luci-app-adblock luci-app-commands luci-app-ddns luci-app-mosquitto luci-app-nlbwmon luci-app-openvpn luci-app-sqm luci-app-statistics luci-app-uhttpd luci-app-wol luci-proto-wireguard luci-theme-material msmtp nano openssh-client openssl-util openvpn-openssl patch qrencode tree wget-ssl xtables-nft

This is a working workaround which can be started from rc.local using an & after the shell script name:

#!/bin/sh
# get PID
PID=$(ps | grep logread | grep -v grep | sed -e 's/^[[:space:]]*//' | cut -d ' ' -f 1)
if  [ "$PID" == "" ] || [ $PID -lt 1300 ];then
	# read remote logging configuration
	HOST=$(cat /etc/config/system | grep hostname | sed -e 's/^[[:space:]]*//' | cut -d ' ' -f 3 |  sed -e "s/'//g")
	SYSLOG_SERVER_IP=$(cat /etc/config/system | grep log_ip | sed -e 's/^[[:space:]]*//' | cut -d ' ' -f 3 |  sed -e "s/'//g")
	SYSLOG_SERVER_PORT=$(cat /etc/config/system | grep log_port | sed -e 's/^[[:space:]]*//' | cut -d ' ' -f 3 |  sed -e "s/'//g")
	SYSLOG_SERVER_PROTOCOL=$(cat /etc/config/system | grep log_proto | sed -e 's/^[[:space:]]*//' | cut -d ' ' -f 3 |  sed -e "s/'//g")
	if [ "$SYSLOG_SERVER_PROTOCOL" == "udp" ];then
		PROTOCOL_OPTION="-u"
	else
		PROTOCOL_OPTION="-t"
	fi
	# compose command
	COMMAND="/sbin/logread -f -h $HOST -r $SYSLOG_SERVER_IP $SYSLOG_SERVER_PORT -p /var/run/logread.2.pid $PROTOCOL_OPTION"
	if [ -n "$PID" ];then
		# restart process
		kill -9  $PID > /dev/null
	fi
	$COMMAND &
fi

btw. did anybody else notice this behaviour?

Any error messages?

Which shell are you using when connected via ssh?

The shell used by /etc/rc.local, when it is executed, is /bin/sh, which defaults to ash.

yes, I am using ash

when using the previous shell script, strings got truncated when started from rc.local, so it used the wrong command to restart logread.

It was working fine in an ssh session, which also uses ash, as far as I know.

But with behaviour I meant the remote logging not working after a restart.

I have opened a bug ticket for this issue here: https://github.com/openwrt/openwrt/issues/17478