From e09aa22226b9f366000b778378c7d34018e3846a Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Fri, 4 Apr 2008 13:34:02 +0000 Subject: Show logfile. Show config errors in expert-tab. git-svn-id: svn://svn.alpinelinux.org/acf/quagga/trunk@929 ab2d0c66-481e-0410-8bed-d214d4d58bed --- quagga-controller.lua | 11 +++++++ quagga-model.lua | 80 ++++++++++++++++++++++++++++++++++++++++++++------- quagga.menu | 2 ++ 3 files changed, 82 insertions(+), 11 deletions(-) diff --git a/quagga-controller.lua b/quagga-controller.lua index f59ac0a..ac216e7 100644 --- a/quagga-controller.lua +++ b/quagga-controller.lua @@ -107,3 +107,14 @@ expert = function (self) cmdmanagement = cmdmanagement, url = url, } ) end +logfile = function (self) + + local status=self.model.getstatus() + local logfile = self.model:get_logfile() + + return ({ + status = status, + logfile = logfile, + url = url, + }) +end diff --git a/quagga-model.lua b/quagga-model.lua index be045d5..8153fa2 100644 --- a/quagga-model.lua +++ b/quagga-model.lua @@ -126,33 +126,91 @@ function getstatus() return status end ---[[ -function get_filedetails() - local path = configfile - local filedetails = fs.stat(path) +function get_logfile () local file = {} + local cmdtxt = "cat /var/log/messages | grep " .. processname + local cmd, error = io.popen(cmdtxt ,r) + local cmdoutput = cmd:read("*a") + cmd:close() file["filename"] = cfe({ name="filename", label="File name", + value=cmdtxt, + }) + + file["filecontent"] = cfe({ + type="longtext", + name="filecontent", + label="File content", + value=cmdoutput, + }) + + return file +end +function getconfig() + local config = {} + return config +end + +function get_filedetails(self,num) + local path + if (num == "2") then + path = configfile2 + else + path = configfile + end + local file = {} + local filedetails = {} + local config = {} + local filenameerrtxt + if (path) and (fs.is_file(path)) then + filedetails = fs.stat(path) + config = getconfig(path) + else + config = {} + config.filename = {} + config["filename"]["errtxt"]="Config file '".. path .. "' is missing!" + end + + file["filename" .. (num or "")] = cfe({ + name="filename" .. (num or ""), + label="File name", value=path, + errtxt=filenameerrtxt }) - file["filesize"] = cfe({ - name="filesize", + file["filesize" .. (num or "")] = cfe({ + name="filesize" .. (num or ""), label="File size", value=filedetails.size or 0, }) - file["mtime"] = cfe({ - name="mtime", + file["mtime" .. (num or "")] = cfe({ + name="mtime" .. (num or ""), label="File date", value=filedetails.mtime or "---", }) - file["filecontent"] = cfe({ + file["filecontent" .. (num or "")] = cfe({ type="longtext", - name="filecontent", + name="filecontent" .. (num or ""), label="File content", value=fs.read_file(path), }) + + -- Sum all errors into one cfe + local sumerrors = "" + for k,v in pairs(config) do + if (config[k]) and (config[k]["errtxt"]) and (config[k]["errtxt"] ~= "") then + sumerrors = sumerrors .. config[k]["errtxt"] .. "\n" + end + end + if (sumerrors ~= "") then + file["sumerrors" .. (num or "")] = cfe ({ + name="sumerrors" .. (num or ""), + label = "Configuration errors", + errtxt = string.match(sumerrors, "(.-)\n$"), + }) + end + return file end function update_filecontent (self, modifications) @@ -160,4 +218,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.menu b/quagga.menu index f999729..d0d6b24 100644 --- a/quagga.menu +++ b/quagga.menu @@ -1,3 +1,5 @@ #CAT GROUP/DESC TAB ACTION Networking 46BGP Status status +Networking 46BGP Expert expert +Networking 46BGP Logfile logfile -- cgit v1.2.3