--- /dev/null
+#!/bin/sh -xe
+
+ssh postgres@10.200.1.60 PCPPASSFILE=/etc/pgpool-II/.pcppass pcp_watchdog_info --no-password | tee /dev/stderr | grep DEAD | cut -d' ' -f2 | while read host ; do
+ ssh -F ssh_config $host systemctl start pgpool
+done
+
+replication_ok=`psql -h 10.200.1.61 -t -A -c 'SELECT count(*) from pg_stat_replication' postgres postgres`
+if [ $replication_ok != 1 ] ; then
+ echo FIXME online-recovery?
+ exit 1
+fi
+
+psql -h 10.200.1.60 -p 9999 -c 'show pool_nodes' postgres postgres | grep down | awk '{ print $1 }' | while read node_id ; do
+ ssh postgres@10.200.1.60 PCPPASSFILE=/etc/pgpool-II/.pcppass pcp_attach_node --node-id $node_id --no-password
+done
+
+