libzbxpgsql
libzbxpgsql copied to clipboard
Add 'state' parameter to pg.backends.count
We can monitor idle connections by - SELECT COUNT(datid) FROM pg_stat_activity where state='idle'; but currently monitoring of idle pgsql connections are not available.
I suppose it should be done in pg.backends.count in which currently implemented -something similar SELECT COUNT(datid) FROM pg_stat_activity where waiting='f';
I did have this working at some stage but from memory, the state column was only introduced recently (maybe 9.2?). I'll take a look again at reimplementing it with graceful failure on older versions.
In the meantime, you can execute a custom query using pg.query.int
http://cavaliercoder.com/libzbxpgsql/agent-keys/queries/#pg-query-integer
Thx, just done it with - pg.query.integer[,,"SELECT COUNT(datid) FROM pg_stat_activity WHERE state='idle';",]
But it works only with superuser rights :(
p.s. Postgres 9.3.
Awesome thanks. I'll look at adding a native key in the next version.