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