Add multi-db support and lots of comments

This commit is contained in:
James Campbell 2024-05-23 00:35:44 -04:00
parent 7c3fe0ba40
commit e4b6e981a5
Signed by: james
GPG Key ID: 2287C33A40DC906A
3 changed files with 748 additions and 159 deletions

View File

@ -7,7 +7,8 @@ metric=version:value::SHOW server_version_num
metric=max_frozen_age:value::SELECT max(age(datfrozenxid)) FROM pg_database metric=max_frozen_age:value::SELECT max(age(datfrozenxid)) FROM pg_database
# Per-database metrics # Per-database metrics
metric=db_stats:row::SELECT * FROM pg_stat_database WHERE datname = '{datname}' metric=db_stats:row::SELECT numbackends, xact_commit, xact_rollback, blks_read, blks_hit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted, conflicts, temp_files, temp_bytes, deadlocks, blk_read_time, blk_write_time, extract('epoch' from stats_reset) FROM pg_stat_database WHERE datname = '{datname}'
metric=db_stats:row:160000:SELECT numbackends, xact_commit, xact_rollback, blks_read, blks_hit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted, conflicts, temp_files, temp_bytes, deadlocks, checksum_failures, blk_read_time, blk_write_time, session_time, active_time, idle_in_transaction_time, sessions, sessions_abandoned, sessions_fatal, sessions_killed, extract('epoch' from stats_reset) FROM pg_stat_database WHERE datname = '{datname}'
# Per-replication metrics # Per-replication metrics
metric=rep_stats:row::SELECT * FROM pg_stat_database WHERE client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') = '{repid}' metric=rep_stats:row::SELECT * FROM pg_stat_database WHERE client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') = '{repid}'

View File

@ -36,24 +36,26 @@
## ##
# Log level for stderr logging (or 'off') # Log level for stderr logging (or 'off')
#stderr_log_level=info stderr_log_level=debug
# Log level for file logging (od 'off') # Log level for file logging (od 'off')
#file_log_level=info file_log_level=off
# Log file # Log file
#log_file=pgmon.log #log_file=pgmon.log
## ##
# DB connection settings # DB connection settings
#
# Each cluster entry is of the form:
# name:address:port:dbname:user:password
#
# Any element other than the name can be left empty to use the defaults
## ##
#host=localhost #cluster=local:/var/run/postgresql:5432:postgres:zbx_monitor:
host=/var/run/postgresql cluster=pg15:localhost:54315:postgres:postgres:
#port=5432 cluster=pg96:localhost:54396:postgres:postgres:
#user=postgres
user=zbx_monitor
#password=None
# Default database to connect to when none is specified for a metric # Default database to connect to when none is specified for a metric
#dbname=postgres #dbname=postgres
@ -65,4 +67,4 @@ user=zbx_monitor
# Metrics # Metrics
#metrics={} #metrics={}
include=/etc/zabbix/pgmon-metrics.cfg include=pgmon-metrics.cfg

884
pgmon.py

File diff suppressed because it is too large Load Diff