DEDUPED Hot AI repos, turned into use cases Get 5 a day

How to triage a slow PostgreSQL database in ten seconds with Pgbot

Run one read-only health check and get ranked findings for a database you do not own.

Credentials. Connection strings contain the role password, so use the environment variable rather than putting the password in shell history or the ps output.

Who it is forAn on-call engineer or database owner who needs to know what is wrong with a PostgreSQL database right now, without deploying monitoring.

The problemDigging through pg_stat views by hand is slow, and dashboards need setup before they help during an incident.

The outcomeA findings-first report that grades cache hit, lock wait, rollbacks, and idle index bytes, then lists CRITICAL, WARNING, and NOTE findings.

What you need first

  • A PostgreSQL server version 14 to 18 that you can reach over the network
  • A login role with the pg_monitor role and no write grants (pgbot init generates the setup SQL)
  • The pgbot binary, installed with the curl install script or npx @pgbot/cli
  • Optional: pg_stat_statements for the queries section, and hypopg on PostgreSQL 16+ for advise

Steps

  1. Install Pgbot with curl -fsSL https://pgbot.dev/install | sh.
  2. Generate the read-only role setup SQL with pgbot init, review it, and run it yourself, since Pgbot executes nothing. (inferred, check the README)
  3. Set the connection once with export DATABASE_URL="postgres://pgbot_ro@host:5432/db".
  4. Run pgbot inspect for the graded summary.
  5. Run pgbot inspect --full for the subsystem status board and section tables.

Prompt for your agent

Using the pgbot tool from the pgrundev/pgbot repository, run `pgbot inspect --json` against the database whose connection string is in <target-env-var>. Report the CRITICAL and WARNING findings and the health score. Verify that the JSON contract version reported is 1.5.0 before you trust the findings.

Caveat. The human-readable report is not a stable interface, so scripts and agents should parse --json instead of the terminal output.

Share: X LinkedIn Hacker News Email Copy link

Disclaimer

Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked "Seen in the wild", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email [email protected] and we will look at it promptly. Full disclaimer page