Here is the simple script to monitor PostgreSQL replication on FreeBSD:
========= Cut here =========
#!/bin/sh
# Timeout in seconds
readonly timeout=600
last_chkp=`pg_controldata /var/db/pgsql/ | grep "Time of latest checkpoint" | sed "s/.*checkpoint: *//"`
last_chkp=`date -j -f "%a %b %d %T %Z %Y" "$last_chkp" "+%s"`
now=`date`
now=`date -j -f "%a %b %d %T %Z %Y" "$now" "+%s"`
if [ `expr $now - $last_chkp` -gt $timeout ]; then
echo Replication kaput!
fi
Subscribe to:
Posts (Atom)