2025-06-26-13-33-49: Cronjob

This commit is contained in:
lmn-client 2025-06-26 13:33:49 +02:00
commit 29049c8da1
127 changed files with 7089 additions and 0 deletions

24
tools/collector Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/bash
#
# collect messages from reporter and drop them into log files
#
set -eu
port=1234
#logdir="/var/log/collector"
logdir="/tmp/collector"
mkdir -vp "$logdir"
nc -k -l -u -p "$port" | while read line ; do
sndr="${line%% *}"
msg="${line#* }"
if [[ "$sndr" =~ [a-z0-9]+ ]] ; then
if [[ "$msg" =~ ^-------\ .+\ -------$ ]] ; then
echo "$(date --rfc-3339=seconds) → Report from '$sndr' received."
echo "$msg" > "$logdir/$sndr"
else
echo "$msg" >> "$logdir/$sndr"
fi
fi
done