Skip to content

Based on pg_report, but only issues email/slack alerts and console output, no html output format.

License

Notifications You must be signed in to change notification settings

MichaelDBA/pg_check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pg_check

(c) 2018-2023 SQLEXEC LLC
GNU V3 and MIT licenses are conveyed accordingly.
Bugs can be reported @ [email protected]

Overview

Based on pg_report, but only issues email alerts/slack channel msgs and console output, no html output format. Currently the things checked for:
PG host is accepting connections
Waiting or blocked transactions
Long running queries
Idle in transaction
Idle connections
Linux Load state
High number of active connections relative to number of CPUs
Data Directory size > 75%
Streaming replication state
PGBouncer state
PGBackrest last backup state

Requirements

Python, psql command line tool, postfix service

Gotchas

Make sure mailx is installed.
Make sure postfix service is running.
Make sure there is room for logging mail to root file (/var/spool/mail/root). Consider max size from default=50MB.
Tail /var/log/maillog for errors.

Slack Setup:

You need to put the slack webhook into a specific file location: UserHomeDirectory/.slackhook
It looks like this:
https://hooks.slack.com/services/ "somekeyvalue without the quotes and leading space"

Typical usage:

pg_check.py -h localhost -p 5432 -U sysdba -d mydb -w -l 60 -i 30 -c 48 -e PROD -m -r -x -y
pg_check.py -h localhost -p 5432 -U sysdba -d mydb -o 2440 -e PROD -s

-w 5 --> WAITS and LOCKS checking greater than number of seconds provided
-l 60 --> queries running longer than 60 minutes
-i 30 --> idle in transaction state for more than 30 minutes
-o 2440 --> idle connections more than 2 days
-c 48 --> number of CPUs serving this PG instance (not necessary if db is on localhost)
-e PROD --> User Context for PG instances that shows up in email subject line
-r --> Check Replication
-x --> Check PGBouncer
-y --> Check PGBackrest
-m --> Send Mail Notifications
-s --> Send Slack Notifications

About

Based on pg_report, but only issues email/slack alerts and console output, no html output format.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages