Last active
August 3, 2018 08:22
-
-
Save zukka77/5f93786fc2623a8671398fbef9545d55 to your computer and use it in GitHub Desktop.
check_mk pg_replication_check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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