Comparison

plugins/mod_admin_telnet.lua @ 8126:60f6f7ddd2ce

mod_admin_telnet: Output human-friendly memory usage when meminfo is unavailable (thanks nbastin)
author Kim Alvefur <zash@zash.se>
date Tue, 25 Apr 2017 00:14:19 +0200
parent 7977:01d6298de991
child 8128:c14513401d65
child 8192:4354f556c5db
comparison
equal deleted inserted replaced
8125:5f0c642a41a1 8126:60f6f7ddd2ce
323 return ("%0.2f%sB"):format(kb, unit); 323 return ("%0.2f%sB"):format(kb, unit);
324 end 324 end
325 325
326 function def_env.server:memory() 326 function def_env.server:memory()
327 if not has_pposix or not pposix.meminfo then 327 if not has_pposix or not pposix.meminfo then
328 return true, "Lua is using "..collectgarbage("count"); 328 return true, "Lua is using "..human(collectgarbage("count"));
329 end 329 end
330 local mem, lua_mem = pposix.meminfo(), collectgarbage("count"); 330 local mem, lua_mem = pposix.meminfo(), collectgarbage("count");
331 local print = self.session.print; 331 local print = self.session.print;
332 print("Process: "..human((mem.allocated+mem.allocated_mmap)/1024)); 332 print("Process: "..human((mem.allocated+mem.allocated_mmap)/1024));
333 print(" Used: "..human(mem.used/1024).." ("..human(lua_mem).." by Lua)"); 333 print(" Used: "..human(mem.used/1024).." ("..human(lua_mem).." by Lua)");