Révision c41c5666
Created 3 new pgbouncer plugins to show stats on all pools configured in the system.
| plugins/postgresql/pgbouncer_client_connections | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
# |
|
| 3 |
# Plugin to monitor PgBouncer total client connections for all pools. |
|
| 4 |
# |
|
| 5 |
# Author: |
|
| 6 |
# Dave Fennell <dave@microtux.co.uk> |
|
| 7 |
# |
|
| 8 |
# Created: |
|
| 9 |
# 20th December 2012 |
|
| 10 |
# |
|
| 11 |
# Usage: |
|
| 12 |
# Place in /etc/munin/plugins/ (or link it there using ln -s) |
|
| 13 |
# |
|
| 14 |
# Parameters: |
|
| 15 |
# config (required) |
|
| 16 |
# |
|
| 17 |
|
|
| 18 |
dbserver='' # '-h localhost' |
|
| 19 |
dbuser='postgres' |
|
| 20 |
|
|
| 21 |
# Pgbouncer Port Number |
|
| 22 |
port=6432 |
|
| 23 |
|
|
| 24 |
# The psql command to use. |
|
| 25 |
cmd="psql ${dbserver} -U ${dbuser} -p ${port} pgbouncer -tc 'SHOW POOLS;' | grep -v '^$'"
|
|
| 26 |
|
|
| 27 |
if [ "$1" = "config" ]; then |
|
| 28 |
echo 'graph_args --lower-limit 0' |
|
| 29 |
echo 'graph_category pgbouncer' |
|
| 30 |
echo 'graph_info The sum of the active and waiting clients for each pool on the server.' |
|
| 31 |
echo 'graph_scale no' |
|
| 32 |
echo 'graph_title PgBouncer Pool Total Client Connections' |
|
| 33 |
echo 'graph_vlabel client connections' |
|
| 34 |
|
|
| 35 |
eval ${cmd} | while read pool sep user junk
|
|
| 36 |
do |
|
| 37 |
# Skip pgbouncer database itself. |
|
| 38 |
if [ "$user" = "pgbouncer" ]; then |
|
| 39 |
continue |
|
| 40 |
fi |
|
| 41 |
|
|
| 42 |
test -z "${pool}" && continue
|
|
| 43 |
|
|
| 44 |
echo ${pool}.label ${pool}
|
|
| 45 |
echo ${pool}.info ${pool} connection pool
|
|
| 46 |
echo ${pool}.type GAUGE
|
|
| 47 |
done |
|
| 48 |
|
|
| 49 |
exit 0 |
|
| 50 |
fi |
|
| 51 |
|
|
| 52 |
# Output looks like this: |
|
| 53 |
# database | user | cl_active | cl_waiting | sv_active | sv_idle | sv_used | sv_tested | sv_login | maxwait |
|
| 54 |
|
|
| 55 |
eval ${cmd} | while read pool sep user sep cl_active sep cl_waiting sep sv_active sep sv_idle sep sv_used sep sv_tested sep sv_login sep maxwait
|
|
| 56 |
do |
|
| 57 |
# Skip pgbouncer database itself. |
|
| 58 |
if [ "$user" = "pgbouncer" ]; then |
|
| 59 |
continue |
|
| 60 |
fi |
|
| 61 |
|
|
| 62 |
total=$(echo ${cl_active} + ${cl_waiting} | bc)
|
|
| 63 |
|
|
| 64 |
echo ${pool}.value ${total}
|
|
| 65 |
done |
|
| 66 |
|
|
| plugins/postgresql/pgbouncer_maxwait | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
# |
|
| 3 |
# Plugin to monitor PgBouncer max wait stat for all pools. |
|
| 4 |
# |
|
| 5 |
# Author: |
|
| 6 |
# Dave Fennell <dave@microtux.co.uk> |
|
| 7 |
# |
|
| 8 |
# Created: |
|
| 9 |
# 20th December 2012 |
|
| 10 |
# |
|
| 11 |
# Usage: |
|
| 12 |
# Place in /etc/munin/plugins/ (or link it there using ln -s) |
|
| 13 |
# |
|
| 14 |
# Parameters: |
|
| 15 |
# config (required) |
|
| 16 |
# |
|
| 17 |
|
|
| 18 |
dbserver='' # '-h localhost' |
|
| 19 |
dbuser='postgres' |
|
| 20 |
|
|
| 21 |
# Pgbouncer Port Number |
|
| 22 |
port=6432 |
|
| 23 |
|
|
| 24 |
# The psql command to use. |
|
| 25 |
cmd="psql ${dbserver} -U ${dbuser} -p ${port} pgbouncer -tc 'SHOW POOLS;' | grep -v '^$'"
|
|
| 26 |
|
|
| 27 |
if [ "$1" = "config" ]; then |
|
| 28 |
echo 'graph_args --lower-limit 0' |
|
| 29 |
echo 'graph_category pgbouncer' |
|
| 30 |
echo 'graph_info PgBouncer Pool Maximum Wait' |
|
| 31 |
echo 'graph_scale no' |
|
| 32 |
echo 'graph_title PgBouncer Pool Maximum Wait' |
|
| 33 |
echo 'graph_vlabel maximum wait (secs)' |
|
| 34 |
|
|
| 35 |
eval ${cmd} | while read pool sep user junk
|
|
| 36 |
do |
|
| 37 |
# Skip pgbouncer database itself. |
|
| 38 |
if [ "$user" = "pgbouncer" ]; then |
|
| 39 |
continue |
|
| 40 |
fi |
|
| 41 |
|
|
| 42 |
test -z "${pool}" && continue
|
|
| 43 |
|
|
| 44 |
echo ${pool}.label ${pool}
|
|
| 45 |
echo ${pool}.info ${pool} connection pool
|
|
| 46 |
echo ${pool}.type GAUGE
|
|
| 47 |
done |
|
| 48 |
|
|
| 49 |
exit 0 |
|
| 50 |
fi |
|
| 51 |
|
|
| 52 |
# Output looks like this: |
|
| 53 |
# database | user | cl_active | cl_waiting | sv_active | sv_idle | sv_used | sv_tested | sv_login | maxwait |
|
| 54 |
|
|
| 55 |
eval ${cmd} | while read pool sep user sep cl_active sep cl_waiting sep sv_active sep sv_idle sep sv_used sep sv_tested sep sv_login sep maxwait
|
|
| 56 |
do |
|
| 57 |
# Skip pgbouncer database itself. |
|
| 58 |
if [ "$user" = "pgbouncer" ]; then |
|
| 59 |
continue |
|
| 60 |
fi |
|
| 61 |
|
|
| 62 |
echo ${pool}.value ${maxwait}
|
|
| 63 |
done |
|
| 64 |
|
|
| plugins/postgresql/pgbouncer_server_connections | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
# |
|
| 3 |
# Plugin to monitor PgBouncer total server connections for all pools. |
|
| 4 |
# |
|
| 5 |
# Author: |
|
| 6 |
# Dave Fennell <dave@microtux.co.uk> |
|
| 7 |
# |
|
| 8 |
# Created: |
|
| 9 |
# 20th December 2012 |
|
| 10 |
# |
|
| 11 |
# Usage: |
|
| 12 |
# Place in /etc/munin/plugins/ (or link it there using ln -s) |
|
| 13 |
# |
|
| 14 |
# Parameters: |
|
| 15 |
# config (required) |
|
| 16 |
# |
|
| 17 |
|
|
| 18 |
dbserver='' # '-h localhost' |
|
| 19 |
dbuser='postgres' |
|
| 20 |
|
|
| 21 |
# Pgbouncer Port Number |
|
| 22 |
port=6432 |
|
| 23 |
|
|
| 24 |
# The psql command to use. |
|
| 25 |
cmd="psql ${dbserver} -U ${dbuser} -p ${port} pgbouncer -tc 'SHOW POOLS;' | grep -v '^$'"
|
|
| 26 |
|
|
| 27 |
if [ "$1" = "config" ]; then |
|
| 28 |
echo 'graph_args --lower-limit 0' |
|
| 29 |
echo 'graph_category pgbouncer' |
|
| 30 |
echo 'graph_info The sum of the active and idle server connections for each pool on the server.' |
|
| 31 |
echo 'graph_scale no' |
|
| 32 |
echo 'graph_title PgBouncer Pool Total Server Connections' |
|
| 33 |
echo 'graph_vlabel server connections' |
|
| 34 |
|
|
| 35 |
eval ${cmd} | while read pool sep user junk
|
|
| 36 |
do |
|
| 37 |
# Skip pgbouncer database itself. |
|
| 38 |
if [ "$user" = "pgbouncer" ]; then |
|
| 39 |
continue |
|
| 40 |
fi |
|
| 41 |
|
|
| 42 |
test -z "${pool}" && continue
|
|
| 43 |
|
|
| 44 |
echo ${pool}.label ${pool}
|
|
| 45 |
echo ${pool}.info ${pool} connection pool
|
|
| 46 |
echo ${pool}.type GAUGE
|
|
| 47 |
done |
|
| 48 |
|
|
| 49 |
exit 0 |
|
| 50 |
fi |
|
| 51 |
|
|
| 52 |
# Output looks like this: |
|
| 53 |
# database | user | cl_active | cl_waiting | sv_active | sv_idle | sv_used | sv_tested | sv_login | maxwait |
|
| 54 |
|
|
| 55 |
eval ${cmd} | while read pool sep user sep cl_active sep cl_waiting sep sv_active sep sv_idle sep sv_used sep sv_tested sep sv_login sep maxwait
|
|
| 56 |
do |
|
| 57 |
# Skip pgbouncer database itself. |
|
| 58 |
if [ "$user" = "pgbouncer" ]; then |
|
| 59 |
continue |
|
| 60 |
fi |
|
| 61 |
|
|
| 62 |
total=$(echo ${sv_active} + ${sv_idle} | bc)
|
|
| 63 |
|
|
| 64 |
echo ${pool}.value ${total}
|
|
| 65 |
done |
|
| 66 |
|
|
Formats disponibles : Unified diff