Mercurial > prosody-modules
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 2226:9754eedbc4d1 | 2227:7356d722e180 |
|---|---|
| 1 local heartbeats = module:shared("/*/host_status_check/heartbeats"); | 1 local heartbeats = module:shared("/*/host_status_check/heartbeats"); |
| 2 local events = module:shared("/*/host_status_check/connection_events"); | 2 local events = module:shared("/*/host_status_check/connection_events"); |
| 3 local host_status_ok = module:shared("host_status_ok"); | |
| 3 | 4 |
| 4 local time = require "socket".gettime; | 5 local time = require "socket".gettime; |
| 5 local template = require "util.interpolation".new("%b{}", function (s) return s end) | 6 local template = require "util.interpolation".new("%b{}", function (s) return s end) |
| 6 local st = require "util.stanza"; | 7 local st = require "util.stanza"; |
| 7 | 8 |
| 84 end | 85 end |
| 85 | 86 |
| 86 if not ok or is_component or last_heartbeat_time then | 87 if not ok or is_component or last_heartbeat_time then |
| 87 host_statuses[host] = string_pad(status_text, 20); | 88 host_statuses[host] = string_pad(status_text, 20); |
| 88 end | 89 end |
| 90 local last_ok = host_status_ok[host]; | |
| 91 if last_ok ~= ok then | |
| 92 if last_ok ~= nil then | |
| 93 module:log("warn", "Host status check %s (%s)", ok and "OK" or "FAILED", status_text); | |
| 94 end | |
| 95 host_status_ok[host] = ok; | |
| 96 end | |
| 89 end | 97 end |
| 90 local page = template(status_page_template, { | 98 local page = template(status_page_template, { |
| 91 status = all_ok and "OK" or "FAIL"; | 99 status = all_ok and "OK" or "FAIL"; |
| 92 host_statuses = host_statuses; | 100 host_statuses = host_statuses; |
| 93 }); | 101 }); |
