From 0b350ce8049e8c5db34751340e015c7a7937664e Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 1 Feb 2009 22:48:01 +0100 Subject: [PATCH] postgresql plugin: Added support for blocks. This is a replacement for the "Column" config option (which has been deprecated). blocks allow for much more flexible handling of the data. Besides being able to use data types with multiple data sources, the plugin now supports to generate the type instance using information from the database. An example block might look like this (taken from the manpage): Type counter InstancePrefix "rt36_tickets" InstancesFrom "type" ValuesFrom "count" --- src/collectd.conf.pod | 99 ++++++++- src/postgresql.c | 425 +++++++++++++++++++++++++++--------- src/postgresql_default.conf | 184 ++++++++++++---- 3 files changed, 559 insertions(+), 149 deletions(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index a92497f0..00c7ed35 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -1589,10 +1589,28 @@ L. - Statement "SELECT magic, spells FROM wizard WHERE host = $1;" + Statement "SELECT magic FROM wizard WHERE host = $1;" Param hostname - Column gauge magic - Column counter spells + + Type gauge + InstancePrefix "magic" + ValuesFrom magic + + + + + Statement "SELECT COUNT(type) AS count, type \ + FROM (SELECT CASE \ + WHEN resolved = 'epoch' THEN 'open' \ + ELSE 'resolved' END AS type \ + FROM tickets) type \ + GROUP BY type;" + + Type counter + InstancePrefix "rt36_tickets" + InstancesFrom "type" + ValuesFrom "count" + @@ -1604,15 +1622,25 @@ L. KRBSrvName "kerberos_service_name" Query magic + Service "service_name" + Query backend # predefined + Query rt36_tickets The B block defines one database query which may later be used by a database definition. It accepts a single mandatory argument which specifies -the name of the query. The names of all queries have to be unique. The -following configuration options are available to define the query: +the name of the query. The names of all queries have to be unique (see the +B and B options below for an exception to this +rule). The following configuration options are available to define the query: + +In each B block, there is one or more B blocks. B +blocks define how to handle the values returned from the query. They define +which column holds which value and how to dispatch that value to the daemon. +Multiple B blocks may be used to extract multiple values from a single +query. =over 4 @@ -1628,6 +1656,8 @@ Any SQL command which may return data (such as C