1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
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")
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="---"} )
-- 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)
local f = files_opened:read("*a") or "unknown"
table.insert ( listed_files , cfe{date="?", name=f, size="?"} )
return listed_files
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 = list_files(logfile_folders)
file_name = cfe{value=path, name=file_name}
return logfile_result
end
|