X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fpostgres%2Ffiles%2Fdsa-restart-all-idle-postgres;h=078d50010cc377494b61b43df09789c16a1285cc;hb=6d227b8973b5f73b3cb558312bdcc895ab70e04b;hp=2f7ee90255239310c0ad65a1043d84104bfda060;hpb=6e66642ee331bbcafad68b2d3606321a9d337a83;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 2f7ee9025..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 @@ -40,14 +41,19 @@ handle_cluster() { pid="$(get_pidfile_value "$version" "$name")" while chk_net "$port" && [ "$pid" = "$(get_pidfile_value "$version" "$name")" ]; do - sleep 10 + sleep 60 done 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 -wait + handle_cluster $version $name $port +done