Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph for connection count grouped by database on database server? Possible? #159

Open
xtpclark opened this issue Jul 15, 2020 · 1 comment

Comments

@xtpclark
Copy link

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

@xtpclark
Copy link
Author

pg.db.discovery[{$PG_CONN},{$PG_DB}] does most of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant