1

I intend to write a script to alert me when the number of connections active in my PostgreSQL server exceeds a certain threshold. Where can I find this number in a form I can use for comparison in a script?

My PostgreSQL version is 8.4.8, and my operating system is Debian Squeeze.

  • Possible duplicate of [How can you get the active users connected to a postgreSQL database via SQL?](http://stackoverflow.com/questions/464623/how-can-you-get-the-active-users-connected-to-a-postgresql-database-via-sql) – Brad Koch Aug 09 '16 at 14:57

1 Answers1

2

It's in the pg_catalog.pg_stat_activity view. Each row is a connection.

Eelke
  • 20,897
  • 4
  • 50
  • 76
  • 3
    Thanks. With this information and some help from #postgres on freenode, I have arrived at the following solution: `psql -Atc 'SELECT count(*) FROM pg_stat_activity'` –  Apr 03 '13 at 18:45