postgres 为连接存储哪些信息

发布于 2024-10-30 18:27:31 字数 437 浏览 0 评论 0原文

寻找 PostgreSQL 存储的更多连接信息。

我确实找到了这些查询:

SELECT datname, numbackends 
FROM pg_stat_database
WHERE numbackends > 0
ORDER BY numbackends DESC, datname

SELECT datname, COUNT(*) AS numbackends
FROM pg_stat_activity 
GROUP BY datname HAVING COUNT(*) > 0

但我想找出哪些脚本或 IP 正在连接或当前连接到 PostgreSQL,有什么可以捕获此信息吗?

脚本或 IP 进行过滤的即时报告

注意:打开日志记录不是我正在寻找的解决方案,更多的是我可以通过连接到数据库Postgres 版本 7.4 的

Looking to find more connection information that PostgreSQL stores.

I did find these queries:

SELECT datname, numbackends 
FROM pg_stat_database
WHERE numbackends > 0
ORDER BY numbackends DESC, datname

SELECT datname, COUNT(*) AS numbackends
FROM pg_stat_activity 
GROUP BY datname HAVING COUNT(*) > 0

But I'm looking to find out what script(s) or IP's are connecting or have current connections to PostgreSQL, is there anything that captures this information?

NOTE: Turning Logging on is not the solution I'm looking for, more of a on the fly report I can filter by the script or IP connecting to the database

Postgres version 7.4

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春花秋月 2024-11-06 18:27:31

连接的客户端的IP地址也记录在pg_stat_activity中,就像当前运行的语句一样(如果有的话)

SELECT usename, 
       application_name, -- only valid for 9.x 
       client_addr, 
       backend_start,
       query_start,
       current_query
FROM pg_stat_activity

The IP address of the connected clients is also recorded in pg_stat_activity, just as the currently running statement (if any)

SELECT usename, 
       application_name, -- only valid for 9.x 
       client_addr, 
       backend_start,
       query_start,
       current_query
FROM pg_stat_activity
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文