root / plugins / postgresql / postgresql_transactions @ 3c10c360
Historique | Voir | Annoter | Télécharger (1,45 ko)
| 1 | fdf6cea2 | Lars Kruse | #!/bin/sh |
|---|---|---|---|
| 2 | 98df7ce7 | Guilherme Augusto da Rocha Silva | # |
| 3 | # Plugin to monitor PostgreSQL Commits and Rollbacks in Transactions |
||
| 4 | # |
||
| 5 | # Author: |
||
| 6 | # Guilherme Augusto da Rocha Silva <gars.dba@gmail.com> |
||
| 7 | # |
||
| 8 | # Created: |
||
| 9 | # 9th of november 2007 |
||
| 10 | # |
||
| 11 | # Usage: |
||
| 12 | # Place in /etc/munin/plugins/ (or link it there using ln -s) |
||
| 13 | # |
||
| 14 | # Parameters: |
||
| 15 | # config (required) |
||
| 16 | # |
||
| 17 | # General info: |
||
| 18 | # Require permission for database access and read (no writes are processed). |
||
| 19 | fba800ae | Veres Lajos | # Recommended user is PostgreSQL database owner (default: postgres). |
| 20 | 98df7ce7 | Guilherme Augusto da Rocha Silva | # |
| 21 | # Log info: |
||
| 22 | # |
||
| 23 | |||
| 24 | 3c10c360 | Lars Kruse | dbhost=${dbhost:-localhost}
|
| 25 | dbuser=${dbuser:-postgres}
|
||
| 26 | 98df7ce7 | Guilherme Augusto da Rocha Silva | |
| 27 | 154cef14 | Lars Kruse | |
| 28 | do_config() {
|
||
| 29 | 98df7ce7 | Guilherme Augusto da Rocha Silva | echo 'graph_args --base 1000 --lower-limit 0' |
| 30 | 29bdf34e | dipohl | echo 'graph_category db' |
| 31 | 98df7ce7 | Guilherme Augusto da Rocha Silva | echo 'graph_info Shows summarized commits and rollbacks in transactions on the PostgreSQL Server.' |
| 32 | echo 'graph_title PostgreSQL Transactions' |
||
| 33 | 93a567af | Lars Kruse | echo 'graph_vlabel Commits and Rollbacks per second' |
| 34 | 98df7ce7 | Guilherme Augusto da Rocha Silva | |
| 35 | echo 'commits.label commits' |
||
| 36 | echo 'commits.min 0' |
||
| 37 | 93a567af | Lars Kruse | echo 'commits.type DERIVE' |
| 38 | echo 'commits.info Number of transaction commits per second.' |
||
| 39 | 98df7ce7 | Guilherme Augusto da Rocha Silva | |
| 40 | echo 'rollbacks.label rollbacks' |
||
| 41 | echo 'rollbacks.min 0' |
||
| 42 | 93a567af | Lars Kruse | echo 'rollbacks.type DERIVE' |
| 43 | echo 'rollbacks.info Number of transaction rollbacks per second.' |
||
| 44 | 154cef14 | Lars Kruse | } |
| 45 | |||
| 46 | |||
| 47 | do_fetch() {
|
||
| 48 | 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 |
| 49 | 154cef14 | Lars Kruse | } |
| 50 | |||
| 51 | |||
| 52 | if [ "$1" = "config" ]; then |
||
| 53 | do_config |
||
| 54 | if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
|
||
| 55 | else |
||
| 56 | do_fetch |
||
| 57 | 98df7ce7 | Guilherme Augusto da Rocha Silva | fi |
