Mercurial > prosody-modules
comparison mod_http_host_status_check/mod_http_host_status_check.lua @ 2228:03a4c3209f21
mod_http_host_status_check: Fix some luacheck warnings
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 02 Jul 2016 16:04:35 +0100 |
parents | 7356d722e180 |
children | 2a7e9d9e7339 |
comparison
equal
deleted
inserted
replaced
2227:7356d722e180 | 2228:03a4c3209f21 |
---|---|
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 local host_status_ok = module:shared("host_status_ok"); |
4 | 4 |
5 local time = require "socket".gettime; | 5 local time = require "socket".gettime; |
6 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) |
7 local st = require "util.stanza"; | |
8 | 7 |
9 module:depends "http" | 8 module:depends "http" |
10 | 9 |
11 local threshold = module:get_option_number("status_check_heartbeat_threshold", 5); | 10 local threshold = module:get_option_number("status_check_heartbeat_threshold", 5); |
12 | 11 |
13 local function status_string(status, duration, comment) | 12 local function status_string(status, duration, comment) |
14 local string_timestamp = ""; | 13 local string_timestamp; |
15 if duration then | 14 if duration then |
16 string_timestamp = ("(%0.2fs%s)"):format(duration, comment or ""); | 15 string_timestamp = ("(%0.2fs%s)"):format(duration, comment or ""); |
17 elseif comment then | 16 elseif comment then |
18 string_timestamp = ("(%s)"):format(comment); | 17 string_timestamp = ("(%s)"):format(comment); |
19 else | 18 else |
38 local all_ok = true; | 37 local all_ok = true; |
39 | 38 |
40 for host in pairs(hosts) do | 39 for host in pairs(hosts) do |
41 local last_heartbeat_time = heartbeats[host]; | 40 local last_heartbeat_time = heartbeats[host]; |
42 | 41 |
43 local ok, status_text = true, "OK"; | 42 local ok, status_text = true; |
44 | 43 |
45 local is_component = hosts[host].type == "component" and hosts[host].modules.component; | 44 local is_component = hosts[host].type == "component" and hosts[host].modules.component; |
46 | 45 |
47 if is_component then | 46 if is_component then |
48 local current_status = hosts[host].modules.component.connected; | 47 local current_status = hosts[host].modules.component.connected; |