Skip to content

Instantly share code, notes, and snippets.

@zukka77
Last active August 3, 2018 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zukka77/5f93786fc2623a8671398fbef9545d55 to your computer and use it in GitHub Desktop.
Save zukka77/5f93786fc2623a8671398fbef9545d55 to your computer and use it in GitHub Desktop.
check_mk pg_replication_check
#!/bin/bash
Q="select now() - pg_last_xact_replay_timestamp() < interval '10 seconds',extract (epoch from now() - pg_last_xact_replay_timestamp()) ;"
RES=($(echo ${Q} | /usr/bin/psql -tA -Upostgres | tr '|' " "))
STATUS=2
if [ ${RES[0]} == 't' ];then
STATUS=0
STATUSTEXT="OK"
else
STATUSTEXT="CRITICAL"
fi
echo "$STATUS postgres_replication_check delay=${RES[1]};5;10 $STATUSTEXT replication delay is ${RES[1]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment