Merge "borg-backup-server: volume space monitor"

This commit is contained in:
Zuul 2021-02-10 01:28:46 +00:00 committed by Gerrit Code Review
commit 0acbf39c91
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,12 @@
#!/bin/bash
THRESHOLD=90
df -PkH | grep '/opt/backups' | awk '{ print $5 " " $6 }' | while read output;
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{print $2}' )
if [ $usep -ge $THRESHOLD ]; then
echo "Backup volume \"$partition ($usep%)\" on $(hostname) at $(date)" |
mail -s "ACTION REQUIRED: Backup volume usage at $usep%" infra-root@openstack.org
fi
done

View File

@ -15,6 +15,22 @@
group: root
mode: '0755'
- name: Install backup volume monitor
copy:
src: 'backup-volume-monitor.sh'
dest: '/usr/local/bin/backup-volume-monitor'
owner: root
group: root
mode: '0755'
- name: Run backup volume monitor
cron:
name: backup-volume-monitor
state: present
job: '/usr/local/bin/backup-volume-monitor'
minute: '0'
hour: '0'
- name: Build all borg users from backup hosts
set_fact:
borg_users: '{{ borg_users }} + [ {{ hostvars[item]["borg_user"] }} ]'