send log to remote syslog

This section covers the Meteobridge PRO, PRO2, NANO SD, Raspberry Pi and VM platforms exclusively

Moderator: Mattk

Post Reply
pehon
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: Mon Jun 04, 2012 11:32 am

send log to remote syslog

Post 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
User avatar
Gyvate
Platinum Boarder
Platinum Boarder
Posts: 453
Joined: Thu May 14, 2020 4:36 pm
Location: Saarbrücken, Germany

Re: send log to remote syslog

Post 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 !
WH4000SE 1.6.6/1 x DP1500/4 x GW1000 1.7.7/GW1100 2.3.0/HP1000SE Pro 1.9.3//2 x WH2650 1.7.7/GW2000 3.1.0
2xMeteobridge Pro [B+R] 15161, 2xRPi4B-2GB/16/32 3139,VM128 1704
Weather Landing page: https://meshka.eu
Ecowitt WiKi: https://meshka.eu/Ecowitt/dokuwiki
User avatar
Gyvate
Platinum Boarder
Platinum Boarder
Posts: 453
Joined: Thu May 14, 2020 4:36 pm
Location: Saarbrücken, Germany

Re: send log to remote syslog

Post 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)
WH4000SE 1.6.6/1 x DP1500/4 x GW1000 1.7.7/GW1100 2.3.0/HP1000SE Pro 1.9.3//2 x WH2650 1.7.7/GW2000 3.1.0
2xMeteobridge Pro [B+R] 15161, 2xRPi4B-2GB/16/32 3139,VM128 1704
Weather Landing page: https://meshka.eu
Ecowitt WiKi: https://meshka.eu/Ecowitt/dokuwiki
pehon
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: Mon Jun 04, 2012 11:32 am

Re: send log to remote syslog

Post 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
User avatar
Gyvate
Platinum Boarder
Platinum Boarder
Posts: 453
Joined: Thu May 14, 2020 4:36 pm
Location: Saarbrücken, Germany

Re: send log to remote syslog

Post by Gyvate »

yep - rsync or scp would be another option from a remote system ...
WH4000SE 1.6.6/1 x DP1500/4 x GW1000 1.7.7/GW1100 2.3.0/HP1000SE Pro 1.9.3//2 x WH2650 1.7.7/GW2000 3.1.0
2xMeteobridge Pro [B+R] 15161, 2xRPi4B-2GB/16/32 3139,VM128 1704
Weather Landing page: https://meshka.eu
Ecowitt WiKi: https://meshka.eu/Ecowitt/dokuwiki
Post Reply