[check_postgres] pnp4nagios template stack_outline.php rewritten

George Hansper georgeh at infoxchange.org.au
Fri Feb 20 01:06:57 UTC 2015


Hi,

I have recently rewritten the pnp4nagios template stack_outline.php

This was originally posted to this mailing list by Cédric Villemain

Like the original version, it is extraordinarily easy to create pnp4nagios templates using the file stack_outline.php

Simple example:
check_postgres_database_size.php

<?php

$opt[1] = "--vertical-label \"DB size\"  --title \"database size per DB | $hostname\" ";

require('stack_outline.php');

?>

The above gives you one graph, with all the databases on it.
A second graph with the execution time is also rendered.

Sophisticated example:

<?php

$opt[1] = "--vertical-label \"locks\"  --title \"Locks per database | $hostname\" “;

$LIMIT=5;
$FILL=true;
$STACK=true;

$REGEX=‘/dev/';
require('stack_outline.php’);

$REGEX=‘/test/';
require('stack_outline.php');

$REGEX=‘/dev|test/';
$REGEX_EXCLUDE=true;
require('stack_outline.php');

?>

This give 3 or more graphs, with no more than 5 items per graph.
Dev and test are shown separately (if present).

If there are no Data Sources with ‘dev’ in the name, no graph is rendered by stack_outline.php, and no error is generated.
The other graphs are still rendered.

This template will also work if you set a config with
RRD_STORAGE_TYPE = MULTIPLE

eg. If  you are using nrpe, you would use  /etc/pnp4nagios/check_commands/check_postgres_locks.cfg
CUSTOM_TEMPLATE = 1
RRD_STORAGE_TYPE = MULTIPLE

I would recommend using this option, as rrdtool will continue to operate normally even when databases are added and removed.
When using the default ( RRD_STORAGE_TYPE = SINGLE ) rrdtool stops adding data when something like this changes,
on the grounds that the data supplied no longer matches what’s in the file.
The additional disk space required by using MULTIPLE is quite small in practise.
--

George Hansper | Senior Linux Systems Administrator

Infoxchange Australia  |  Ph (03) 9418 7429 | Mobile 0449 55 20 57 | www.infoxchange.net.au<http://www.infoxchange.net.au/>  | 33 Elizabeth Street, Richmond Victoria 3121
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.endcrypt.com/pipermail/check_postgres/attachments/20150220/62ae0b10/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stack_outline.php
Type: text/php
Size: 7425 bytes
Desc: stack_outline.php
URL: <https://mail.endcrypt.com/pipermail/check_postgres/attachments/20150220/62ae0b10/attachment-0001.bin>


More information about the Check_postgres mailing list