summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--logfiles-controller.lua33
-rw-r--r--logfiles-model.lua75
-rw-r--r--logfiles-read-html.lsp29
-rw-r--r--logfiles.menu2
4 files changed, 139 insertions, 0 deletions
diff --git a/logfiles-controller.lua b/logfiles-controller.lua
new file mode 100644
index 0000000..1770754
--- /dev/null
+++ b/logfiles-controller.lua
@@ -0,0 +1,33 @@
+module (..., package.seeall)
+
+-- Cause an http redirect to our "read" action
+-- We use the self.conf table because it already has prefix,controller,etc
+-- The redir code is defined in the application error handler (acf-controller)
+local list_redir = function (self)
+ self.conf.action = "read"
+ self.conf.type = "redir"
+ error (self.conf)
+end
+
+mvc={}
+mvc.on_load = function(self, parent)
+ if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then
+ self.worker[self.conf.action] = list_redir(self)
+ end
+end
+
+-- Public methods
+
+read = function (self )
+ return ({logfile = self.model:get("/var/log/mini_httpd.log")} )
+end
+
+--update = function (self)
+-- return nil
+--end
+
+--delete = function (self)
+-- return nil
+--end
+
+--create = update
diff --git a/logfiles-model.lua b/logfiles-model.lua
new file mode 100644
index 0000000..204da04
--- /dev/null
+++ b/logfiles-model.lua
@@ -0,0 +1,75 @@
+module (..., package.seeall)
+
+-- no initializer in model - use controller.init for that
+
+local function list_files ( path )
+ local listed_files = {}
+ local open_files = {}
+ split = require("split")
+ local files = io.popen("find " .. path .. " -type f | sort")
+-- local files_opened = io.popen("ls -l $( find /proc/[0-9]*/fd) | egrep 'tmp\|var' - | sed 's/ \+/ /g' | sort")
+
+ opens=" ls -l $( find /proc/[0-9]*/fd 2>/dev/null) 2>/dev/null | \
+ egrep 'tmp\|var' - | sed 's/ \+/ /g' | \
+ cut -f 12"
+-- cut -f11 -d' ' | sort |uniq "
+ local files_opened = io.popen(opens)
+
+ if ( files ) then
+ local f = files:read("*a") or "unknown"
+ for k,v in pairs(split("%s", f)) do
+ if v ~= "" then
+ table.insert ( listed_files , cfe{date="?", name=v, size="?"} )
+ end
+ end
+ files:close()
+ end
+ table.insert ( listed_files , cfe{date="---", name="--- Now follows list with open files to compare agains logfile-list ---", size="---"} )
+
+-- if ( files_opened ) then
+ local f = files_opened:read("*a") or "unknown"
+-- for k,v in pairs(split("%s", f)) do
+ table.insert ( listed_files , cfe{date="?", name=f, size="?"} )
+-- end
+-- files_opened:close()
+-- end
+
+ return listed_files
+end
+
+function list_filesx ( path )
+ local file, error = io.popen("find " .. path .. " -type f")
+ if ( file == nil ) then
+ return nil, error
+ end
+ local f = {}
+ for line in file:lines() do
+ table.insert ( f , cfe{value=line, name=line} )
+ end
+ file:close()
+ return f
+end
+
+
+
+local function read_file ( path )
+ local file = io.open(path)
+ if ( file ) then
+ local f = file:read("*a") or "unknown"
+ file:close()
+ return f
+ else
+ return "Cant find '" .. path .. "'"
+ end
+end
+
+get = function (self,path)
+ local logfile_folders = "/var/log /tmp/squid/log"
+ local logfile_result = {}
+-- logfile_result = cfe{value=read_file(path), name=path}
+-- logfile_result = cfe{value=list_files(logfile_folders), name=path}
+ logfile_result = list_files(logfile_folders)
+ file_name = cfe{value=path, name=file_name}
+ return logfile_result
+end
+
diff --git a/logfiles-read-html.lsp b/logfiles-read-html.lsp
new file mode 100644
index 0000000..b89e8eb
--- /dev/null
+++ b/logfiles-read-html.lsp
@@ -0,0 +1,29 @@
+<? local view = ... ?>
+<html>
+<body>
+<h1>Logfiles</h1>
+<TABLE border=1>
+ <TR class=grey>
+ <TD "width=55px">Delete</TD>
+ <TD "width=55px">Save</TD>
+ <TD "width=55px">View</TD>
+ <TD "width=55px">Size</TD>
+ <TD>Last Modified</TD>
+ <TD>File</TD>
+ </TR>
+
+<? for i = 1, 20 do ?>
+ <TR>
+ <TD>?</TD>
+ <TD>?</TD>
+ <TD>?</TD>
+ <TD>?</TD>
+ <TD>?</TD>
+ <TD><?= view.logfile[i].name ?></TD>
+ </TR>
+<? end ?>
+
+</TABLE>
+
+</body>
+</html>
diff --git a/logfiles.menu b/logfiles.menu
new file mode 100644
index 0000000..f775cfc
--- /dev/null
+++ b/logfiles.menu
@@ -0,0 +1,2 @@
+#CAT GROUP/DESC TAB ACTION
+General Logfiles dlogfiles read