Mercurial > prosody-modules
comparison mod_statistics/stats.lib.lua @ 2300:dded110af017
mod_statistics/stats: Guard usage of module:get_option() so we only call it when Prosody is running
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 18 Sep 2016 18:53:09 +0100 |
parents | 2733cb8c82a9 |
children | 063abaab666f |
comparison
equal
deleted
inserted
replaced
2299:e099586f9de5 | 2300:dded110af017 |
---|---|
29 local active_sessions, active_jids = {}, {}; | 29 local active_sessions, active_jids = {}, {}; |
30 local c2s_sessions, s2s_sessions; | 30 local c2s_sessions, s2s_sessions; |
31 if prosody and prosody.arg then | 31 if prosody and prosody.arg then |
32 c2s_sessions, s2s_sessions = module:shared("/*/c2s/sessions", "/*/s2s/sessions"); | 32 c2s_sessions, s2s_sessions = module:shared("/*/c2s/sessions", "/*/s2s/sessions"); |
33 end | 33 end |
34 | |
35 local memory_update_interval = module:get_option_number("statistics_meminfo_interval", 60); | |
36 | 34 |
37 local stats = { | 35 local stats = { |
38 total_users = { | 36 total_users = { |
39 get = function () return it.count(it.keys(bare_sessions)); end | 37 get = function () return it.count(it.keys(bare_sessions)); end |
40 }; | 38 }; |
88 return math.ceil(pc); | 86 return math.ceil(pc); |
89 end; | 87 end; |
90 tostring = "%s%%"; | 88 tostring = "%s%%"; |
91 }; | 89 }; |
92 }; | 90 }; |
91 | |
92 local memory_update_interval = 60; | |
93 if prosody and prosody.arg then | |
94 memory_update_interval = module:get_option_number("statistics_meminfo_interval", 60); | |
95 end | |
96 | |
93 | 97 |
94 if has_pposix and pposix.meminfo then | 98 if has_pposix and pposix.meminfo then |
95 | 99 |
96 local cached_meminfo, last_cache_update; | 100 local cached_meminfo, last_cache_update; |
97 local function meminfo() | 101 local function meminfo() |