Mercurial > prosody-modules
comparison mod_host_status_check/mod_host_status_check.lua @ 2219:5fcf9d558250
Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 28 Jun 2016 22:33:13 +0100 |
parents | |
children | 3d80f8dba886 |
comparison
equal
deleted
inserted
replaced
2218:0ca0fdad3b2c | 2219:5fcf9d558250 |
---|---|
1 local time = require "socket".gettime; | |
2 | |
3 local heartbeats = module:shared("/*/host_status_check/heartbeats"); | |
4 local connection_events = module:shared("/*/host_status_check/connection_events"); | |
5 | |
6 if prosody.hosts[module.host].type == "component" and module:get_option_string("component_module") == "component" then | |
7 module:hook("component-authenticated", function () | |
8 connection_events[module.host] = { connected = true; timestamp = time() }; | |
9 end); | |
10 | |
11 -- Note: this event is not in 0.9, and requires a recent 0.10 or trunk build | |
12 module:hook("component-disconnected", function () | |
13 connection_events[module.host] = { connected = false; timestamp = time() }; | |
14 end); | |
15 | |
16 module:hook("stanza/xmpp:prosody.im/heartbeat:heartbeat", function () | |
17 heartbeats[module.host] = time(); | |
18 return true; | |
19 end); | |
20 else | |
21 connection_events[module.host] = { connected = true, timestamp = time() }; | |
22 module:log("debug", "BLAH") | |
23 end | |
24 | |
25 function module.unload() | |
26 connection_events[module.host] = { connected = false, timestamp = time() }; | |
27 heartbeats[module.host] = nil; | |
28 end |