From c743fdd25b46f341b649ba3ae498e9fc97ad5f38 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Wed, 2 Apr 2008 07:09:59 +0000 Subject: Cleaning up the code. Some general status information works. git-svn-id: svn://svn.alpinelinux.org/acf/quagga/trunk@875 ab2d0c66-481e-0410-8bed-d214d4d58bed --- quagga-model.lua | 69 +++++--------------------------------------------- quagga-status-html.lsp | 41 ++---------------------------- 2 files changed, 8 insertions(+), 102 deletions(-) diff --git a/quagga-model.lua b/quagga-model.lua index c9ef9d1..21ca098 100644 --- a/quagga-model.lua +++ b/quagga-model.lua @@ -9,27 +9,15 @@ require("validator") local configfile = "/etc/quagga/bgpd.conf" local processname = "bgpd" +local packagename = "quagga" local baseurl = "/etc/quagga/" local descr = { - Type = { - ['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']="This entry is from a node that connected to us", - ['local']="Local interface address", - ['static']="Static mapping from configuration file (e.g. address of core)", - }, - Flags= { --- ['up']="Connection is fully usable", - ['lower-up']="ipsec connections is up, but registration is not yet done", - }, } local function get_version() local cmd_output_result, cmd_output_error - local cmd = "/sbin/apk_version -vs " .. processname .." 2>/dev/null" + local cmd = "/sbin/apk_version -vs " .. packagename .." 2>/dev/null" local f = io.popen( cmd ) local cmdresult = f:read("*l") if (cmdresult) and (#cmdresult > 0) then @@ -55,48 +43,6 @@ local function autostarts() return cmd_output_result,cmd_output_error end -local function opennhrpctl_show() - local cmd_output_result={} - local cmd_output_result_table={} - local cmd_output_error, opennhrpstatus - local cmd = "/usr/sbin/opennhrpctl show 2>/dev/null" - local f = io.popen( cmd ) - for line in f:lines() do - if string.find(line, "^Status:") then - opennhrpstatus=line - else - table.insert(cmd_output_result, line) - end - end - f:close() - local cnt = 0 - for k,v in pairs(cmd_output_result) do - if string.find(v,"^Interface") then - cnt = cnt + 1 - cmd_output_result_table[cnt] = {} - end - if ( cnt > 0 ) and (v ~= "") then - local k = string.match(v,"^(.-):%s?.*") - cmd_output_result_table[cnt][k]=cfe({value=string.match(v,"^.-:%s?(.*)")}) - local statusdescription = string.lower(string.match(v,"^.-:%s?(.*)")) - if (type(descr[k]) == "table") then - cmd_output_result_table[cnt][k]['descr']=descr[k][statusdescription] - end - end - end - - local peers_list = {} - for k,v in pairs(cmd_output_result_table) do - if (v.Interface.value) and not (peers_list[v.Interface.value]) then - peers_list[v.Interface.value] = {} - end - table.insert(peers_list[v.Interface.value], v) - end - - return peers_list,opennhrpstatus,cmd_output_error -end - - function process_status_text(procname) local t = procps.pidof(procname) if (t) and (#t > 0) then @@ -138,20 +84,16 @@ function getstatus() errtxt=autostart_errtxt, }) - local opennhrpctl_show, opennhrpctl_status = opennhrpctl_show() + -- THIS IS WHERE WE PRESENT THE OUTPUT FROM TELNET status.stats = cfe({ name="stats", label="Programstatus reports", - value=opennhrpctl_status, - }) - - status.show = cfe({ name="show", - label="Peers", - option=opennhrpctl_show, + value="xxx", }) return status end +--[[ function get_filedetails() local path = configfile local filedetails = fs.stat(path) @@ -185,3 +127,4 @@ function update_filecontent (self, modifications) local file_result,err = fs.write_file(path, format.dostounix(modifications)) return file_result end +--]] diff --git a/quagga-status-html.lsp b/quagga-status-html.lsp index 765de12..b8d58f9 100644 --- a/quagga-status-html.lsp +++ b/quagga-status-html.lsp @@ -38,49 +38,12 @@ informationform(myform,tags)
0) then io.write(" class='error'") end io.write(">" .. 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") - for k1,v1 in pairs(v) do - 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) == "interface")) then - io.write("\n") - end ---]] - end - - end - - io.write("\t\t\t
" .. k .. "
" .. v1["Protocol-Address"]['value'] .. "
"..k2..""..v2['value']) - if (v2['descr']) and (#v2['descr'] > 0) then - io.write(" (" .. (v2['descr'] or "") .. ")") - end - io.write("
") -end +io.write("\t\t
"..myform.value.."
\n") io.write("\t\t
\n") ?>
-- cgit v1.2.3