diff options
Diffstat (limited to 'snort-model.lua')
-rw-r--r-- | snort-model.lua | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/snort-model.lua b/snort-model.lua index b4b3266..9b1300d 100644 --- a/snort-model.lua +++ b/snort-model.lua @@ -6,6 +6,28 @@ module (..., package.seeall) require("posix") require("fs") +local function file_info ( path ) + local filedetails = posix.stat(path) + filedetails["owner"]=rawget((posix.getpasswd(filedetails["uid"])),"name") + filedetails["group"]=rawget((posix.getgroup(filedetails["gid"])),"name") + filedetails["atimelong"]=os.date("%c", filedetails["atime"]) + filedetails["mtimelong"]=os.date("%c", filedetails["mtime"]) + filedetails["path"]=path + filedetails["name"]=basename(path) + + if ( filedetails["size"] > 1073741824 ) then + filedetails["size"]=((filedetails["size"]/1073741824) - (filedetails["size"]/1073741824%0.1)) .. "G" + elseif ( filedetails["size"] > 1048576 ) then + filedetails["size"]=((filedetails["size"]/1048576) - (filedetails["size"]/1048576%0.1)) .. "M" + elseif ( filedetails["size"] > 1024 ) then + filedetails["size"]=((filedetails["size"]/1024) - (filedetails["size"]/1024%0.1)) .. "k" + else + filedetails["size"]=filedetails["size"] + end + return filedetails + +end + local function get_version() local cmd = "snort -V 2>&1 | grep Version | sed 's/.*ersion\ /snort-/'" local cmd_output = io.popen( cmd ) @@ -21,9 +43,7 @@ local is_running = function( process ) local cmdoutput = string.gsub(cmd:read("*a"), "%s", "") cmd:close() if (cmdoutput ~= "") then - statusreport = "Running" - else - statusreport = "Stopped" + statusreport = "Yes" end return statusreport end @@ -35,11 +55,16 @@ getstatus = function (self) local status = {} local version = get_version() status.version = version - local isrunning = is_running("snort") - status.status = isrunning + status.enabled = is_running("snort") return status end - +function get_filedetails() + local filedetails = {} + local path = "/etc/snort/snort.conf" + filedetails.details = file_info(path) + filedetails.content = fs.read_file(path) + return filedetails +end service_control = function ( self, srvcmd ) local srvcmd = string.lower(srvcmd) local retval = "" |