2018-06-10 13:56:07 +02:00
|
|
|
#!/bin/sh
|
2018-06-10 14:06:48 +02:00
|
|
|
|
|
|
|
: <<=cut
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
postgresql_transactions - Plugin to monitor PostgreSQL Commits and Rollbacks in Transactions
|
|
|
|
|
|
|
|
|
|
|
|
=head1 USAGE
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
Place in /etc/munin/plugins/ (or link it there using ln -s)
|
|
|
|
|
|
|
|
General info:
|
|
|
|
Requires permission for database read access (no writes are processed).
|
|
|
|
Recommended user is PostgreSQL database owner (default: postgres).
|
|
|
|
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
|
|
|
The following configuration directives may be placed below /etc/munin/plugin-conf.d/ (optional):
|
|
|
|
|
|
|
|
[postgresql_transactions]
|
|
|
|
user postgres
|
|
|
|
env.dbuser postgres
|
|
|
|
env.dbhost localhost
|
|
|
|
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
Guilherme Augusto da Rocha Silva <gars.dba@gmail.com>
|
|
|
|
|
|
|
|
Copyright (C) 2007 Guilherme Augusto da Rocha Silva <gars.dba@gmail.com>
|
|
|
|
|
|
|
|
=cut
|
2007-11-30 13:21:19 +01:00
|
|
|
|
2018-06-10 14:06:30 +02:00
|
|
|
dbhost=${dbhost:-localhost}
|
|
|
|
dbuser=${dbuser:-postgres}
|
2007-11-30 13:21:19 +01:00
|
|
|
|
2018-06-10 13:58:31 +02:00
|
|
|
|
|
|
|
do_config() {
|
2007-11-30 13:21:19 +01:00
|
|
|
echo 'graph_args --base 1000 --lower-limit 0'
|
2017-02-22 02:54:01 +01:00
|
|
|
echo 'graph_category db'
|
2007-11-30 13:21:19 +01:00
|
|
|
echo 'graph_info Shows summarized commits and rollbacks in transactions on the PostgreSQL Server.'
|
|
|
|
echo 'graph_title PostgreSQL Transactions'
|
2018-06-10 13:54:35 +02:00
|
|
|
echo 'graph_vlabel Commits and Rollbacks per second'
|
2007-11-30 13:21:19 +01:00
|
|
|
|
|
|
|
echo 'commits.label commits'
|
|
|
|
echo 'commits.min 0'
|
2018-06-10 13:54:35 +02:00
|
|
|
echo 'commits.type DERIVE'
|
|
|
|
echo 'commits.info Number of transaction commits per second.'
|
2007-11-30 13:21:19 +01:00
|
|
|
|
|
|
|
echo 'rollbacks.label rollbacks'
|
|
|
|
echo 'rollbacks.min 0'
|
2018-06-10 13:54:35 +02:00
|
|
|
echo 'rollbacks.type DERIVE'
|
|
|
|
echo 'rollbacks.info Number of transaction rollbacks per second.'
|
2018-06-10 13:58:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
do_fetch() {
|
2018-06-10 14:06:30 +02:00
|
|
|
psql -h "$dbhost" -U "$dbuser" -tc "SELECT 'commits.value '||SUM(xact_commit)::TEXT||E'\\nrollbacks.value '||SUM(xact_rollback)::TEXT FROM pg_stat_database;" --no-align
|
2018-06-10 13:58:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
do_config
|
|
|
|
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
|
|
|
else
|
|
|
|
do_fetch
|
2007-11-30 13:21:19 +01:00
|
|
|
fi
|