"Fossies" - the Fresh Open Source Software Archive

Member "munin-2.0.52/plugins/node.d/pgbouncer_requests.in" (20 Nov 2019, 2389 Bytes) of package /linux/misc/munin-2.0.52.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!@@PERL@@
    2 # -*- cperl -*-
    3 #
    4 # Copyright (C) 2010 Magnus Hagander, Redpill Linpro AB
    5 #
    6 # This program is free software; you can redistribute it and/or
    7 # modify it under the terms of the GNU General Public License
    8 # as published by the Free Software Foundation; version 2 dated June,
    9 # 1991.
   10 #
   11 # This program is distributed in the hope that it will be useful,
   12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14 # GNU General Public License for more details.
   15 #
   16 # You should have received a copy of the GNU General Public License
   17 # along with this program; if not, write to the Free Software
   18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
   19 # 02110-1301 USA.
   20 
   21 =head1 NAME
   22 
   23 pgbouncer_requests - Plugin to monitor pgbouncer requests.
   24 
   25 =head1 CONFIGURATION
   26 
   27 Configuration is done through libpq environment variables, for example
   28 PGUSER, PGDATABASE, etc. For more information, see L<Munin::Plugin::Pgsql>.
   29 
   30 =head1 SEE ALSO
   31 
   32 L<Munin::Plugin::Pgsql>
   33 
   34 =head1 MAGIC MARKERS
   35 
   36  #%# family=auto
   37  #%# capabilities=autoconf
   38 
   39 =head1 AUTHOR
   40 
   41 Magnus Hagander <magnus@hagander.net>, Redpill Linpro AB
   42 
   43 =head1 COPYRIGHT/License.
   44 
   45 Copyright (c) 2010 Magnus Hagander, Redpill Linpro AB
   46 
   47 All rights reserved. This program is free software; you can
   48 redistribute it and/or modify it under the terms of the GNU General
   49 Public License as published by the Free Software Foundation; version 2
   50 dated June, 1991.
   51 
   52 =cut
   53 
   54 use strict;
   55 use warnings;
   56 
   57 use Munin::Plugin::Pgsql;
   58 
   59 my $pg = Munin::Plugin::Pgsql->new(
   60     title       => 'PgBouncer queries',
   61     info        => 'Number of queries per second',
   62     vlabel      => 'Queries / sec',
   63     defaultdb   => 'pgbouncer',
   64     basequery   => "SHOW STATS",
   65     postprocess => \&PgBouncerStatsCounter,
   66     configquery => "SHOW STATS",
   67     postconfig  => \&PgBouncerStatsConfig,
   68     graphtype   => 'DERIVE',
   69     graphmin    => 0,
   70 );
   71 
   72 $pg->Process();
   73 
   74 sub PgBouncerStatsConfig {
   75     my $pgresult = shift;
   76 
   77     my @outres;
   78 
   79     foreach my $row (@$pgresult) {
   80         push @outres, [$row->[0], $row->[0]] unless ($row->[0] eq "pgbouncer");
   81     }
   82 
   83     return \@outres;
   84 }
   85 
   86 sub PgBouncerStatsCounter {
   87     my $pgresult = shift;
   88 
   89     my @outres;
   90 
   91     foreach my $row (@$pgresult) {
   92         push @outres, [$row->[0], $row->[1]] unless ($row->[0] eq "pgbouncer");
   93     }
   94 
   95     return \@outres;
   96 }