Software /
code /
prosody
Diff
plugins/mod_c2s.lua @ 7662:946871f6e3c8
mod_c2s, mod_s2s: Switch connection counting to 'amount' type and enumerate once per statistics interval
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 12 Sep 2016 15:01:16 +0200 |
parent | 7540:e69df8093387 |
child | 7666:03aa330562ed |
child | 7862:f5cbbf69cac8 |
line wrap: on
line diff
--- a/plugins/mod_c2s.lua Wed Sep 07 19:32:29 2016 +0100 +++ b/plugins/mod_c2s.lua Mon Sep 12 15:01:16 2016 +0200 @@ -27,7 +27,7 @@ local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5); local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true)); -local measure_connections = module:measure("connections", "counter"); +local measure_connections = module:measure("connections", "amount"); local sessions = module:shared("sessions"); local core_process_stanza = prosody.core_process_stanza; @@ -36,7 +36,7 @@ local stream_callbacks = { default_ns = "jabber:client" }; local listener = {}; -do +module:hook("stats-update", function () -- Connection counter resets to 0 on load and reload -- Bump it up to current value local count = 0; @@ -44,7 +44,7 @@ count = count + 1; end measure_connections(count); -end +end); --- Stream events handlers local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; @@ -207,7 +207,6 @@ --- Port listener function listener.onconnect(conn) - measure_connections(1); local session = sm_new_session(conn); sessions[conn] = session; @@ -276,7 +275,6 @@ end function listener.ondisconnect(conn, err) - measure_connections(-1); local session = sessions[conn]; if session then (session.log or log)("info", "Client disconnected: %s", err or "connection closed");