X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fpostgres%2Ffiles%2Fdsa-restart-all-idle-postgres;h=078d50010cc377494b61b43df09789c16a1285cc;hb=7e22e08a43a59c1bfa91c3ca009e5222430b47be;hp=33f48c2ceec3711828c8c31e8339bec6e4bf2c79;hpb=d8aaeeb7e1fa14706ef7428442addfaeb8bfb9e0;p=mirror%2Fdsa-puppet.git diff --git a/modules/postgres/files/dsa-restart-all-idle-postgres b/modules/postgres/files/dsa-restart-all-idle-postgres index 33f48c2ce..078d50010 100755 --- a/modules/postgres/files/dsa-restart-all-idle-postgres +++ b/modules/postgres/files/dsa-restart-all-idle-postgres @@ -3,7 +3,8 @@ # Written by Peter Palfrader # Based on code by Tollef Fog Heen based on code by Peter Palfrader # -# Restart all postgresql clusters when they do not have connections to them. +# Restart all postgresql clusters that show up in dsa-check-libs when they do +# not have connections to them. set -e set -u @@ -45,9 +46,14 @@ handle_cluster() { systemctl restart "postgresql@${version}-${name}.service" } +tmpfile="$(tempfile)" +trap "rm -f '$tmpfile'" EXIT +/usr/lib/nagios/plugins/dsa-check-libs > "$tmpfile" || true + pg_lsclusters -h | while read version name port status; do echo "$status" | grep -q --word-regexp online || continue - handle_cluster $version $name $port & -done + pid="$(get_pidfile_value "$version" "$name")" + grep -q --word-regexp $pid "$tmpfile" || continue -disown -a + handle_cluster $version $name $port +done