From 95ba493873f7879bb16a2f12a0bdc6f60602f7aa Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 28 Apr 2017 11:52:30 +0200 Subject: [PATCH] Improved error detection (for endless loops in channel fetch). --- app/controllers/monitoring_controller.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/monitoring_controller.rb b/app/controllers/monitoring_controller.rb index cd03c671d..ece7e4a5d 100644 --- a/app/controllers/monitoring_controller.rb +++ b/app/controllers/monitoring_controller.rb @@ -32,8 +32,10 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX issues = [] # channel check + last_run_tolerance = Time.zone.now - 1.hour Channel.where(active: true).each { |channel| - next if (channel.status_in.empty? || channel.status_in == 'ok') && (channel.status_out.empty? || channel.status_out == 'ok') + + # inbound channel if channel.status_in == 'error' message = "Channel: #{channel.area} in " %w(host user uid).each { |key| @@ -42,6 +44,11 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX } issues.push "#{message} #{channel.last_log_in}" end + if channel.preferences && channel.preferences['last_fetch'] && channel.preferences['last_fetch'] < last_run_tolerance + issues.push "#{message} channel is active but not fetched for 1 hour" + end + + # outbound channel next if channel.status_out != 'error' message = "Channel: #{channel.area} out " %w(host user uid).each { |key|