Method: PgHero::Methods::Connections#connection_sources

Defined in:
lib/pghero/methods/connections.rb

#connection_sourcesObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/pghero/methods/connections.rb', line 59

def connection_sources
  select_all <<~SQL
    SELECT
      datname AS database,
      usename AS user,
      application_name AS source,
      client_addr AS ip,
      COUNT(*) AS total_connections
    FROM
      pg_stat_activity
    GROUP BY
      1, 2, 3, 4
    ORDER BY
      5 DESC, 1, 2, 3, 4
  SQL
end