I would like to use monit and M/Monit to monitor our Postgresql database. Setting it up to monitor the Postgresql process is simple enough. The next most important thing for us to monitor is the number of connections.
Current solution
I can write a bash script that will query the number of connections. The script will exit with a status code equal to the number of connections. I can call this script from Monit using
check program pg-replication-lag with path /tmp/count-connections.sh
if status > 45 then alert
This will alert if more than 45 connections are consumed.
Problem
While getting alerts in such situations is very important, we would also like to visualize the number of connections over time. M/Monit has some great graphs of systems variables like RAM, CPU, etc..., but I do not see any way of graphing a check program
status value in M/Monit, but I hope that I am just overlooking it.
Is it possible to graph arbitrary data collected by check program
? Can anyone think of a better way to collect this data and visualize it in M/Monit?
PS: Though I used the number of connections as an example here, there is other numeric data that we would like to plot over time as well (e.g. replication lag).