-- vim:set ft=lua: dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua') ct=CreateContentBuilder(GZIP_THRESHOLD_BYTE) ct:Append(DOCTYPE_HTML4_STRICT..[=[

# プロセス管理

]=]) post=AssertPost() if post then kill=mg.get_var(post,'kill') end for i=1,20 do ps={} killIndex=0 if PROCESS_MANAGEMENT_LIST and #PROCESS_MANAGEMENT_LIST>0 then f=edcb.io.popen('ps -C "'..table.concat(PROCESS_MANAGEMENT_LIST,',')..'" -o pid=,%cpu=,%mem=,s=,command=') if f then for pid,cpu,mem,st,cmd in f:read('*a'):gmatch(' *([0-9]+) +([0-9.]+) +([0-9.]+) +([A-Za-z]+) +([^\n]+)\n') do ps[#ps+1]={pid=pid,cpu=cpu,mem=mem,st=st,cmd=cmd} if kill and kill:find('^'..pid..'!?$') then killIndex=#ps killForce=kill:find('!$') end end f:close() end end if killIndex==0 then break elseif i==1 then cmd='kill '..(killForce and '-9 ' or '')..ps[killIndex].pid edcb.os.execute(cmd) ct:Append('
`'..cmd..'`を実行しました
\n') end edcb.Sleep(500) end tuners=#ps>0 and edcb.GetTunerProcessStatusAll and edcb.GetTunerProcessStatusAll() or {} ct:Append([=[

PID | CPU | MEM | ST | COMMAND | TUNER
--- | --- | --- | --- | --- | ---
]=]) edcb.htmlEscape=15 for i,v in ipairs(ps) do tunerStatus='' for j,w in ipairs(tuners) do if w.processID==tonumber(v.pid) then tunerStatus=('Sig:%.2f D:'):format(w.signalLv)..w.drop..' S:'..w.scramble..' sp:'..w.space..' ch:'..w.ch..(w.recFlag and ' ●' or w.epgCapFlag and ' ○' or '') break end end ct:Append('
'..v.pid..' | '..v.cpu..' | '..v.mem..' | '..v.st..' | '..EdcbHtmlEscape(v.cmd)..' | '..EdcbHtmlEscape(tunerStatus)..'
\n') end ct:Append([=[

PID
を
する ([hang-up]の注記があるものは`kill -9`します)
]=]) ct:Finish() mg.write(ct:Pop(Response(200,'text/html','utf-8',ct.len,ct.gzip)..'\r\n'))