2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/other/postgresql_active_locks

58 lines
1.7 KiB
Plaintext
Raw Normal View History

2007-11-30 12:45:21 +01:00
#!/bin/bash
#
# Plugin to monitor PostgreSQL Locks
#
# 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 --lower-limit 0'
echo 'graph_category Postgresql'
echo 'graph_info Shows active locks on database server.'
echo 'graph_scale no'
echo 'graph_title PostgreSQL Active Locks'
echo 'graph_vlabel Number of active locks'
echo 'AccessExclusive.label AccessExclusive'
echo 'AccessExclusive.info Access Exclusive Lock.'
echo 'AccessShare.label AccessShare'
echo 'AccessShare.info Access Share Lock.'
echo 'Exclusive.label Exclusive'
echo 'Exclusive.info Exclusive Lock.'
echo 'RowExclusive.label RowExclusive'
echo 'RowExclusive.info Row Exclusive Lock.'
echo 'RowShare.label RowShare'
echo 'RowShare.info Row Share Lock.'
echo 'Share.label Share'
echo 'Share.info Share Lock.'
echo 'ShareRowExclusive.label ShareRowExclusive'
echo 'ShareRowExclusive.info Share Row Exclusive Lock.'
echo 'ShareUpdateExclusive.label ShareUpdateExclusive'
echo 'ShareUpdateExclusive.info Share Update Exclusive Lock.'
exit 0
fi
psql -h ${dbserver} -U ${dbuser} -tc "SELECT trim(mode, 'Lock'), COUNT(*) FROM pg_locks GROUP BY mode ORDER BY 1;" | while read name sep num
do
test -z "${name}" && continue
echo ${name}'.value '${num}
done