Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #set -x
- if [ $# -lt 2 ]
- then
- echo "There must be 2 parameters, stanza method"
- exit 1
- fi
- case $1 in
- stanza1)
- HOST="";;
- stanza1)
- HOST="";;
- *)
- echo "stanza not defined!"
- exit 1 ;;
- esac
- STANZA=$1
- USER=""
- export PGPASSWORD=""
- CONN_STR="-qAtX -h $HOST -U $USER postgres"
- case $2 in
- time)
- # check now - last wal time
- archive_time_diff=`psql $CONN_STR -c "select extract(seconds from (now()-last_archived_time)) from pg_stat_archiver;"`
- echo $archive_time_diff;;
- wal)
- # wall difference
- last_archive_wal=`psql $CONN_STR -c "SELECT last_archived_wal from pg_stat_archiver;"`
- last_backrest_wal=`pgbackrest --stanza $STANZA info | grep "wal archive min/max" | awk '{ print $NF }'`
- last_archive_wal=$((16#${last_archive_wal:16:23}))
- last_backrest_wal=$((16#${last_backrest_wal:16:23}))
- archive_wal_diff=$((last_archive_wal-last_backrest_wal))
- echo $archive_wal_diff;;
- *)
- echo "method not defined!"
- exit 1;;
- esac
Add Comment
Please, Sign In to add comment