Bash public

PostgreSQL Ready Check

Share this script safely, inspect its metadata, and copy the exact command you need.

Dashboard

Ready to run

One-liner

Copy the command, then review before execution.
curl -fsSL https://runny.sh/r/A30MHGJ0NZJT | bash

Current version: 1.1 · Updated by Godmode · 2026-09-07 02:38:59.303

At a glance

Script metadata

Slug
A30MHGJ0NZJT
Fetches
0
Size
1079 B · 43 lines
Expires
never
Last fetch
Created
2026-09-07 00:35:59.694
Description
pg_isready against the local client defaults

Readable before runnable

Preview

#!/usr/bin/env bash
# PostgreSQL readiness
# Read-only: pg_isready against optional extra args (host/port/socket).
# Exit 0 if accepting connections, 1 if the CLI is missing, 2 if not ready.
# Hosted on Runny.sh. Review the script page before you run it.

set -u

note() { printf '%s\n' "$*"; }

note "=== PostgreSQL readiness ==="
if ! command -v pg_isready >/dev/null 2>&1; then
  note "pg_isready not found in PATH"
  note "Result: WARNING"
  exit 1
fi

note "Client:   $(pg_isready --version 2>/dev/null || printf unknown)"
note "Args:     ${*:-<defaults>}"
note ""
if out=$(pg_isready "$@" 2>&1); then
  note "$out"
  note "          OK"
  note "Result: HEALTHY"
  exit 0
else
  rc=$?
  note "$out"
  if [ "$rc" -eq 1 ]; then
    note "          CRITICAL: server is rejecting connections"
    note "Result: CRITICAL"
    exit 2
  elif [ "$rc" -eq 2 ]; then
    note "          CRITICAL: server is not responding"
    note "Result: CRITICAL"
    exit 2
  else
    note "          WARNING: pg_isready usage or permission problem"
    note "Result: WARNING"
    exit 1
  fi
fi

Raw endpointhttps://runny.sh/r/A30MHGJ0NZJT

See something unsafe?

Report this script

Tell us why it should come down. Anyone can also report a URL at /abuse.

Restore revision