Skip to content

Commit

Permalink
pgsql-health: wal-g_verify now only works once a day
Browse files Browse the repository at this point in the history
  • Loading branch information
LobbyLobster committed Oct 17, 2024
1 parent ecde63b commit ab62eeb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions configs/db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
postgres:
limits:
process: 50
query: 25
conn_percent: 70
alarm:
enabled: true
leader_switch_hook: "echo 'leader switch'"
wal-g_verify_hour: "03:00"
11 changes: 9 additions & 2 deletions scripts/monodb/pgsql-health.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function parse_config_pgsql() {

LEADER_SWITCH_HOOK=$(yaml .postgres.leader_switch_hook $CONFIG_PATH_MONODB "")

WALG_VERIFY_HOUR=$(yaml .postgres.wal-g_verify_hour $CONFIG_PATH_MONODB "")

if [ -z "$PATRONI_API" ] && [ -f /etc/patroni/patroni.yml ]; then
PATRONI_API="$(yq -r .restapi.connect_address /etc/patroni/patroni.yml)"
fi
Expand Down Expand Up @@ -353,16 +355,21 @@ function main() {
check_active_connections
printf '\n'
check_running_queries

if [ -z "$WALG_VERIFY_HOUR" ]; then
WALG_VERIFY_HOUR="03:00"
fi

if [[ -n "$PATRONI_API" ]]; then
printf '\n'
cluster_status
role="$(curl -s "$PATRONI_API/patroni" | jq -r .role)"
if [ "$role" == "master" ] && [ -n "$(command -v wal-g)" ]; then
if [ "$role" == "master" ] && [ -n "$(command -v wal-g)" ] && [[ "$(date "+%H:%M")" == "$WALG_VERIFY_HOUR" ]]; then
printf '\n'
wal-g_verify
fi
else
if [ -n "$(command -v wal-g)" ]; then
if [ -n "$(command -v wal-g)" ] && [[ "$(date "+%H:%M")" == "$WALG_VERIFY_HOUR" ]]; then
printf '\n'
wal-g_verify
fi
Expand Down

0 comments on commit ab62eeb

Please sign in to comment.