mod_muc_webchat_url: Fix default url
[prosody-modules.git] / mod_measure_memory / mod_measure_memory.lua
blob321f372dfd598bb69fc53128c1bed0e32b0369f3
1 module:set_global();
3 local measure = require"core.statsmanager".measure;
5 local measures = {};
6 setmetatable(measures, {
7 __index = function (t, k)
8 local m = measure("amount", "memory."..k); t[k] = m; return m;
9 end
10 });
12 module:hook("stats-update", function ()
13 measures.lua(collectgarbage("count")*1024);
14 end);
16 if require"lfs".attributes("/proc/self/statm", "mode") == "file" then
17 local pagesize = module:get_option_number("memory_pagesize", 4096); -- getconf PAGESIZE
19 module:hook("stats-update", function ()
20 local statm, err = io.open("/proc/self/statm");
21 if not statm then
22 module:log("error", tostring(err));
23 return;
24 end
25 -- virtual memory (caches, opened librarys, everything)
26 measures.total(statm:read("*n") * pagesize);
27 -- resident set size (actually used memory)
28 measures.rss(statm:read("*n") * pagesize);
29 statm:close();
30 end);
31 end