I am currently using:
pg.query.string[{$PG_CONN},{$PG_DB}, "SELECT 'Total:'||count(*)||E' '||string_agg(usename||':'||datname,E'\t') from pg_stat_activity WHERE usename !='postgres';"]
Which produces a text list of users and the database they are connected to. I would like to have that in a zabbix graph and I am not sure how to accomplish this. I have tried pg.db.numbackends[{$PG_CONN},{$PG_DB}] but gives the total connections.
The query is:
SELECT datname, count(*) from pg_stat_activity
AND application_name ~'MyApp'
GROUP BY datname ;
Result for graphing on 2 axis should be:
x0=db1, y0=10
x1=db2, y1=40
x2=db3, y2=2
etc.
I am happy to read the manuals for both zabbix/libzbxpgsql and I have looked for how to accomplish this, including looking at a munin graph which did this, but I am not seeing how to do this in zabbix with libzbx.
Hello,
I am currently using: pg.query.string[{$PG_CONN},{$PG_DB}, "SELECT 'Total:'||count(*)||E' '||string_agg(usename||':'||datname,E'\t') from pg_stat_activity WHERE usename !='postgres';"]
Which produces a text list of users and the database they are connected to. I would like to have that in a zabbix graph and I am not sure how to accomplish this. I have tried pg.db.numbackends[{$PG_CONN},{$PG_DB}] but gives the total connections.
The query is: SELECT datname, count(*) from pg_stat_activity AND application_name ~'MyApp' GROUP BY datname ;
Result for graphing on 2 axis should be: x0=db1, y0=10 x1=db2, y1=40 x2=db3, y2=2 etc.
I am happy to read the manuals for both zabbix/libzbxpgsql and I have looked for how to accomplish this, including looking at a munin graph which did this, but I am not seeing how to do this in zabbix with libzbx.
Best regards