2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/postgresql/postgresql_transactions
André de Kock 89898512d3 Fixed output of transactions script
The current output of this script is:

root@master:/etc/munin/plugins# ./pg_transactions 
 \ncommits.value xxxx\nrollbacks.value xxxx

By removing the first `\n` and by adding an `E` before the second `\n` the output is:

root@master:/etc/munin/plugins# ./pg_transactions 
 commits.value xxxx +
 rollbacks.value xxxx

And lastly by adding the `--no-align` attribute you get the correct output:

root@master:/etc/munin/plugins# ./pg_transactions 
commits.value xxxx
rollbacks.value xxxx
2017-07-22 11:29:00 +02:00

44 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
#
# Plugin to monitor PostgreSQL Commits and Rollbacks in Transactions
#
# Author:
# Guilherme Augusto da Rocha Silva <gars.dba@gmail.com>
#
# Created:
# 9th 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).
# Recommended user is PostgreSQL database owner (default: postgres).
#
# Log info:
#
dbserver='localhost'
dbuser='postgres'
if [ "$1" = "config" ]; then
echo 'graph_args --base 1000 --lower-limit 0'
echo 'graph_category db'
echo 'graph_info Shows summarized commits and rollbacks in transactions on the PostgreSQL Server.'
echo 'graph_title PostgreSQL Transactions'
echo 'graph_vlabel Number of Commits and Rollbacks'
echo 'commits.label commits'
echo 'commits.min 0'
echo 'commits.info Number of transaction commits.'
echo 'rollbacks.label rollbacks'
echo 'rollbacks.min 0'
echo 'rollbacks.info Number of transaction rollbacks.'
exit 0
fi
psql -h ${dbserver} -U ${dbuser} -tc "SELECT 'commits.value '||SUM(xact_commit)::TEXT||E'\nrollbacks.value '||SUM(xact_rollback)::TEXT FROM pg_stat_database;" --no-align