1Munin::Plugin::Pgsql(3)User Contributed Perl DocumentatioMnunin::Plugin::Pgsql(3)
2
3
4
6 Munin::Plugin::Pgsql - Base module for PostgreSQL plugins for Munin
7
9 The Munin::Plugin::Pgsql module provides base functionality for all
10 PostgreSQL Munin plugins, including common configuration parameters.
11
13 All configuration is done through environment variables.
14
16 All plugins based on Munin::Plugin::Pgsql accepts all the environment
17 variables that libpq does. The most common ones used are:
18
19 PGHOST hostname to connect to, or path to Unix socket
20 PGPORT port number to connect to
21 PGUSER username to connect as
22 PGPASSWORD password to connect with, if a password is required
23
24 The plugins will by default connect to the 'template1' database, except
25 for wildcard per-database plugins. This can be overridden using the
26 PGDATABASE variable, but this is usually a bad idea.
27
28 Example
29 [postgres_*]
30 user postgres
31 env.PGUSER postgres
32 env.PGPORT 5433
33
35 Wildcard plugins based on this module will match on whatever type of
36 object specifies for a filter, usually a database. If the object name
37 ALL is used (for example, a symlink to postgres_connections_ALL), the
38 filter will not be applied, and the plugin behaves like a non-wildcard
39 one.
40
42 The module requires DBD::Pg to work.
43
45 Support for using psql instead of DBD::Pg, to remove dependency.
46
48 No known bugs at this point.
49
51 DBD::Pg
52
54 Magnus Hagander <magnus@hagander.net>, Redpill Linpro AB
55
57 Copyright (c) 2009 Magnus Hagander, Redpill Linpro AB
58
59 All rights reserved. This program is free software; you can
60 redistribute it and/or modify it under the terms of the GNU General
61 Public License as published by the Free Software Foundation; version 2
62 dated June, 1991.
63
65 The following functions are available to plugins using this module.
66
67 Initialization
68 use Munin::Plugin::Pgsql;
69 my $pg = Munin::Plugin::Pgsql->new(
70 parameter=>value,
71 parameter=>value
72 );
73
74 Parameters
75
76 minversion Minimum PostgreSQL version required, formatted like 8.2. If the
77 database is an older version than this, the plugin will exit
78 with an error.
79 category The category for this plugin. Copied directly to the config
80 output. Default 'PostgreSQL'.
81 title The title for this plugin. Copied directly to the config output.
82 info The info for this plugin. Copied directly to the config output.
83 vlabel The vertical label for the graph. Copied directly to the config
84 output.
85 basename For wildcard plugins, this is the base name of the plugin,
86 including the trailing underscore.
87 basequery SQL query run to get the plugin values. The query should return
88 two columns, one being the name of the counter and the second
89 being the current value for the counter.
90 pivotquery Set to 1 to indicate that the query in basequery returns a single
91 row, with one field for each counter. The name of the counter is
92 taken from the returned column name, and the value from the
93 first row in the result.
94 configquery SQL query run to generate the configuration information for the
95 plugin. The query should return at least two columns, which are
96 the name of the counter and the label of the counter. If
97 a third column is present, it will be used as the info
98 parameter.
99 suggestquery SQL query to run to generate the list of suggestions for a
100 wildcard plugin. Don't forget to include ALL if the plugin
101 supports aggregate statistics.
102 autoconfquery SQL query to run as the last step of "autoconf", to determine
103 if the plugin should be run on this machine. Must return a single
104 row, two columns columns. The first one is a boolean field
105 representing yes or no, the second one a reason for "no".
106 graphdraw The draw parameter for the graph. The default is LINE1.
107 graphtype The type parameter for the graph. The default is GAUGE.
108 graphperiod The period for the graph. Copied directly to the config output.
109 graphmin The min parameter for the graph. The default is no minimum.
110 graphmax The max parameter for the graph. The default is no maximum.
111 stack If set to 1, all counters except the first one will be written
112 with a draw type of STACK.
113 base Used for graph_args --base. Default is 1000, set to 1024 when
114 returning sizes in Kb for example.
115 wildcardfilter The SQL to substitute for when a wildcard plugin is run against
116 a specific entity, for example a database. All occurrences of
117 the string %%FILTER%% will be replaced with this string, and
118 for each occurrence a parameter with the value of the filtering
119 condition will be added to the DBI statement.
120 paramdatabase Makes the plugin connect to the database in the first parameter
121 (wildcard plugins only) instead of 'template1'.
122 defaultdb Makes the plugin connect to the database specified in this
123 parameter instead of 'template1'.
124 extraconfig This string is copied directly into the configuration output
125 when the plugin is run in config mode, allowing low-level
126 customization.
127 postprocess A function that's called with the result of the base query,
128 and can post-process the result and return a new resultset.
129 postconfig A function that's called with the result of the config query,
130 and can post-process the result and return a new resultset.
131 postautoconf A function that's called with the result of the autoconf query,
132 and can post-process the result and return a new resultset.
133 postsuggest A function that's called with the result of the suggest query,
134 and can post-process the result and return a new resultset.
135
136 Specifying queries
137
138 Queries specified in one of the parameters above can take one of two
139 forms. The easiest one is a simple string, which will then always be
140 executed, regardless of server version. The other form is an array,
141 looking like this:
142 [
143 "SELECT 'default',... FROM ...",
144 [
145 "8.3", "SELECT 'query for 8.3 or earlier',... FROM ...",
146 "8.1", "SELECT 'query for 8.1 or earlier',... FROM ..."
147 ]
148 ] This array is parsed from top to bottom, so the entries must be in
149 order of version number. The *last* value found where the version
150 specified is higher than or equal to the version of the server will be
151 used (yes, it counts backwards).
152
153 Processing
154 $pg->Process();
155
156 This command executes the plugin. It will automatically parse the ARGV array
157 for commands given by Munin.
158
159
160
161perl v5.32.1 2021-02-05 Munin::Plugin::Pgsql(3)