diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-09-16 11:32:24 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-09-16 11:32:24 +0000 |
commit | 2b83bc701c24101c10e062cdbfff11498370389f (patch) | |
tree | d07073e4950146e3adcbdf4d65356158bfe8a8d7 /zebra-model.lua | |
parent | 8854cd82b4214373d61ae9d363de4f7127985c0b (diff) | |
download | acf-quagga-2b83bc701c24101c10e062cdbfff11498370389f.tar.bz2 acf-quagga-2b83bc701c24101c10e062cdbfff11498370389f.tar.xz |
Adding zebra routes on statuspage to show some debugging details
git-svn-id: svn://svn.alpinelinux.org/acf/quagga/trunk@1468 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'zebra-model.lua')
-rw-r--r-- | zebra-model.lua | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/zebra-model.lua b/zebra-model.lua index 12d62b9..89bfc26 100644 --- a/zebra-model.lua +++ b/zebra-model.lua @@ -11,6 +11,52 @@ local processname = "zebra" local packagename = "quagga" -- ################################################################################ +-- LOCAL FUNCTIONS +local function parseconfigfile() + local conf = {} + local f = io.open(configfile, "r") + local line, key, _, k, v + + if not f then + return nil + end + + for line in f:lines() do + line = string.gsub(line, "%s*#.*", "") + local k,v = string.match(line, "^%s*(%S*)%s+(.*)") + if k then + conf[k] = v + end + end + f:close() + return conf +end + +local function telnetshowip() + local output = {} + local configfile = parseconfigfile() + local cmd_output_result, cmd_output_error + local cmd = path .. "echo -e '" .. (configfile.password or "") .. "\nshow ip route\nquit\n' | nc localhost zebra 2>/dev/null" + local f = io.popen( cmd ) + local line = f:read("*l") + local validoutput + while line do + if (string.find(line, "^Codes")) then + validoutput = true + end + if (string.find(line, "> quit")) then + validoutput = false + end + if (validoutput) then + table.insert(output,line) + end + line = f:read("*l") + end + return table.concat(output,"\n"),cmd_output_error +-- return configfile.password +end + +-- ################################################################################ -- PUBLIC FUNCTIONS function startstop_service(action) @@ -30,3 +76,11 @@ function setconfigfile(filedetails) return modelfunctions.setfiledetails(filedetails) end +function getdetails() + local status = {} + status.showip = cfe({ label="Zebra routes" }) + status.showip.value,status.showip.errtxt = telnetshowip() + return cfe({ type="group", value=status, label="Zebra Details" }) +end + + |