Automagic ansible updates using the reports.

This commit is contained in:
Andreas B. Mundt 2023-12-18 12:57:15 +01:00
parent 877396dc15
commit 7ce165553d
5 changed files with 209 additions and 137 deletions

View file

@ -11,41 +11,14 @@ sendto="collector.steinbeis.schule 1234"
cmds=(
'uname -a'
'uptime'
'apt list --upgradeable -o Apt::Cmd::Disable-Script-Warning=true'
'systemctl --failed'
'w'
'ls -ld /home/ansible/.ansible/tmp/'
'ip addr show'
'ls -d --full-time /home/ansible/.ansible/tmp/'
'ip route list default'
)
# 'ip addr show'
# 'apt list --upgradeable -o Apt::Cmd::Disable-Script-Warning=true'
r="$HOSTNAME: ------- $(date) -------
r="$HOSTNAME: ------- $(date --rfc-3339=seconds) -------
$(for c in "${cmds[@]}" ; do echo "$c"; $c | sed 's/^/ /' ; done | sed "s/^/$HOSTNAME: /")
## -------------------------------------------------"
echo "$r" | nc -w 1 -u $sendto
## below is the corresponding collector part:
# #!/usr/bin/bash
# #
# # collect messages from reporter and drop it into log files
# #
#
# set -eu
#
# port=1234
#
# logdir="/var/log/collector"
# [[ -d "$logdir" ]] || mkdir "$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 "$msg" > "$logdir/$sndr"
# else
# echo "$msg" >> "$logdir/$sndr"
# fi
# fi
# done