mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
50 lines
1.5 KiB
Plaintext
50 lines
1.5 KiB
Plaintext
|
#!/bin/bash
|
||
|
#
|
||
|
# Plugin to monitor PostgreSQL Backends
|
||
|
#
|
||
|
# 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
|
||
|
maximum=$(psql -h ${dbserver} -U ${dbuser} -tc "SHOW max_connections;" | bc)
|
||
|
reserved=$(psql -h ${dbserver} -U ${dbuser} -tc "SHOW superuser_reserved_connections;" | bc)
|
||
|
warning=$(((maximum-reserved)*70/100))
|
||
|
critical=$(((maximum-reserved)*90/100))
|
||
|
echo 'graph_args --base 1000 --lower-limit 0 --upper-limit '${maximum}
|
||
|
echo 'graph_category Postgresql'
|
||
|
echo 'graph_info Shows open backends on the PostgreSQL Server.'
|
||
|
echo 'graph_scale no'
|
||
|
echo 'graph_title PostgreSQL Active Backends'
|
||
|
echo 'graph_vlabel Number of active backends'
|
||
|
echo 'backends.label backends'
|
||
|
echo 'backends.type GAUGE'
|
||
|
echo 'backends.min 0'
|
||
|
echo 'backends.max '${maximum}
|
||
|
echo 'backends.warning '${warning}
|
||
|
echo 'backends.critical '${critical}
|
||
|
echo 'backends.info Number of open sessions.'
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
echo 'backends.value '$(psql -h ${dbserver} -U ${dbuser} -tc "SELECT SUM(numbackends) FROM pg_stat_database;" | bc)
|