Mercurial > prosody-modules
diff mod_http_host_status_check/mod_http_host_status_check.lua @ 2227:7356d722e180
mod_http_host_status_check: Emit log message when host status is not the same as last time we looked
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 02 Jul 2016 16:04:06 +0100 |
parents | 5fcf9d558250 |
children | 03a4c3209f21 |
line wrap: on
line diff
--- 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";