Automagic ansible updates using the reports.
This commit is contained in:
parent
877396dc15
commit
7ce165553d
5 changed files with 209 additions and 137 deletions
24
tools/collector
Executable file
24
tools/collector
Executable 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) → Message from '$sndr' received."
|
||||
echo "$msg" > "$logdir/$sndr"
|
||||
else
|
||||
echo "$msg" >> "$logdir/$sndr"
|
||||
fi
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue