From b9997890f266def9882f4efd7753f1d59e458f2b Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Thu, 27 Mar 2008 14:24:10 +0000 Subject: Reorganized the output of data. Added information of Autostart sequence. git-svn-id: svn://svn.alpinelinux.org/acf/opennhrp/trunk@846 ab2d0c66-481e-0410-8bed-d214d4d58bed --- opennhrp-model.lua | 51 +++++++++++++++++++++++++++++++++++++++++++++++- opennhrp-status-html.lsp | 35 ++++++++++++++++++++++----------- 2 files changed, 74 insertions(+), 12 deletions(-) diff --git a/opennhrp-model.lua b/opennhrp-model.lua index ebff6a8..42034d9 100644 --- a/opennhrp-model.lua +++ b/opennhrp-model.lua @@ -11,6 +11,16 @@ local configfile = "/etc/opennhrp/opennhrp.conf" local processname = "opennhrp" local baseurl = "/etc/opennhrp/" +local type_status = { + ['incomplete']="The protocol address is being resolved", + ['negative']="This protocol address is not available", + ['cached']="Protocol address was resolved successfully", + ['route']="this is a dynamic shortcut", + ['dynamic']="only in core branches, the entry is from a node that connected to us", + ['local']="local interface address", + ['static']="static mapping from configuration file (e.g. address of core)", + } + local function get_version() local cmd_output_result, cmd_output_error local cmd = "/sbin/apk_version -vs " .. processname .." 2>/dev/null" @@ -25,6 +35,21 @@ local function get_version() return cmd_output_result,cmd_output_error end +local function autostarts() + local cmd_output_result, cmd_output_error + local cmd = "/sbin/rc_status | egrep '^S' | egrep '" .. processname .."' 2>/dev/null" + local f = io.popen( cmd ) + local cmdresult = f:read("*a") + if (cmdresult) and (#cmdresult > 0) then + cmd_output_result = "Process will autostart at next boot (at sequence '" .. string.match(cmdresult,"^%a+(%d%d)") .. "')" + else + cmd_output_error = "Not programmed to autostart" + end + f:close() + return cmd_output_result,cmd_output_error + +end + local function opennhrpctl_show() local cmd_output_result={} local cmd_output_result_table={} @@ -48,12 +73,21 @@ local function opennhrpctl_show() if ( cnt > 0 ) and (v ~= "") then local k = string.match(v,"^(.-):%s?.*") cmd_output_result_table[cnt][k]=string.match(v,"^.-:%s?(.*)") + if (string.lower(k) == "type") then + local tooltip = string.match(v,"^.-:%s?(.*)") + cmd_output_result_table[cnt]["Tooltip"] = type_status[tooltip] + end end end return cmd_output_result_table,opennhrpstatus,cmd_output_error end + + + + + -- ################################################################################ -- PUBLIC FUNCTIONS @@ -68,14 +102,29 @@ function getstatus() label="Program status", value=procps.pidof(processname), }) + local autostart_sequense, autostart_errtxt = autostarts() + status.autostart = cfe({ name="autostart", + label="Autostart sequence", + value=autostart_sequense, + errtxt=autostart_errtxt, + }) + local opennhrpctl_show, opennhrpctl_status = opennhrpctl_show() status.stats = cfe({ name="stats", label="Programstatus reports", value=opennhrpctl_status, }) + + local peers_list = {} + for k,v in pairs(opennhrpctl_show) do + if (v.Interface) and not (peers_list[v.Interface]) then + peers_list[v.Interface] = {} + end + table.insert(peers_list[v.Interface], v) + end status.show = cfe({ name="show", label="Peers", - option=opennhrpctl_show, + option=peers_list, }) return status diff --git a/opennhrp-status-html.lsp b/opennhrp-status-html.lsp index 6137246..1fa098a 100644 --- a/opennhrp-status-html.lsp +++ b/opennhrp-status-html.lsp @@ -29,18 +29,14 @@ end
-

PROGRAM SPECIFIC OPTIONS/INFORMATION

" .. myform.label .. "\n") io.write("\t\t
\n") for k,v in pairs(myform.option or {}) do io.write("\t\t\t") - io.write("\n\t\t\t\n") + io.write("\n\t\t\t\n") for k1,v1 in pairs(v) do - if (k1 ~= "Protocol-Address") then - io.write("\n") + io.write("\n\t\t\t\n") + for k2,v2 in pairs(v1) do + if (k2) and not ((string.lower(k2) == "protocol-address") or + (string.lower(k2) == "tooltip") or + (string.lower(k2) == "interface")) then + io.write("\n") + end end + end + io.write("\t\t\t
Protocol-Address" .. v["Protocol-Address"] .. "
" .. k .. "
"..k1..""..v1.."
" .. v1["Protocol-Address"] .. "
"..k2..""..v2.."
") end io.write("\t\t
\n") ?>
- - - DEBUGGING

DEBUG INFO: CFE

") -- cgit v1.2.3