mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Initial version
This commit is contained in:
parent
24b4b3f5a7
commit
c7cc092609
54
plugins/other/postgresql_tablespace_size
Executable file
54
plugins/other/postgresql_tablespace_size
Executable file
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor PostgreSQL Tablespaces Size
|
||||
#
|
||||
# Author:
|
||||
# Guilherme Augusto da Rocha Silva <gars.dba@gmail.com>
|
||||
#
|
||||
# Created:
|
||||
# 5th of november 2007
|
||||
#
|
||||
# Usage:
|
||||
# Place in /etc/munin/plugins/ (or link it there using ln -s)
|
||||
#
|
||||
# Parameters:
|
||||
# config (required)
|
||||
#
|
||||
# General info:
|
||||
# Require permission for database access and read (no writes are processed).
|
||||
# Recomended user is PostgreSQL database owner (default: postgres).
|
||||
#
|
||||
# Log info:
|
||||
#
|
||||
|
||||
dbserver='localhost'
|
||||
dbuser='postgres'
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_args --base 1024 --lower-limit 0'
|
||||
echo 'graph_category Postgresql'
|
||||
echo 'graph_info Shows each tablespace size on the PostgreSQL Server.'
|
||||
echo 'graph_title PostgreSQL Tablespace Sizes'
|
||||
echo 'graph_vlabel Size (bytes)'
|
||||
|
||||
psql -h ${dbserver} -U ${dbuser} -tc "SELECT spcname FROM pg_tablespace ORDER BY 1;" | while read name
|
||||
do
|
||||
test -z "${name}" && continue
|
||||
echo ${name}'.label '${name}
|
||||
echo ${name}'.type GAUGE'
|
||||
if [ "${name}" == "pg_global" ]; then
|
||||
echo ${name}'.info Tablespace for shared system catalogs.'
|
||||
elif [ "${name}" == "pg_default" ]; then
|
||||
echo ${name}'.info Default tablespace of the template1 and template0 databases (and, therefore, the default tablespace for other databases, unless user defined ones).'
|
||||
else
|
||||
echo ${name}'.info User defined tablespace.'
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
psql -h ${dbserver} -U ${dbuser} -tc "SELECT spcname, PG_TABLESPACE_SIZE(oid) FROM pg_tablespace ORDER BY 1;" | while read name sep num
|
||||
do
|
||||
test -z "${name}" && continue
|
||||
echo ${name}'.value '${num}
|
||||
done
|
Loading…
Reference in New Issue
Block a user