This file is indexed.

/usr/lib/xymon/server/ext/pgbouncer is in hobbit-plugins 20131022.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/perl

# Copyright (C) 2012 Christoph Berg <myon@debian.org>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

use strict;
use warnings;
use DBD::Pg;
use Hobbit;

my $hosts = Hobbit::grep ('pgbouncer');

foreach my $host (@$hosts) {
	my $bb = new Hobbit({ hostname => $host->{hostname}, test => 'pgbouncer' });
	$bb->add_color ('green');
	my $trends = Hobbit::trends($host->{hostname});
	my $hostname = $host->{hostname};

	my $dbh = DBI->connect("dbi:Pg:dbname=pgbouncer host=$hostname port=6432",
		'hobbit', '',
		{AutoCommit => 1, RaiseError => 1, PrintError => 1});

	$bb->print ("Connections:\n");
	my $q = $dbh->prepare ("SHOW POOLS");
	$q->execute;
	while (my $row = $q->fetchrow_hashref) {
		next if ($row->{database} eq 'pgbouncer');
		$bb->print ("$row->{user}\@$row->{database}:\n");
		$bb->print ("  clients: active  $row->{cl_active}\n");
		$bb->print ("           waiting $row->{cl_waiting}\n");
		$bb->print ("  server connections: active $row->{sv_active}\n");
		$bb->print ("                      idle   $row->{sv_idle}\n");
		$bb->print ("                      used   $row->{sv_used}\n");
		$bb->print ("                      tested $row->{sv_tested}\n");
		$bb->print ("                      login  $row->{sv_login}\n");
		$trends->print ("[pgbouncer,conns,$row->{database},$row->{user}.rrd]\n");
		$trends->print ("DS:cl_active:GAUGE:600:U:U $row->{cl_active}\n");
		$trends->print ("DS:cl_waiting:GAUGE:600:U:U $row->{cl_waiting}\n");
		$trends->print ("DS:sv_active:GAUGE:600:U:U $row->{sv_active}\n");
		$trends->print ("DS:sv_idle:GAUGE:600:U:U $row->{sv_idle}\n");
		$trends->print ("DS:sv_used:GAUGE:600:U:U $row->{sv_used}\n");
		$trends->print ("DS:sv_tested:GAUGE:600:U:U $row->{sv_tested}\n");
		$trends->print ("DS:sv_login:GAUGE:600:U:U $row->{sv_login}\n");
		$trends->print ("DS:maxwait:GAUGE:600:U:U $row->{maxwait}\n");
	}

	$bb->print ("\nStatistics:\n");
	$q = $dbh->prepare ("SHOW STATS");
	$q->execute;
	while (my $row = $q->fetchrow_hashref) {
		next if ($row->{database} eq 'pgbouncer');
		$bb->print ("$row->{database}:\n");
		$bb->print ("  total requests: $row->{total_requests}\n");
		$bb->print ("  total received: $row->{total_received}\n");
		$bb->print ("  total sent: $row->{total_sent}\n");
		$trends->print ("[pgbouncer,stats,$row->{database}.rrd]\n");
		$trends->print ("DS:requests:DERIVE:600:U:U $row->{total_requests}\n");
		$trends->print ("DS:received:DERIVE:600:U:U $row->{total_received}\n");
		$trends->print ("DS:sent:DERIVE:600:U:U $row->{total_sent}\n");
	}

	$bb->graph ('pgbouncer_traffic');
	$bb->graph ('pgbouncer_requests');

	$bb->send;
	$trends->send;
}