mod_http_host_status_check/mod_http_host_status_check.lua
changeset 2231 7356d722e180
parent 2223 5fcf9d558250
child 2232 03a4c3209f21
--- a/mod_http_host_status_check/mod_http_host_status_check.lua	Fri Jul 01 00:31:09 2016 +0100
+++ b/mod_http_host_status_check/mod_http_host_status_check.lua	Sat Jul 02 16:04:06 2016 +0100
@@ -1,5 +1,6 @@
 local heartbeats = module:shared("/*/host_status_check/heartbeats");
 local events = module:shared("/*/host_status_check/connection_events");
+local host_status_ok = module:shared("host_status_ok");
 
 local time = require "socket".gettime;
 local template = require "util.interpolation".new("%b{}", function (s) return s end)
@@ -86,6 +87,13 @@
 		if not ok or is_component or last_heartbeat_time then
 			host_statuses[host] = string_pad(status_text, 20);
 		end
+		local last_ok = host_status_ok[host];
+		if last_ok ~= ok then
+			if last_ok ~= nil then
+				module:log("warn", "Host status check %s (%s)", ok and "OK" or "FAILED", status_text);
+			end
+			host_status_ok[host] = ok;
+		end
 	end
 	local page = template(status_page_template, {
 		status = all_ok and "OK" or "FAIL";