Projet

Général

Profil

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

root / plugins / postgresql / pgbouncer_maxwait @ 17f78427

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

1 c41c5666 Dave Fennell
#!/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 b4d9f328 Dave Fennell
# License:
9 fc43808f Dave Fennell
#    GPLv2
10 b4d9f328 Dave Fennell
#
11 c41c5666 Dave Fennell
# Created:
12
#    20th December 2012
13
#
14
# Usage:
15
#    Place in /etc/munin/plugins/ (or link it there using ln -s)
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 29bdf34e dipohl
	echo 'graph_category db'
30 c41c5666 Dave Fennell
	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 c81c20ab Lars Kruse
	# If dirty config capability is enabled then fall through
50
	# to output the data with the config information.
51
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
52 c41c5666 Dave Fennell
fi
53
54
# Output looks like this:
55
#  database         |   user    | cl_active | cl_waiting | sv_active | sv_idle | sv_used | sv_tested | sv_login | maxwait
56
57
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
58
do
59
	# Skip pgbouncer database itself.
60
	if [ "$user" = "pgbouncer" ]; then
61
		continue
62
	fi
63
64
	echo ${pool}.value ${maxwait}
65
done