mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Initial version
This commit is contained in:
parent
97977383f1
commit
24b4b3f5a7
1 changed files with 57 additions and 0 deletions
57
plugins/other/postgresql_database_size
Executable file
57
plugins/other/postgresql_database_size
Executable file
|
@ -0,0 +1,57 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Plugin to monitor PostgreSQL Database Sizes
|
||||||
|
#
|
||||||
|
# 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:
|
||||||
|
# 2007/11/30 - Review on comments
|
||||||
|
#
|
||||||
|
|
||||||
|
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 database size on the PostgreSQL Server.'
|
||||||
|
echo 'graph_title PostgreSQL Database Sizes'
|
||||||
|
echo 'graph_vlabel Size (bytes)'
|
||||||
|
|
||||||
|
psql -h ${dbserver} -U ${dbuser} -tc "SELECT datname FROM pg_database ORDER BY 1;" | while read name
|
||||||
|
do
|
||||||
|
test -z "${name}" && continue
|
||||||
|
echo ${name}'.label '${name}
|
||||||
|
echo ${name}'.type GAUGE'
|
||||||
|
if [ "${name}" == "template0" ]; then
|
||||||
|
echo ${name}'.info PostgreSQL template database.'
|
||||||
|
elif [ "${name}" == "template1" ]; then
|
||||||
|
echo ${name}'.info PostgreSQL and/or user template database.'
|
||||||
|
elif [ "${name}" == "postgres" ]; then
|
||||||
|
echo ${name}'.info User postgres database.'
|
||||||
|
else
|
||||||
|
echo ${name}'.info User defined database.'
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
psql -h ${dbserver} -U ${dbuser} -tc "SELECT datname, PG_DATABASE_SIZE(oid) FROM pg_database ORDER BY 1;" | while read name sep num
|
||||||
|
do
|
||||||
|
test -z "${name}" && continue
|
||||||
|
echo ${name}'.value '${num}
|
||||||
|
done
|
Loading…
Add table
Add a link
Reference in a new issue