trixie/roles/lmn_fvs/files/reporter

25 lines
696 B
Text
Raw Normal View History

2023-11-13 15:41:49 +01:00
#!/usr/bin/bash
#
# Send stdout of some commands to monitoring server.
# Collect the reports with 'nc -u -k -l 1234' on 'sendto'.
# Use /bin/nc.openbsd, /bin/nc.traditional seems not to work.
#
set -eu
sendto="collector.steinbeis.schule 1234"
cmds=(
'uname -a'
'uptime'
'w'
'ls -d --full-time /home/ansible/.ansible/tmp/'
'ip route list default'
2023-11-13 15:41:49 +01:00
)
# 'ip addr show'
# 'apt list --upgradeable -o Apt::Cmd::Disable-Script-Warning=true'
2023-11-13 15:41:49 +01:00
r="$HOSTNAME: ------- $(date --rfc-3339=seconds) -------
2023-11-13 15:41:49 +01:00
$(for c in "${cmds[@]}" ; do echo "$c"; $c | sed 's/^/ /' ; done | sed "s/^/$HOSTNAME: /")
## -------------------------------------------------"
echo "$r" | nc -w 1 -u $sendto