lib/postgres/vacuum/jobs/monitor_job.rb in postgres-vacuum-monitor-0.9.0 vs lib/postgres/vacuum/jobs/monitor_job.rb in postgres-vacuum-monitor-0.10.0
- old
+ new
@@ -4,10 +4,12 @@
class MonitorJob
AUTOVACUUM_LAGGING_EVENT = 'AutoVacuumLagging'.freeze
LONG_TRANSACTIONS = 'LongTransactions'.freeze
BLOCKED_QUERIES = 'BlockedQueries'.freeze
+ CONNECTION_STATE = 'ConnectionState'.freeze
+ CONNECTION_IDLE_TIME = 'ConnectionIdleTime'.freeze
def perform(*)
with_each_db_name_and_connection do |name, connection|
connection.execute(Postgres::Vacuum::Monitor::Query.long_running_transactions).each do |row|
reporter_class.report_event(
@@ -43,9 +45,23 @@
blocked_application: row['blocked_application'],
blocked_statement: row['blocked_statement'],
blocking_pid: row['blocking_pid'],
blocking_application: row['blocking_application'],
current_statement_in_blocking_process: row['current_statement_in_blocking_process']
+ )
+ end
+
+ connection.execute(Postgres::Vacuum::Monitor::Query.connection_state).each do |row|
+ reporter_class.report_event(CONNECTION_STATE, database_name: name, state: row['state'], connection_count: row['connection_count'])
+ end
+
+ connection.execute(Postgres::Vacuum::Monitor::Query.connection_idle_time).each do |row|
+ reporter_class.report_event(
+ CONNECTION_IDLE_TIME,
+ database_name: name,
+ max: row['max'],
+ median: row['median'],
+ percentile_90: row['percentile_90']
)
end
end
true