Guest User

Untitled

a guest
Mar 10th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/bin/bash
  2. #set -x
  3. if [ $# -lt 2 ]
  4. then
  5. echo "There must be 2 parameters, stanza method"
  6. exit 1
  7. fi
  8.  
  9. case $1 in
  10. stanza1)
  11. HOST="";;
  12. stanza1)
  13. HOST="";;
  14. *)
  15. echo "stanza not defined!"
  16. exit 1 ;;
  17. esac
  18.  
  19. STANZA=$1
  20. USER=""
  21. export PGPASSWORD=""
  22.  
  23. CONN_STR="-qAtX -h $HOST -U $USER postgres"
  24.  
  25. case $2 in
  26. time)
  27. # check now - last wal time
  28. archive_time_diff=`psql $CONN_STR -c "select extract(seconds from (now()-last_archived_time)) from pg_stat_archiver;"`
  29. echo $archive_time_diff;;
  30. wal)
  31. # wall difference
  32. last_archive_wal=`psql $CONN_STR -c "SELECT last_archived_wal from pg_stat_archiver;"`
  33. last_backrest_wal=`pgbackrest --stanza $STANZA info | grep "wal archive min/max" | awk '{ print $NF }'`
  34. last_archive_wal=$((16#${last_archive_wal:16:23}))
  35. last_backrest_wal=$((16#${last_backrest_wal:16:23}))
  36. archive_wal_diff=$((last_archive_wal-last_backrest_wal))
  37. echo $archive_wal_diff;;
  38. *)
  39. echo "method not defined!"
  40. exit 1;;
  41. esac
Add Comment
Please, Sign In to add comment