Munin::...::Pgsql(3)
Hey bestie π welcome to the Munin::...::Pgsql(3) page β it's part of the User Contributed Perl Documentation, and it's all about Munin::Plugin::Pgsql, the base module that PostgreSQL Munin plugins build on. Think of it as the shared group chat that gives all the Postgres plugins their config and API energy. π«Ά
πΈ NAME πΈ
Munin::Plugin::Pgsql β the base module for PostgreSQL plugins for Munin. That's the whole name, and it's iconic. π
β¨ SYNOPSIS β¨
The Munin::Plugin::Pgsql module provides base functionality for all PostgreSQL Munin plugins, including common configuration parameters. It's giving shared foundation, and honestly? Obsessed. β¨
π CONFIGURATION π
All configuration is done through environment variables. No config file drama, just env vars. π
π ENVIRONMENT VARIABLES π
All plugins based on Munin::Plugin::Pgsql accept all the environment variables that libpq does. The most common ones used are:
PGHOSTβ hostname to connect to, or path to Unix socketPGPORTβ port number to connect toPGUSERβ username to connect asPGPASSWORDβ password to connect with, if a password is required
By default, the plugins connect to the 'template1' database β except for wildcard per-database plugins. You can override that with the PGDATABASE variable, but this is usually a bad idea. Like, don't do it unless you know why. π
If you're using the plugin for several Postgres instances, you can customize the graph title with the PGLABEL environment variable. Cute, right? π
Warning and critical can be customized by setting the warning and critical env variables per plugin. Set those thresholds and let the plugin know what's dramatic. π₯
π Example π
[postgres_*]
user postgres
env.PGUSER postgres
env.PGPORT 5433
[postgres_connections_ALL]
env.warning :450
env.critical :500
π¦ WILDCARD MATCHING π¦
Wildcard plugins based on this module match on whatever type of object you specify for a filter β usually a database. If the object name ALL is used (for example, a symlink to postgres_connections_ALL), the filter is not applied, and the plugin behaves like a non-wildcard one. It's literally just doing the most. β¨
π REQUIREMENTS π
The module requires DBD::Pg to work. That's the dependency, no cap. π«Ά
π₯ TODO π₯
Support for using psql instead of DBD::Pg, so the dependency can be removed. Future upgrade vibes. β
π BUGS π
No known bugs at this point. We love a clean slate, periodt. π
π SEE ALSO π
DBD::Pgβ the one and only reference here. Go read it if you need the DBI/Postgres side.
π§ AUTHOR π§
Magnus Hagander <magnus@hagander.net>, Redpill Linpro AB β legendary. π
π COPYRIGHT/License. π
Copyright (c) 2009 Magnus Hagander, Redpill Linpro AB All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 dated June, 1991.
π API DOCUMENTATION π
The following functions are available to plugins using this module. API tea incoming. π«
π Initialization π
use Munin::Plugin::Pgsql;
my $pg = Munin::Plugin::Pgsql->new(
parameter=>value,
parameter=>value
);
π¦ Parameters π¦
minversionβ Minimum PostgreSQL version required, formatted like8.2. If the database is an older version than this, the plugin will exit with an error. π¨categoryβ The category for this plugin. Copied directly to the config output. Default is'db'.titleβ The title for this plugin. Copied directly to the config output.infoβ The info for this plugin. Copied directly to the config output.vlabelβ The vertical label for the graph. Copied directly to the config output.basenameβ For wildcard plugins, this is the base name of the plugin, including the trailing underscore.basequeryβ SQL query run to get the plugin values. The query should return two columns: one is the name of the counter, and the second is the current value for the counter.pivotqueryβ Set to1to indicate that the query inbasequeryreturns a single row, with one field for each counter. The name of the counter is taken from the returned column name, and the value comes from the first row in the result.configqueryβ SQL query run to generate the configuration information for the plugin. The query should return at least two columns, which are the name of the counter and the label of the counter. If a third column is present, it will be used as theinfoparameter.suggestqueryβ SQL query to run to generate the list of suggestions for a wildcard plugin. Don't forget to includeALLif the plugin supports aggregate statistics.autoconfqueryβ SQL query to run as the last step ofautoconf, to determine if the plugin should be run on this machine. Must return a single row, two columns. The first one is a boolean field representing yes or no, and the second one is a reason forno.warningβ The warning low and/or high thresholds.criticalβ The critical low and/or high thresholds.graphdrawβ Thedrawparameter for the graph. The default isLINE1.graphtypeβ Thetypeparameter for the graph. The default isGAUGE.graphperiodβ The period for the graph. Copied directly to the config output.graphminβ Theminparameter for the graph. The default is no minimum.graphmaxβ Themaxparameter for the graph. The default is no maximum.stackβ If set to1, all counters except the first one will be written with a draw type ofSTACK.baseβ Used forgraph_args --base. Default is1000; set to1024when returning sizes in Kb for example.wildcardfilterβ The SQL to substitute for when a wildcard plugin is run against a specific entity, for example a database. All occurrences of the string%%FILTER%%will be replaced with this string, and for each occurrence a parameter with the value of the filtering condition will be added to the DBI statement.paramdatabaseβ Makes the plugin connect to the database in the first parameter (wildcard plugins only) instead of'template1'.defaultdbβ Makes the plugin connect to the database specified in this parameter instead of'template1'.extraconfigβ This string is copied directly into the configuration output when the plugin is run in config mode, allowing low-level customization.postprocessβ A function that's called with the result of the base query, and can post-process the result and return a new resultset.postconfigβ A function that's called with the result of the config query, and can post-process the result and return a new resultset.postautoconfβ A function that's called with the result of the autoconf query, and can post-process the result and return a new resultset.postsuggestβ A function that's called with the result of the suggest query, and can post-process the result and return a new resultset.
π¦ Specifying queries π¦
Queries specified in one of the parameters above can take one of two forms. The easiest one is a simple string, which will then always be executed, regardless of server version. The other form is an array, looking like this:
[
"SELECT 'default',... FROM ...",
[
"8.3", "SELECT 'query for 8.3 or earlier',... FROM ...",
"8.1", "SELECT 'query for 8.1 or earlier',... FROM ..."
]
]
This array is parsed from top to bottom, so the entries must be in order of version number. The last value found where the version specified is higher than or equal to the version of the server will be used (yes, it counts backwards). Iconic logic, honestly. π
β Processing β
$pg->Process();
This command executes the plugin. It will automatically parse the ARGV array for commands given by Munin. So you don't have to do the parsing yourself β it's got main character energy. π
π That's the whole Munin::...::Pgsql(3) page, bestie! It comes from perl v5.42.3, dated 1980-01-01, and now you're all set to understand these PostgreSQL Munin plugins. Go forth and slay your monitoring. πβ¨
π¦ where this page comes from
- nixos 26.05: munin 2.0.76
- nixpkgs unstable: munin 2.0.78
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms