Implement time stamp and improve reporter syntax.

The directory access time used so far is modified on every
ansible run and independent of the ansible module/playbook.
This commit is contained in:
Andreas B. Mundt 2024-01-16 11:54:45 +01:00
parent 5ed4c2a135
commit aa8bc09ce6
4 changed files with 25 additions and 13 deletions

View file

@ -11,11 +11,11 @@ logdir="/tmp/collector"
mkdir -vp "$logdir"
nc -k -l -u -p "$port" | while read line ; do
sndr="${line%%:*}"
msg="${line#*: }"
sndr="${line%% *}"
msg="${line#* }"
if [[ "$sndr" =~ [a-z0-9]+ ]] ; then
if [[ "$msg" =~ ^-------\ .+\ -------$ ]] ; then
echo "$(date --rfc-3339=seconds) → Message from '$sndr' received."
echo "$(date --rfc-3339=seconds) → Report from '$sndr' received."
echo "$msg" > "$logdir/$sndr"
else
echo "$msg" >> "$logdir/$sndr"