summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-04-02 07:09:59 +0000
committerMika Havela <mika.havela@gmail.com>2008-04-02 07:09:59 +0000
commitc743fdd25b46f341b649ba3ae498e9fc97ad5f38 (patch)
tree418ae7ad9bc2b3e08293d78261785ab942b5ec1c
parentafbf9fc47c20d102f516261679b3653bd05fd9fc (diff)
downloadacf-quagga-c743fdd25b46f341b649ba3ae498e9fc97ad5f38.tar.bz2
acf-quagga-c743fdd25b46f341b649ba3ae498e9fc97ad5f38.tar.xz
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
-rw-r--r--quagga-model.lua69
-rw-r--r--quagga-status-html.lsp41
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)
<DL>
<?
-local myform = form.status.show
+local myform = form.status.stats
io.write("\t<DT")
if (#myform.errtxt > 0) then io.write(" class='error'") end
io.write(">" .. myform.label .. "</DT>\n")
io.write("\t\t<DD>\n")
-for k,v in pairs(myform.option or {}) do
- io.write("\t\t\t<TABLE STYLE='margin-bottom:10px;'>")
- io.write("\n\t\t\t<TR><TD STYLE='font-weight:bold;'><IMG SRC='/static/tango/16x16/places/network-server.png' width='16' height='16' alt> " .. k .. "</TD><TD></TD></TR>\n")
- for k1,v1 in pairs(v) do
- io.write("\n\t\t\t<TR STYLE='padding-bottom:10px;'><TD WIDTH='150px' STYLE='font-weight:bold;padding-left:20px;'><IMG SRC='/static/tango/16x16/status/")
-
- if (v1) and (string.lower(v1['Type']['value']) == "incomplete") then
- io.write("network-error")
- elseif (v1) and (string.lower(v1['Type']['value']) == "negative") then
- io.write("network-offline")
- elseif (v1) and (string.lower(v1['Flags']['value']) == "up") then
- io.write("network-idle")
- elseif (v1) and (string.lower(v1['Flags']['value']) == "used up") then
- io.write("network-transmit-receive")
- elseif (v1) and (string.lower(v1['Flags']['value']) == "used up") then
- io.write("network-offline")
- else
- io.write("network-error")
- end
- io.write(".png' width='16' height='16' title='" .. (v1['Type']['descr'] or "") .. "'> " .. v1["Protocol-Address"]['value'] .. "</TD><TD STYLE='font-weight:bold;'></TD></TR>\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("<TR><TD STYLE='font-weight:bold;padding-left:40px;'>"..k2.."</TD><TD>"..v2['value'])
- if (v2['descr']) and (#v2['descr'] > 0) then
- io.write(" <I>(" .. (v2['descr'] or "") .. ")</I>")
- end
- io.write("</TD></TR>\n")
- end
---]]
- end
-
- end
-
- io.write("\t\t\t</TABLE>")
-end
+io.write("\t\t<PRE>"..myform.value.."</PRE>\n")
io.write("\t\t</DD>\n")
?>
</DL>