Projet

Général

Profil

Révision cd68f192

IDcd68f192d52d90b0c5a2ac8c7f9271b561b258ad
Parent 65e4a94c
Enfant e397a73d

Ajouté par Vincas Dargis il y a presque 10 ans

pgbouncer_: allow to separate plugin name and pool name

Voir les différences:

plugins/postgresql/pgbouncer_
16 16
my $db_port = $ENV{'pgbouncer_port'}  || '6432';
17 17
my $db_host = $ENV{'pgbouncer_host'}  || 'localhost';
18 18
my $db_pass = $ENV{'pgbouncer_pass'}  || '';
19
my $db_pool = $ENV{'pgbouncer_pool'}  || '';
19 20
my $db_name = 'pgbouncer';
20 21
my @data = ();
21 22
# get the DB (pool) name we want to fetch
22 23
$plugin_name =~ /pgbouncer_(.*)$/;
23
my $pool_name = $1;
24
my $plugin_suffix = $1;
25
#if pool name is specified explicitly in config file
26
#use plugin name together with pool name in graph title:
27
my $pool_name = ($db_pool) ? $db_pool : $plugin_suffix;
28
my $plugin_title = ($db_pool) ? $plugin_suffix." ".$pool_name : $pool_name;
29

  
24 30
# bail if no name
25 31
if (!$pool_name)
26 32
{
......
52 58
	{
53 59
		# create the basic RRD
54 60
		# stats: average connections
61

  
55 62
		print "multigraph ".$plugin_name."_stats_avg_req\n";
56
		print "graph_title PgBouncer $pool_name average connections\n";
63
		print "graph_title PgBouncer $plugin_title average connections\n";
57 64
		print "graph_args --base 1000\n"; # numbers not bytes
58 65
		print "graph_vlabel Average connections\n";
59 66
		print "graph_scale no\n"; # so we do not print "micro, milli, kilo, etc"
......
64 71
		print $pool_name."_avg_req.draw LINE2\n";
65 72
		# stats: average time for query
66 73
		print "multigraph ".$plugin_name."_stats_avg_query\n";
67
		print "graph_title PgBouncer $pool_name average query time\n";
74
		print "graph_title PgBouncer $plugin_title average query time\n";
68 75
		print "graph_args --base 1000\n"; # numbers not bytes
69 76
		print "graph_vlabel Average time per query (microseconds)\n";
70 77
    		print "graph_category pgbouncer\n";
......
74 81
		print $pool_name."_avg_query.draw LINE2\n";
75 82
		# stats: in/out bytes
76 83
		print "multigraph ".$plugin_name."_stats_bytesinout\n";
77
		print "graph_title PgBouncer $pool_name average bytes received/sent\n";
84
		print "graph_title PgBouncer $plugin_title average bytes received/sent\n";
78 85
		print "graph_args --base 1024\n"; # numbers in bytes
79 86
		print "graph_vlabel Average bytes received (-)/sent (+)\n";
80 87
    		print "graph_category pgbouncer\n";
......
92 99
		print $pool_name."_avg_sent.negative ".$pool_name."_avg_recv\n";
93 100
		# pools: server (sv_)
94 101
		print "multigraph ".$plugin_name."_pools_server\n";
95
		print "graph_title PgBouncer $pool_name servers\n";
102
		print "graph_title PgBouncer $plugin_title servers\n";
96 103
		print "graph_category pgbouncer\n";
97 104
		print "graph_args --base 1000\n"; # numbers not bytes
98 105
		print "graph_vlabel Server connections\n";
......
124 131
		print $pool_name."_server_login.draw STACK\n";
125 132
		# pools: client (cl_)
126 133
		print "multigraph ".$plugin_name."_pools_client\n";
127
		print "graph_title PgBouncer $pool_name clients\n";
134
		print "graph_title PgBouncer $plugin_title clients\n";
128 135
		print "graph_category pgbouncer\n";
129 136
		print "graph_args --base 1000\n"; # numbers not bytes
130 137
		print "graph_vlabel Client connections\n";
......
141 148
		print $pool_name."_client_waiting.draw STACK\n";
142 149
		# pools: maxwait (longest waiting connection, should be 0)
143 150
		print "multigraph ".$plugin_name."_pools_maxwait\n";
144
		print "graph_title PgBouncer $pool_name maximum waiting time\n";
151
		print "graph_title PgBouncer $plugin_title maximum waiting time\n";
145 152
		print "graph_args --base 1000\n"; # numbers not bytes
146 153
		print "graph_vlabel Maximum wait time (seconds)\n";
147 154
    		print "graph_category pgbouncer\n";
......
219 226
=head1 CONFIGURATION
220 227

  
221 228
the plugin that will be run needs to have the pool name after the plugin base name.
229
alternatively, pool name can be specified in config file as env.pgbouncer_pool option, separating plugin name from pool name.
222 230

  
223 231
=head2 plugin configuration
224 232

  
......
241 249
    env.pgbouncer_port 6542
242 250
    env.pgbouncer_host localhost
243 251

  
252
another example, where different pgbouncers (and so munin plugins) connecting to same db:
253
   [pgbouncer_weblogin]
254
     env.pgbouncer_pass barfoo
255
     env.pgbouncer_user bar
256
     env.pgbouncer_port 6542
257
     env.pgbouncer_host localhost
258
     env.pgbouncer_pool dbname
259
    
260
   [pgbouncer_webmain]
261
     env.pgbouncer_pass barfoo
262
     env.pgbouncer_user bar
263
     env.pgbouncer_port 6543
264
     env.pgbouncer_host localhost
265
     env.pgbouncer_pool dbname
266

  
244 267
The database name is always pgbouncer
245 268

  
246 269
=head1 OUTPUT

Formats disponibles : Unified diff