------- -- dmkc_tracking -- -- Track Dmkcheck memory usage -- -- This version uses /proc filesystem and as such, rely on linux kernel. -- Released under Creative Commons Attribution-NonCommercial 3.0 License -- -- Copyright 2013 Laurent Faillie ----- -- 07/05/2013 LF : First version -- local posix = require "posix" -- we need luaposix local M = {} -- each probe is a lua module function M.result() -- this public function is MANDATORY and is called by dmkcheck local pid = posix.getpid('pid') -- what is our pid local f = io.open('/proc/'.. pid ..'/status', 'r') if not f then print("*E* can't open status file") return end local res = {} -- object to store the result res.dmkcheckd = {} -- in order to be compatible with process_track for l in f:lines() do -- read file's lines local tok, v = l:match("(%a+):%s*(%d+)") -- extract information v = tonumber(v) -- reduce text to send if tok == "VmData" then res.dmkcheckd['date'] = v elseif tok == "VmStk" then res.dmkcheckd['stack'] = v if res.dmkcheckd['data'] ~= nil then -- all data read : we can stop here break; end end end f:close() return res, "process_tracking" end return M