Module Munin pg_commit_rollback
Ce module Munin permet de suivre le nombre de commit et de rollback, sur l'ensemble des bases d'un serveur PostgreSQL.
Pour utiliser ce fichier, sauvegardez le sous le nom « pg_commit_rollback » dans le répertoire de vos modules Munin (« /etc/munin/plugins »).
# pg_commit_rollback: Munin plugin used to monitor the number of
# commit and rollback of a PostgreSQL server
#
# pg_commit_rollback : module Munin de suivi du nombre de commit
# et de rollback d'un serveur PostgreSQL
#
# (c) 2007 Jean-Philippe Guérard
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Ce programme est un logiciel libre. Vous pouvez le redistribuer
# et le modifier selon les termes de la Licence publique générale
# GNU (GPL) version 2 ou supérieure, telle que publiée par la Free
# Software Foundation.
#
# Ce programme est distribué dans l'espoir qu'il se révélera
# utile, mais sans aucune garantie, ni explicite ni implicite,
# y compris les garanties de commercialisation ou d'adaptation
# à un but spécifique. Reportez-vous à la Licence Publique
# Générale GNU pour plus d'informations.
# Installation
# To use this plugin, you need to add the following
# 2 lines to the plugin configuration file:
#
# Pour utiliser ce module, ajoutez les deux lignes
# ci-dessous à votre fichier de paramétrage des
# modules Munin :
#
# [pg_commit_rollback]
# user postgres
PATH=/usr/bin:/bin
# Display plugin config if requested
if [ "${1}" = "config" ] ; then
cat <<'FDT'
graph_title PostgreSQL commit and rollback
graph_args --base 1000 -l 0
graph_category PostgreSQL
graph_vlabel transactions
graph_info PostgreSQL number of commit and rollback
commit.info Number of commits
commit.label commit
commit.type DERIVE
rollback.info Number of rollback
rollback.label rollback
rollback.type DERIVE
FDT
exit 0
fi
# Database request
COMMIT_ROLLBACK=$(psql -A -t \
-c "select sum(xact_commit),sum(xact_rollback) \
from pg_stat_database where datname \
not in ('postgres','template0','template1') ;" postgres)
# Display total commit count
COMMIT=$(echo "${COMMIT_ROLLBACK}" | gawk -F "|" '{print $1}')
echo "commit.value ${COMMIT}"
# Display total rollback count
ROLLBACK=$(echo "${COMMIT_ROLLBACK}" | gawk -F "|" '{print $2}')
echo "rollback.value ${ROLLBACK}"
exit 0