Skip to content

Commit

Permalink
Merge pull request #96 from jordiprats/master
Browse files Browse the repository at this point in the history
bugfix
  • Loading branch information
jordiprats authored Feb 7, 2020
2 parents 6e355a8 + a602ea3 commit eef9a76
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.4.7

* bugfix **check_replication_lag**

## 0.4.6

* added nagios compatible check for postgres replication
Expand Down
9 changes: 7 additions & 2 deletions files/nagios/check_replication_lag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ then
exit 1
fi

REPLAY_DATE=$(psql -U "${USERNAME}" -c 'select pg_last_xact_replay_timestamp();' -t | head -n1)
REPLAY_DATE=$(psql -U "${USERNAME}" -c 'select pg_last_xact_replay_timestamp();' -t 2>/dev/null | head -n1)

if [ -z "${REPLAY_DATE}" ];
then
echo "UNKNOWN: unable to to get data from postgres - check select pg_last_xact_replay_timestamp();"
exit 3
fi

NOW_TS="$(date +%s)"
REPLAY_TS="$(date -d "${REPLAY_DATE}" '+%s')"
Expand All @@ -45,7 +51,6 @@ DIFF_TS="ERROR"

let DIFF_TS=NOW_TS-REPLAY_TS


if ! [[ $DIFF_TS =~ ^[0-9]+$ ]];
then
echo "UNKNOWN: unable to process timestamps - check select pg_last_xact_replay_timestamp();"
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eyp-postgresql",
"version": "0.4.6",
"version": "0.4.7",
"author": "eyp",
"summary": "postgresql and pgbounce installation, configuration and management",
"license": "Apache-2.0",
Expand Down

0 comments on commit eef9a76

Please sign in to comment.