Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / postgresql / postgresql_transactions @ 17f78427

Historique | Voir | Annoter | Télécharger (1,69 ko)

1 fdf6cea2 Lars Kruse
#!/bin/sh
2 e93a46bc Lars Kruse
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 98df7ce7 Guilherme Augusto da Rocha Silva
38 3c10c360 Lars Kruse
dbhost=${dbhost:-localhost}
39
dbuser=${dbuser:-postgres}
40 98df7ce7 Guilherme Augusto da Rocha Silva
41 154cef14 Lars Kruse
42
do_config() {
43 98df7ce7 Guilherme Augusto da Rocha Silva
   echo 'graph_args --base 1000 --lower-limit 0'
44 29bdf34e dipohl
   echo 'graph_category db'
45 98df7ce7 Guilherme Augusto da Rocha Silva
   echo 'graph_info Shows summarized commits and rollbacks in transactions on the PostgreSQL Server.'
46
   echo 'graph_title PostgreSQL Transactions'
47 93a567af Lars Kruse
   echo 'graph_vlabel Commits and Rollbacks per second'
48 98df7ce7 Guilherme Augusto da Rocha Silva
49
   echo 'commits.label commits'
50
   echo 'commits.min 0'
51 93a567af Lars Kruse
   echo 'commits.type DERIVE'
52
   echo 'commits.info Number of transaction commits per second.'
53 98df7ce7 Guilherme Augusto da Rocha Silva
54
   echo 'rollbacks.label rollbacks'
55
   echo 'rollbacks.min 0'
56 93a567af Lars Kruse
   echo 'rollbacks.type DERIVE'
57
   echo 'rollbacks.info Number of transaction rollbacks per second.'
58 154cef14 Lars Kruse
}
59
60
61
do_fetch() {
62 3c10c360 Lars Kruse
   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 154cef14 Lars Kruse
}
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 98df7ce7 Guilherme Augusto da Rocha Silva
fi