#!@@PERL@@
# -*- cperl -*-
#
# Copyright (C) 2009 Magnus Hagander, Redpill Linpro AB
#
# 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_bgwriter_ - Plugin to monitor the PostgreSQL Background Writer.

=head1 CONFIGURATION

Configuration is done through libpq environment variables, for example
PGUSER, PGDATABASE, etc. For more information, see L<Munin::Plugin::Pgsql>.

=head1 SEE ALSO

L<Munin::Plugin::Pgsql>

=head1 MAGIC MARKERS

 #%# family=auto
 #%# capabilities=autoconf

=head1 AUTHOR

Magnus Hagander <magnus@hagander.net>, Redpill Linpro AB

=head1 COPYRIGHT/License.

Copyright (c) 2009 Magnus Hagander, Redpill Linpro AB

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 strict;
use warnings;

use Munin::Plugin::Pgsql;

my $pg = Munin::Plugin::Pgsql->new(
    minversion => 8.3,
    title      => 'PostgreSQL bgwriter',
    info       => 'bgwriter buffer statistics',
    vlabel     => 'buffers / second',
    basequery =>
        "SELECT buffers_checkpoint,buffers_clean,buffers_backend,buffers_alloc FROM pg_stat_bgwriter",
    pivotquery  => 1,
    configquery => "VALUES
           ('buffers_checkpoint','Buffers at checkpoint', 'Buffers written when performing a checkpoint'),
           ('buffers_clean','Buffers cleaned', 'Buffers cleaned by background bgwriter runs'),
           ('buffers_backend', 'Buffers by backend', 'Buffers written by backends and not the bgwriter'),
           ('buffers_alloc', 'Buffers allocated', 'Buffers allocated globally')",
    graphtype => 'DERIVE'
);

$pg->Process();

