Files
fedora-infra_ansible/roles/batcave/files/vmdiff.sh
Frank Ch. Eigler 55bfa1af29 batcave vmdiff.sh: timeout this hourly cron job to 1h
Prevent these jobs from running so long that new jobs can get started
meanwhile.  batcave has been observed to run sometimes dozens of old
list-vms-per-host processes under unusual but not rare circumstances.
2022-10-24 23:33:03 +00:00

25 lines
823 B
Bash
Executable File

#!/bin/bash
dest="/var/log/virthost-lists.out"
output=$(mktemp tmp.XXXXXXXXXX)
diffout=$(mktemp tmp.XXXXXXXXX)
mailto='admin@fedoraproject.org'
source /root/sshagent >>/dev/null
export ANSIBLE_HOST_KEY_CHECKING=False
timeout 1h /srv/web/infra/ansible/scripts/list-vms-per-host virtservers 2>/dev/null > "$output"
chmod 644 "$output"
diff -u "$dest" "$output" > $diffout
rc=$?
if [ $rc == 1 ]; then
cat $diffout | /bin/mail -s "virthosts changed: `date +'%Y-%m-%d %H:%M'`" $mailto
cp -f $dest ${dest}.last
elif [ $rc == 2 ]; then
cat $output | /bin/mail -s "virthosts: `date +'%Y-%m-%d %H:%M'`" $mailto
fi
bad=""
bad=`/bin/grep 'shutdown:1' $output`
if [ -n "$bad" ]; then
echo -e "\n$bad\n" | /bin/mail -s "shutdown virt instances which are set to autorun" $mailto
fi
mv -f "$output" "$dest"
rm -f $diffout