Add daily Postgres vacuum script
This commit is contained in:
parent
6b491e529d
commit
030a3ded99
|
@ -60,6 +60,12 @@
|
|||
dest: /usr/lib/check_mk_agent/plugins/postgres
|
||||
mode: 0755
|
||||
|
||||
- name: install daily vacuum script
|
||||
template:
|
||||
src: patroni/pvcdns-vacuum.j2
|
||||
dest: /etc/cron.daily/pvcdns-vacuum
|
||||
mode: 0755
|
||||
|
||||
- name: install initial schema files
|
||||
copy:
|
||||
src: "{{ item.src }}"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
# Daily vaccuum script for PVCDNS database
|
||||
# {{ ansible_managed }}
|
||||
|
||||
# Don't run if we aren't primary
|
||||
HOSTNAME="$( hostname -s )"
|
||||
PRIMARY="$( pvc node list | grep primary | awk '{ print $1 }' )"
|
||||
if [[ $HOSTNAME != $PRIMARY ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Analyze the database
|
||||
echo -e "----------------------------" &>>/var/log/pvc/pdns/vacuum.log
|
||||
echo -e "$( date )" &>>/var/log/pvc/pdns/vacuum.log
|
||||
echo -e "----------------------------" &>>/var/log/pvc/pdns/vacuum.log
|
||||
su postgres -c 'psql pvcdns -c "VACUUM (VERBOSE, ANALYZE);"' &>>/var/log/pvc/pdns/vacuum.log
|
Loading…
Reference in New Issue