Révision c7cc0926
Initial version
| plugins/other/postgresql_tablespace_size | ||
|---|---|---|
| 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 |
# 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 --base 1024 --lower-limit 0' |
|
| 29 |
echo 'graph_category Postgresql' |
|
| 30 |
echo 'graph_info Shows each tablespace size on the PostgreSQL Server.' |
|
| 31 |
echo 'graph_title PostgreSQL Tablespace Sizes' |
|
| 32 |
echo 'graph_vlabel Size (bytes)' |
|
| 33 |
|
|
| 34 |
psql -h ${dbserver} -U ${dbuser} -tc "SELECT spcname FROM pg_tablespace ORDER BY 1;" | while read name
|
|
| 35 |
do |
|
| 36 |
test -z "${name}" && continue
|
|
| 37 |
echo ${name}'.label '${name}
|
|
| 38 |
echo ${name}'.type GAUGE'
|
|
| 39 |
if [ "${name}" == "pg_global" ]; then
|
|
| 40 |
echo ${name}'.info Tablespace for shared system catalogs.'
|
|
| 41 |
elif [ "${name}" == "pg_default" ]; then
|
|
| 42 |
echo ${name}'.info Default tablespace of the template1 and template0 databases (and, therefore, the default tablespace for other databases, unless user defined ones).'
|
|
| 43 |
else |
|
| 44 |
echo ${name}'.info User defined tablespace.'
|
|
| 45 |
fi |
|
| 46 |
done |
|
| 47 |
exit 0 |
|
| 48 |
fi |
|
| 49 |
|
|
| 50 |
psql -h ${dbserver} -U ${dbuser} -tc "SELECT spcname, PG_TABLESPACE_SIZE(oid) FROM pg_tablespace ORDER BY 1;" | while read name sep num
|
|
| 51 |
do |
|
| 52 |
test -z "${name}" && continue
|
|
| 53 |
echo ${name}'.value '${num}
|
|
| 54 |
done |
|
Formats disponibles : Unified diff