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