diff options
author | Ted Trask <ttrask01@yahoo.com> | 2015-08-03 19:44:18 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2015-08-03 19:44:18 +0000 |
commit | b3f42b0b5de4786752151641ef2af37f5ce3feaf (patch) | |
tree | 7fec7a3ba0fcde72007aaddf767862d94db935c4 | |
parent | 30cdc5684382c8fb634bdfb79dc02d9d3b13786b (diff) | |
download | acf-chrony-b3f42b0b5de4786752151641ef2af37f5ce3feaf.tar.bz2 acf-chrony-b3f42b0b5de4786752151641ef2af37f5ce3feaf.tar.xz |
Modify logfile to get logging info from the config and use common view
-rw-r--r-- | chrony-controller.lua | 4 | ||||
l---------[-rw-r--r--] | chrony-logfile-html.lsp | 7 | ||||
-rw-r--r-- | chrony-model.lua | 18 |
3 files changed, 23 insertions, 6 deletions
diff --git a/chrony-controller.lua b/chrony-controller.lua index eedffb5..5fbd6d4 100644 --- a/chrony-controller.lua +++ b/chrony-controller.lua @@ -30,4 +30,8 @@ function mymodule.expert(self) return self.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit Config File", "Configuration Set") end +function mymodule.logfile(self) + return self.model.get_logfile(self, self.clientdata) +end + return mymodule diff --git a/chrony-logfile-html.lsp b/chrony-logfile-html.lsp index a1184f8..ac8854f 100644..120000 --- a/chrony-logfile-html.lsp +++ b/chrony-logfile-html.lsp @@ -1,6 +1 @@ -<% local data, viewlibrary = ... -%> - -<% if viewlibrary and viewlibrary.dispatch_component then - viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {filename="/var/log/messages", grep="chronyd"}) -end %> +../logfile-html.lsp
\ No newline at end of file diff --git a/chrony-model.lua b/chrony-model.lua index 8661e20..12f82f4 100644 --- a/chrony-model.lua +++ b/chrony-model.lua @@ -231,4 +231,22 @@ function mymodule.update_filedetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, {configfile}) end +function mymodule.get_logfile(self, clientdata) + local retval = cfe({ type="structure", value={{facility="daemon", grep="chronyd"}}, label="Log File Configuration" }) + local logdir = "/var/log/chrony" + local config = format.parse_linesandwords(fs.read_file(configfile) or "", "[!;#%%]") + if config then + for i,entry in ipairs(config) do + if entry[1] == "logdir" then + logdir = entry[2] + end + end + end + -- Add in files in the logdir + for f in fs.find(nil, logdir) do + retval.value[#retval.value+1] = {filename=f} + end + return retval +end + return mymodule |