Projet

Général

Profil

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

root / plugins / postgresql / postgresql_tablespace_size @ 17f78427

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

1
#!/bin/bash
2
#
3
# Plugin to monitor PostgreSQL Tablespaces Size
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
#    Recommended user is PostgreSQL database owner (default: postgres).
20
#
21
# Log info:
22
#
23

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

    
28
if [ "$1" = "config" ]; then
29
   echo 'graph_args --base 1024 --lower-limit 0'
30
   echo 'graph_category db'
31
   echo 'graph_info Shows each tablespace size on the PostgreSQL Server.'
32
   echo 'graph_title PostgreSQL Tablespace Sizes'
33
   echo 'graph_vlabel Size (bytes)'
34

    
35
   PGPASSWORD="${dbpass}" psql -h ${dbserver} -U ${dbuser} -tc "SELECT spcname FROM pg_tablespace ORDER BY 1;" | while read name
36
   do
37
      test -z "${name}" && continue
38
      echo ${name}'.label '${name}
39
      echo ${name}'.type GAUGE'
40
      if [ "${name}" == "pg_global" ]; then
41
         echo ${name}'.info Tablespace for shared system catalogs.'
42
      elif [ "${name}" == "pg_default" ]; then
43
         echo ${name}'.info Default tablespace of the template1 and template0 databases (and, therefore, the default tablespace for other databases, unless user defined ones).'
44
      else
45
         echo ${name}'.info User defined tablespace.'
46
      fi
47
   done
48
   exit 0
49
fi
50

    
51
PGPASSWORD="${dbpass}" psql -h ${dbserver} -U ${dbuser} -tc "SELECT spcname, PG_TABLESPACE_SIZE(oid) FROM pg_tablespace ORDER BY 1;" | while read name sep num
52
do
53
   test -z "${name}" && continue
54
   echo ${name}'.value '${num}
55
done