diff --git a/plugins/other/postgresql_active_locks b/plugins/other/postgresql_active_locks new file mode 100755 index 00000000..95d0ecd5 --- /dev/null +++ b/plugins/other/postgresql_active_locks @@ -0,0 +1,57 @@ +#!/bin/bash +# +# Plugin to monitor PostgreSQL Locks +# +# Author: +# Guilherme Augusto da Rocha Silva +# +# 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