Adding a custom PostgreSQL monitor to collectd
The primary reason we chose to install collectd stems from its ability to monitor arbitrary data points. Due to the existence of a PostgreSQL plugin for collectd, we can actually collect data from the database itself. Monitoring PostgreSQL becomes as easy as writing a query!
We'll include a few sample queries we developed for monitoring PostgreSQL servers. Feel free to develop your own as we explain how to leverage the PostgreSQL collectd module.
Getting ready
As the collectd PostgreSQL module needs to log in to a database within the cluster to gather its statistics, we should create a user specifically for this purpose. Execute this SQL query with an appropriate password:
CREATE USER perf_mon WITH PASSWORD 'testpw';
In addition, follow the instructions in the Installing and configuring collectd recipe so that there is a fully-functional collectd client and server.
How to do it...
To create a collectd custom PostgreSQL query, simply follow these steps...