diff options
author | Mika Havela <mika.havela@gmail.com> | 2007-11-01 16:47:33 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2007-11-01 16:47:33 +0000 |
commit | 0ef3beac1d5b87bf0baf2b808ceefc1b174cffe8 (patch) | |
tree | 28469203fc20d8b776477c430a35269eafecb6d0 /logfiles-model.lua | |
parent | 6e1c67f38c43b88b4f098ced3279e2227c593e53 (diff) | |
download | acf-alpine-baselayout-0ef3beac1d5b87bf0baf2b808ceefc1b174cffe8.tar.bz2 acf-alpine-baselayout-0ef3beac1d5b87bf0baf2b808ceefc1b174cffe8.tar.xz |
Minor changes to clean up code
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@244 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'logfiles-model.lua')
-rw-r--r-- | logfiles-model.lua | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/logfiles-model.lua b/logfiles-model.lua index 204da04..2473a9f 100644 --- a/logfiles-model.lua +++ b/logfiles-model.lua @@ -7,13 +7,6 @@ local function list_files ( path ) 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" @@ -26,32 +19,19 @@ local function list_files ( path ) 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 +-- 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) -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 + 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 @@ -66,8 +46,6 @@ 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 |