Commit 2cc08d53 authored by Mika Havela's avatar Mika Havela

Cleaning up the code and activating all visible functions (show/expert/logfile)

git-svn-id: svn://svn.alpinelinux.org/acf/dnscache/trunk@983 ab2d0c66-481e-0410-8bed-d214d4d58bed
parent 3a375213
APP_NAME=quagga
APP_NAME=dnscache
PACKAGE=acf-$(APP_NAME)
VERSION=0.2.0
VERSION=0.1.0
APP_DIST=\
quagga-controller.lua \
quagga-model.lua \
quagga-status-html.lsp \
quagga-logfile-html.lsp \
quagga-expert-html.lsp \
quagga.menu \
dnscache-controller.lua \
dnscache-model.lua \
dnscache-status-html.lsp \
dnscache-logfile-html.lsp \
dnscache-expert-html.lsp \
dnscache.menu \
EXTRA_DIST=README Makefile config.mk
......
......@@ -22,7 +22,6 @@ local function displaycmdmanagement(pidofstatus)
label="Program control-panel",
value="Start",
type="submit",
descr="When starting or restarting BGP, the web-page will freeze for some reason!",
})
management.stop = cfe({ name="cmdmanagement",
label="Program control-panel",
......
......@@ -12,41 +12,16 @@ require("socket")
require("processinfo")
-- Set variables
local configfile = "/etc/quagga/bgpd.conf"
local processname = "bgpd"
local packagename = "quagga"
local baseurl = "/etc/quagga/"
local configfile = "/etc/conf.d/dnscache"
local processname = "dnscache"
local packagename = "dnscache"
local baseurl = "/etc/dnscache/"
local descr = {
}
-- ################################################################################
-- LOCAL FUNCTIONS
local function get_routes()
local cmd_output_result, cmd_output_error
local cmd = "/sbin/route -n 2>/dev/null"
local f = io.popen( cmd )
local cmd_output_result = f:read("*a")
return cmd_output_result,cmd_output_error
end
local function get_iproute()
local cmd_output_result, cmd_output_error
local cmd = "/bin/ip route 2>/dev/null"
local f = io.popen( cmd )
local cmd_output_result = f:read("*a")
return cmd_output_result,cmd_output_error
end
local function get_bgpinfo()
local cmd_output_result, cmd_output_error
local cmd = "/usr/sbin/bgpd --version 2>/dev/null"
local f = io.popen( cmd )
local cmd_output_result = f:read("*a")
-- bgpdport=179
return cmd_output_result,cmd_output_error
end
local function process_status_text(procname)
local t = procps.pidof(procname)
if (t) and (#t > 0) then
......@@ -56,6 +31,21 @@ local function process_status_text(procname)
end
end
local function humanreadable(value)
local myvalue = tonumber(value)
if not (myvalue) then
return false
end
if ( myvalue > 1073741824 ) then
myvalue=((myvalue/1073741824) - (myvalue/1073741824%0.1)) .. "G"
elseif ( myvalue > 1048576 ) then
myvalue=((myvalue/1048576) - (myvalue/1048576%0.1)) .. "M"
elseif ( myvalue > 1024 ) then
myvalue=((myvalue/1024) - (myvalue/1024%0.1)) .. "k"
end
return myvalue
end
-- ################################################################################
-- PUBLIC FUNCTIONS
......@@ -69,7 +59,7 @@ end
function getstatus()
local status = {}
local config = getconfig()
local value, errtxt = processinfo.package_version(packagename)
status.version = cfe({ name = "version",
label="Program version",
......@@ -89,19 +79,14 @@ function getstatus()
errtxt=autostart_errtxt,
})
status.iproute = cfe({ name="iproute",
label="ip route",
value=get_iproute(),
status.ip = cfe({ name="ip",
label="Listening on",
value=config.IP,
})
status.routes = cfe({ name="routes",
label="route -n",
value=get_routes(),
})
status.bgpstats = cfe({ name="bgpstats",
label="BGP version",
value=get_bgpinfo(),
status.cachesize = cfe({ name="cachesize",
label="Cache size",
value=humanreadable(config.CACHESIZE),
})
return status
......@@ -131,8 +116,10 @@ function get_logfile ()
end
function getconfig()
local config = {}
return config
if (fs.is_file(configfile)) then
return getopts.getoptsfromfile(configfile)
end
return false
end
function get_filedetails(self,num)
......
......@@ -21,18 +21,9 @@ displayinfo(myform,tags,"viewonly")
<H2>PROGRAM SPECIFIC OPTIONS/INFORMATION</H2>
<DL>
<?
local tags ={ "bgpstats", "iproute", }
for k,v in pairs(tags) do
local myform = form.status[v]
if (myform) then
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")
io.write("\t\t<PRE>"..myform.value.."</PRE>\n")
io.write("\t\t</DD>\n")
end
end
local myform = form.status
local tags = { "ip", "cachesize", }
displayinfo(myform,tags,"viewonly")
?>
</DL>
#CAT GROUP/DESC TAB ACTION
Networking 46BGP Status status
Networking 46BGP Expert expert
Networking 46BGP Logfile logfile
Networking 11DNScache Status status
Networking 11DNScache Expert expert
Networking 11DNScache Logfile logfile
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment