Comparison

mod_measure_memory/mod_measure_memory.lua @ 1655:4d38b8c03dfe

mod_measure_memory: Silence warnings [luacheck]
author Kim Alvefur <zash@zash.se>
date Tue, 07 Apr 2015 22:05:48 +0200
parent 1623:2c39af0fb93b
child 2436:a01a3fb96302
comparison
equal deleted inserted replaced
1654:1a6d6221c5f6 1655:4d38b8c03dfe
3 local measure = require"core.statsmanager".measure; 3 local measure = require"core.statsmanager".measure;
4 local have_pposix, pposix = pcall(require, "util.pposix"); 4 local have_pposix, pposix = pcall(require, "util.pposix");
5 5
6 local measures = {}; 6 local measures = {};
7 setmetatable(measures, { 7 setmetatable(measures, {
8 __index = function (t, k, m) 8 __index = function (t, k)
9 m = measure("sizes", "memory."..k); t[k] = m; return m; 9 local m = measure("sizes", "memory."..k); t[k] = m; return m;
10 end 10 end
11 }); 11 });
12 12
13 module:hook("stats-update", function () 13 module:hook("stats-update", function ()
14 measures.lua(collectgarbage("count")*1024); 14 measures.lua(collectgarbage("count")*1024);
21 m[k](v); 21 m[k](v);
22 end 22 end
23 end); 23 end);
24 end 24 end
25 25
26 local statm = io.open("/proc/self/statm"); 26 if require"lfs".attributes("/proc/self/statm", "mode") == "file" then
27 if statm then
28 statm:close();
29 local pagesize = module:get_option_number("memory_pagesize", 4096); -- getconf PAGESIZE 27 local pagesize = module:get_option_number("memory_pagesize", 4096); -- getconf PAGESIZE
30 28
31 module:hook("stats-update", function () 29 module:hook("stats-update", function ()
32 local statm, err = io.open("/proc/self/statm"); 30 local statm, err = io.open("/proc/self/statm");
33 if not statm then 31 if not statm then