Sha256: c046e4b96656e84ae30e477fe03466c70382bfb81e36235e7d4f3a2af1f17653

Contents?: true

Size: 576 Bytes

Versions: 11

Compression:

Stored size: 576 Bytes

Contents

module PgHero
  module Methods
    module Connections
      def total_connections
        select_one("SELECT COUNT(*) FROM pg_stat_activity")
      end

      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
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pghero-2.1.1 lib/pghero/methods/connections.rb
pghero-2.1.0 lib/pghero/methods/connections.rb
pghero-2.0.8 lib/pghero/methods/connections.rb
pghero-2.0.7 lib/pghero/methods/connections.rb
pghero-2.0.6 lib/pghero/methods/connections.rb
pghero-2.0.5 lib/pghero/methods/connections.rb
pghero-2.0.4 lib/pghero/methods/connections.rb
pghero-2.0.3 lib/pghero/methods/connections.rb
pghero-2.0.2 lib/pghero/methods/connections.rb
pghero-2.0.1 lib/pghero/methods/connections.rb
pghero-2.0.0 lib/pghero/methods/connections.rb