From 0b4260198b9abbef76961b1089866da37a698ce2 Mon Sep 17 00:00:00 2001 From: Gilles Date: Tue, 28 May 2013 11:31:47 +0200 Subject: [PATCH] p/postgres_tuplesratio: ratio of live/dead tuples --- plugins/postgresql/postgres_tuplesratio_ | 79 ++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 plugins/postgresql/postgres_tuplesratio_ diff --git a/plugins/postgresql/postgres_tuplesratio_ b/plugins/postgresql/postgres_tuplesratio_ new file mode 100644 index 00000000..4826c44b --- /dev/null +++ b/plugins/postgresql/postgres_tuplesratio_ @@ -0,0 +1,79 @@ +#!/usr/bin/perl +# -*- cperl -*- +# +# Copyright (C) 2013 Gilles Fauvie, OPENDBTEAM.com (INTEGER S.P.R.L) +# +# 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; version 2 dated June, +# 1991. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA. + +=head1 NAME + +postgres_tuplesratio_ - Plugin to monitor PostgreSQL live/dead tuples ratio. + +=head1 CONFIGURATION + +Configuration is done through libpq environment variables, for example +PGUSER, PGDATABASE, etc. For more information, see L. + +To monitor a specific database, link to postgres_tuplesratio_. +To monitor all databases, link to postgres_tuplesratio_ALL. + +=head1 SEE ALSO + +L + +=head1 MAGIC MARKERS + + #%# family=auto + #%# capabilities=autoconf suggest + +=head1 AUTHOR + +Gilles Fauvie , OPENDBTEAM.com (INTEGER S.P.R.L) + +=head1 COPYRIGHT/License. + +Copyright (c) 2013 Gilles Fauvie, OPENDBTEAM.com (INTEGER S.P.R.L) + +All rights reserved. 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; version 2 +dated June, 1991. + +=cut + +use warnings; +use strict; + +use Munin::Plugin::Pgsql; + +my $pg = Munin::Plugin::Pgsql->new( + basename => 'postgres_tuplesratio_', + title => 'PostgreSQL tuples ratio', + info => 'Ratio dead/live tuples of a database', + vlabel => 'Nbr', + paramdatabase => 1, + pivotquery => 1, + basequery => + "select sum(n_live_tup) as livetup, sum(n_dead_tup) as deadtup from pg_stat_user_tables", + configquery => "values('livetup', 'livetup'), ('deadtup', 'deadtup')", + suggestquery => + "SELECT datname FROM pg_database WHERE datallowconn AND NOT datistemplate AND NOT datname='postgres' UNION ALL SELECT 'ALL' ORDER BY 1 LIMIT 10", + graphdraw => 'AREA', + stack => 1 +); + +$pg->Process(); +exit(0);