Projet

Général

Profil

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

root / plugins / postgresql / pgbouncer_maxwait @ c41c5666

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

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