[collectd] how to set a threshold using postgresql plugin

Marc Fournier marc.fournier at camptocamp.com
Fri Mar 11 10:11:03 CET 2016


Gerardo Herzig <gherzig at fmed.uba.ar> writes:

> Hi all. Im sending collectd values from a postgres DB to our collectd central server.
> In DB, there is using postgres plugin like:
>
> <Query db_movements>
>   Statement "select sum(numbackends) as backends, sum(tup_inserted) as inserts, sum(tup_updated) as updates, sum(tup_deleted) as deletes 
>   from pg_stat_database;"
>   <Result>
>     Type gauge
>     InstancePrefix total_backends
>     ValuesFrom "backends"
>   </Result>
> </Query>
> <Database template1>
>         Interval 10
>         Host localhost
>         User postgres
>         Query db_movements
> </Database>
>
> And, in the "central" collectd server i want to set a threshold for that server, so
> " If that db server is over 100 connections in use, ALERT "
>
> At that point, i got confused about how to get it work.
> I have something like that:
>
> <Host "db_server">
>     <Plugin "postgresql-template1">
>       <Instance "total_backends">
>         FailureMax 100.0
>       </Instance>
>     </Plugin>
>  </Host>
>
>
> It throws no error, but even if i put a FailureMax of 2 or so, alert is not raising.
> So, anyone can help me to know to set that alert?

I don't think the above specification will match the value you're trying
to track.

Try something like this:

<Host "db_server">
  <Plugin "postgresql">
    Instance "template1"
    <Type "gauge">
      Instance "total_backends"
      FailureMax 100.0
    </Type>
  </Plugin>
</Host>

You might want to enable the unixsock plugin and run
"collectdctl listval" to make sure your specification actually matches
an existing element name.

Also, take a look at https://collectd.org/wiki/index.php/Naming_schema

Marc



More information about the collectd mailing list