A command-line tool and Go library for running health checks against PostgreSQL databases.
go install github.com/fresha/pgdoctor/cmd/pgdoctor@latest
Get your PostgreSQL health report in seconds.
$ pgdoctor run "postgres://user:pass@localhost:5432/mydb"
# Or use an environment variable
$ export PGDOCTOR_DSN="postgres://..."
$ pgdoctor run
# Run only specific checks or categories
$ pgdoctor run --only connection-health,indexes
# Skip certain checks
$ pgdoctor run --ignore index-bloat,vacuum
# List all available checks
$ pgdoctor list
# Read detailed docs for a check
$ pgdoctor explain index-bloat
# JSON output for CI/CD
$ pgdoctor run --output json
# Verbose details, hide passing
$ pgdoctor run --detail verbose --hide-passing
Production-safe checks organized across categories. Click any check to expand its documentation.
pgdoctor explain <check-id>
Embed pgdoctor checks directly in your Go applications.
Import as a Go module and run checks programmatically. Filter, extend with custom checks, and process results however you need.
package main
import (
"context"
"fmt"
"github.com/fresha/pgdoctor"
"github.com/jackc/pgx/v5"
)
func main() {
ctx := context.Background()
conn, _ := pgx.Connect(ctx, "postgres://localhost:5432/mydb")
defer conn.Close(ctx)
reports, err := pgdoctor.Run(
ctx, conn, pgdoctor.AllChecks(), nil, nil,
)
if err != nil {
panic(err)
}
for _, report := range reports {
fmt.Printf("[%s] %s\n", report.CheckID, report.Name)
}
}