Page 1 of 1

send log to remote syslog

Posted: Sat Aug 20, 2022 3:54 pm
by pehon
Is there a option to send logs (meteobridge.log and logread) to a remote syslog?
It looks like that could be added to /etc/config/system (log_hostname, log_ip and log_port) but I guess this will be overwritten at restart/update.

Any ideas?

Thanks,
Peter

Re: send log to remote syslog

Posted: Sat Aug 20, 2022 11:20 pm
by Gyvate
one way could be to mount the directory where the log is written into the exported portion of the file system.
For this you need to connect to your MB via SSH (e.g. using PuTTY) - username and password are the same as for your browser access.
By default MB exports /tmp/mnt/data as \\METEOBRIDGE\data.
By creating a mount point e.g. mkdir /tmp/mnt/data/log and mounting the folder which contains meteobridge.log into /tmp/mnt/data/log, you could regularly copy the file meteobridge.log at the widows end from \\METEOBRIDGE\data\log to somewhere else and either save or process it there. As it will be overwritten at every reboot, you will at least have saved what was available in your last copy interval.
You could e.g. schedule a copy script (Windows .bat script) every hour and add a timestamp to the file name.
Could also be every minute - depends on your available storage space and housekeeping tasks you implement along with it.

The mount needs to be established manually newly after each reboot !

Re: send log to remote syslog

Posted: Sat Aug 20, 2022 11:25 pm
by Gyvate
you could also do the renaming e.g. with a time stamp and FTP the file to where you want to have it (create a FTP event under service/events)

Re: send log to remote syslog

Posted: Sat Oct 01, 2022 3:11 pm
by pehon
Solved with this setup:

cronjob (5min interval) from another system:

Code: Select all

#!/bin/bash
rsync -q root@mb:/var/log/meteobridge.log /tmp/$$.log >/dev/null 2>&1
if [ $? -eq 0 ]; then
        sed -i 's/}n/}\n/' /tmp/$$.log
        cat /tmp/$$.log > /var/log/meteobridge/meteobridge.log
fi
rm -f /tmp/$$.log >/dev/null 2>&1
(the sed is necessary because the logfile is broken from Meteobridge, sometime missing newlines

And if someone also uses promtail/Grafana Loki here are the relevant parts:

Code: Select all

      # logger (27.07.2022 04:43:52): station 1 (Weatherflow): {"serial_number":"ST-0000XXXX","type":"obs...
      stages:
      - regex:
          expression: '^[a-z0-9]+ \((?P<mytime>\d{2,2}.\d{2,2}.\d{4,4} \d{2,2}:\d{2,2}:\d{2,2})\): (?P<msg>.*)'
      - timestamp:
          # https://github.com/grafana/loki/blob/main/docs/sources/clients/promtail/stages/timestamp.md
          location: Europe/Zurich
          format: "02.01.2006 15:04:05"
          source: mytime
      - output:
          source: msg

Re: send log to remote syslog

Posted: Sat Oct 01, 2022 4:17 pm
by Gyvate
yep - rsync or scp would be another option from a remote system ...