mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Initial version
This commit is contained in:
parent
090a44055b
commit
97977383f1
1 changed files with 57 additions and 0 deletions
57
plugins/other/postgresql_database_ratio
Executable file
57
plugins/other/postgresql_database_ratio
Executable file
|
@ -0,0 +1,57 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor PostgreSQL Database Ratios (blocks read X blocks hit)
|
||||
#
|
||||
# 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 1000 --lower-limit 0 --upper-limit 100'
|
||||
echo 'graph_category Postgresql'
|
||||
echo 'graph_info Shows each database read/hit (%) on the PostgreSQL Server.'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_title PostgreSQL Database Hit/Read Ratios'
|
||||
echo 'graph_vlabel % of blocks read and hits'
|
||||
|
||||
psql -h ${dbserver} -U ${dbuser} -tc "SELECT datname FROM pg_stat_database WHERE datname != 'template0' ORDER BY 1;" | while read name
|
||||
do
|
||||
test -z "${name}" && continue
|
||||
echo ${name}'.label '${name}
|
||||
echo ${name}'.type GAUGE'
|
||||
echo ${name}'.min 0'
|
||||
echo ${name}'.max 100'
|
||||
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.'
|
||||
echo ${name}'.critical 50:min'
|
||||
echo ${name}'.warning 75:min'
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
psql -h ${dbserver} -U ${dbuser} -tc "SELECT '\n'||datname||'.value '||(CASE WHEN (blks_hit > 0) THEN ROUND((blks_hit::NUMERIC / (blks_hit + blks_read)::NUMERIC) * 100, 2) ELSE 0 END)::TEXT FROM pg_stat_database WHERE datname != 'template0' ORDER BY datname;"
|
Loading…
Add table
Add a link
Reference in a new issue