Projet

Général

Profil

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

root / plugins / postgresql / pgbouncer_server_connections @ 17f78427

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

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
# License:
12
#    GPLv2
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
	echo 'graph_category db'
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
	# 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
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
	total=$(echo ${sv_active} + ${sv_idle} | bc)
65

    
66
	echo ${pool}.value ${total}
67
done