What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Remote logging, early boot hostname and syslog tag. Best method?

deusx

New Around Here
I am interested in forwarding the syslog entries to another host, a synology NAS. Forwarding works fine, as well as the loglevel options. The issue I'm facing is that during boot and until init the hostname is not initialised early enough to ensure that the log entries will be tagged with the hostname and the initial ones start with the router's LAN IP for example. Also, I would need to restart the syslogd without the -S option to ensure consistency with other logs from the system. End result is that the remote syslog is populated with numerous ungrouped log entries from the corresponding logging components.

In short I want to group all the router log entries under the tag that will be the router's hostname.

What I've tried so far:

In order to initialise the hostname early enough to be picked before syslogd commences I echo the hostname to /proc/sys/kernel/hostname in init-start. That solves partially the problem, as the kernel logs prior to starting the syslogd were not tagged with the hostname.

I also set log_level, console_loglevel and message_loglevel to 0, between init-start and services-start in order to ensure zero logging until I restart the syslogd in services-start without the -S option.

The point which syslogd behaves as intended is right after services-start where I cycle the logging services and restart the daemon with the desired options, verbosity and hostname, assuming that syslogd will never crash. But I'm losing all boot, kernel, and syslog messages until this point.

So, which would be the best strategy to forward all logging from the router to the remote host, preferably from boot, all tagged with the router's hostname?

I guess, a clean, short solution would be to just tune the kernel boot args, so that boot logs as well as syslog logs later on will all be tagged with the hostname. Is there a way to tune that?

Anything else, that involves jffs scripts seems a hack to me, that partially works. Especially because all the intended parts which need to be modified are hardcoded and not configurable, e.g. syslogd options, the order which syslogd is launched in init in relation to where sethostname() is called, etc.
 
What code level are you running? I wrote a patch for this on my fork a while ago (hostname not available for syslogd early in boot). If you want to give it a try, let me know and I'll make a code for you to test, then send a pull request to Merlin if it works for you.
 
By code level you mean the syslog verbosity, or the firmware version I'm running? I'm on a AC87U, with latest 380.60_beta1. Ideally I'd prefer to avoid to have to build the firmware, but I fear this will be unavoidable for a proper solution in boot, due to not having a linux machine available at the moment. But I can setup a docker container to quickly try it out. Do you have your fork on github? If it works, I guess it would improve logging for every other router, so I could PR Merlin's upstream with the patch.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top