Projet

Général

Profil

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

root / plugins / other / postgresql_active_locks @ 090a4405

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

1
#!/bin/bash
2
#
3
# Plugin to monitor PostgreSQL Locks
4
#
5
# Author:
6
#    Guilherme Augusto da Rocha Silva <gars.dba@gmail.com>
7
#
8
# Created:
9
#    5th 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
#    Recomended user is PostgreSQL database owner (default: postgres).
20
#
21
# Log info:
22
#
23

    
24
dbserver='localhost'
25
dbuser='postgres'
26

    
27
if [ "$1" = "config" ]; then
28
   echo 'graph_args --lower-limit 0'
29
   echo 'graph_category Postgresql'
30
   echo 'graph_info Shows active locks on database server.'
31
   echo 'graph_scale no'
32
   echo 'graph_title PostgreSQL Active Locks'
33
   echo 'graph_vlabel Number of active locks'
34
   echo 'AccessExclusive.label AccessExclusive'
35
   echo 'AccessExclusive.info Access Exclusive Lock.'
36
   echo 'AccessShare.label AccessShare'
37
   echo 'AccessShare.info Access Share Lock.'
38
   echo 'Exclusive.label Exclusive'
39
   echo 'Exclusive.info Exclusive Lock.'
40
   echo 'RowExclusive.label RowExclusive'
41
   echo 'RowExclusive.info Row Exclusive Lock.'
42
   echo 'RowShare.label RowShare'
43
   echo 'RowShare.info Row Share Lock.'
44
   echo 'Share.label Share'
45
   echo 'Share.info Share Lock.'
46
   echo 'ShareRowExclusive.label ShareRowExclusive'
47
   echo 'ShareRowExclusive.info Share Row Exclusive Lock.'
48
   echo 'ShareUpdateExclusive.label ShareUpdateExclusive'
49
   echo 'ShareUpdateExclusive.info Share Update Exclusive Lock.'
50
   exit 0
51
fi
52

    
53
psql -h ${dbserver} -U ${dbuser} -tc "SELECT trim(mode, 'Lock'), COUNT(*) FROM pg_locks GROUP BY mode ORDER BY 1;" | while read name sep num
54
do
55
   test -z "${name}" && continue
56
   echo ${name}'.value '${num}
57
done