Sha256: f29917bbb77570a5cefbfc08fbb6da5509679eb3d18b7b62cf8a6ac3656822e6
Contents?: true
Size: 1.34 KB
Versions: 6
Compression:
Stored size: 1.34 KB
Contents
module Marty::Diagnostic::Database def self.db_name ActiveRecord::Base.connection_config[:database] end def self.db_server_name ActiveRecord::Base.connection_config[:host] || 'undefined' end def self.db_adapter_name ActiveRecord::Base.connection.adapter_name end def self.db_time ActiveRecord::Base.connection.execute('SELECT NOW();')[0]['now'] end def self.db_version ActiveRecord::Base.connection.execute('SELECT VERSION();')[0]['version'] end def self.db_schema current = ActiveRecord::Migration.current_version raise "Migration is needed.\nCurrent Version: #{current}" if ActiveRecord::Base.connection.migration_context.needs_migration? current.to_s end def self.get_postgres_connections conn = ActiveRecord::Base.connection.execute('SELECT datname,'\ 'application_name,'\ 'state,'\ 'pid,'\ 'client_addr '\ 'FROM pg_stat_activity') conn.each_with_object({}) do |conn, h| h[conn['datname']] ||= [] h[conn['datname']] << conn.except('datname') end end def self.current_connections get_postgres_connections[db_name] end end
Version data entries
6 entries across 6 versions & 1 rubygems