root / plugins / postgresql / postgresql_transactions @ 17f78427
Historique | Voir | Annoter | Télécharger (1,69 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
|
| 3 |
: <<=cut |
| 4 |
|
| 5 |
=head1 NAME |
| 6 |
|
| 7 |
postgresql_transactions - Plugin to monitor PostgreSQL Commits and Rollbacks in Transactions |
| 8 |
|
| 9 |
|
| 10 |
=head1 USAGE |
| 11 |
|
| 12 |
Usage: |
| 13 |
Place in /etc/munin/plugins/ (or link it there using ln -s) |
| 14 |
|
| 15 |
General info: |
| 16 |
Requires permission for database read access (no writes are processed). |
| 17 |
Recommended user is PostgreSQL database owner (default: postgres). |
| 18 |
|
| 19 |
|
| 20 |
=head1 CONFIGURATION |
| 21 |
|
| 22 |
The following configuration directives may be placed below /etc/munin/plugin-conf.d/ (optional): |
| 23 |
|
| 24 |
[postgresql_transactions] |
| 25 |
user postgres |
| 26 |
env.dbuser postgres |
| 27 |
env.dbhost localhost |
| 28 |
|
| 29 |
|
| 30 |
=head1 AUTHOR |
| 31 |
|
| 32 |
Guilherme Augusto da Rocha Silva <gars.dba@gmail.com> |
| 33 |
|
| 34 |
Copyright (C) 2007 Guilherme Augusto da Rocha Silva <gars.dba@gmail.com> |
| 35 |
|
| 36 |
=cut |
| 37 |
|
| 38 |
dbhost=${dbhost:-localhost}
|
| 39 |
dbuser=${dbuser:-postgres}
|
| 40 |
|
| 41 |
|
| 42 |
do_config() {
|
| 43 |
echo 'graph_args --base 1000 --lower-limit 0' |
| 44 |
echo 'graph_category db' |
| 45 |
echo 'graph_info Shows summarized commits and rollbacks in transactions on the PostgreSQL Server.' |
| 46 |
echo 'graph_title PostgreSQL Transactions' |
| 47 |
echo 'graph_vlabel Commits and Rollbacks per second' |
| 48 |
|
| 49 |
echo 'commits.label commits' |
| 50 |
echo 'commits.min 0' |
| 51 |
echo 'commits.type DERIVE' |
| 52 |
echo 'commits.info Number of transaction commits per second.' |
| 53 |
|
| 54 |
echo 'rollbacks.label rollbacks' |
| 55 |
echo 'rollbacks.min 0' |
| 56 |
echo 'rollbacks.type DERIVE' |
| 57 |
echo 'rollbacks.info Number of transaction rollbacks per second.' |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
do_fetch() {
|
| 62 |
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 |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
if [ "$1" = "config" ]; then |
| 67 |
do_config |
| 68 |
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
| 69 |
else |
| 70 |
do_fetch |
| 71 |
fi |
