Add daily Postgres vacuum script
This commit is contained in:
parent
9bac2bac43
commit
c0acd3e994
|
@ -60,6 +60,12 @@
|
||||||
dest: /usr/lib/check_mk_agent/plugins/postgres
|
dest: /usr/lib/check_mk_agent/plugins/postgres
|
||||||
mode: 0755
|
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
|
- name: install initial schema files
|
||||||
copy:
|
copy:
|
||||||
src: "{{ item.src }}"
|
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