* logs plugin prepares download button for syslogfile, activate in configfile
This commit is contained in:
parent
d2d974c18b
commit
91f54ffa66
5 changed files with 47 additions and 5 deletions
|
@ -99,3 +99,8 @@ CryptoBoxRootActions = CryptoBoxRootActionsLocal
|
|||
#[[network]]
|
||||
#interface = eth0
|
||||
|
||||
## Uncomment the following lines to enable downloads of system
|
||||
## logfiles via frontend. Make sure they are readable for the uid the
|
||||
## cryptobox server runs with.
|
||||
#[[logs]]
|
||||
#syslogfile = /var/log/syslog
|
||||
|
|
|
@ -8,6 +8,7 @@ Text {
|
|||
AtLeastWarnings = Show warnings and errors
|
||||
OnlyErrors = Show errors only
|
||||
DownloadLogFile = Download complete log
|
||||
DownloadSysLogFile = Download complete syslog
|
||||
AgeOfEvent = Time passed
|
||||
EventText = Description
|
||||
TimeUnits {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
__revision__ = "$Id$"
|
||||
|
||||
import cryptobox.plugins.base
|
||||
import re
|
||||
import re, os
|
||||
import datetime
|
||||
import cherrypy
|
||||
|
||||
|
@ -71,6 +71,20 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
|
|||
self.__set_line_hdf_data(self.hdf_prefix + "Content.%d" % index, line)
|
||||
self.hdf[self.hdf_prefix + "Destination"] = \
|
||||
self.cbox.prefs["Log"]["Destination"].lower()
|
||||
|
||||
## this generates more download buttons if the files are available
|
||||
try:
|
||||
syslogfile = self.defaults["syslogfile"].lower()
|
||||
if os.access(syslogfile, os.R_OK):
|
||||
self.cbox.log.info("[logs]->syslogfile: '%s' will be exported" % syslogfile)
|
||||
self.hdf[self.hdf_prefix + "syslogfile"] = "readable"
|
||||
else:
|
||||
self.cbox.log.warn("[logs]->syslogfile: '%s' is not readable for cryptobox user" % syslogfile)
|
||||
self.hdf[self.hdf_prefix + "syslogfile"] = "not readable"
|
||||
except KeyError:
|
||||
self.cbox.log.error(
|
||||
"could not evaluate the config setting: "
|
||||
+ "[logs]->syslogfile")
|
||||
return "show_log"
|
||||
|
||||
|
||||
|
@ -87,7 +101,6 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
|
|||
return cherrypy.lib.cptools.serveFile(log_file,
|
||||
disposition="attachment", name="cryptobox_logfile.txt")
|
||||
|
||||
|
||||
def get_status(self):
|
||||
"""The current status includes the log configuration details.
|
||||
"""
|
||||
|
|
|
@ -66,10 +66,18 @@
|
|||
</table>
|
||||
<?cs call:print_form_header("download-log", "downloads/logs") ?>
|
||||
<p style="text-align:center">
|
||||
<button type="submit" value="refresh"><?cs
|
||||
var:html_escape(Lang.Plugins.logs.Text.DownloadLogFile) ?></button>
|
||||
<button type="submit" value="refresh"><?cs
|
||||
var:html_escape(Lang.Plugins.logs.Text.DownloadLogFile) ?></button>
|
||||
</p>
|
||||
</form>
|
||||
<?cs if:Data.Plugins.logs.syslogfile == "readable" ?>
|
||||
<?cs call:print_form_header("download-syslog", "syslog") ?>
|
||||
<p style="text-align:center">
|
||||
<button type="submit" value="refresh"><?cs
|
||||
var:html_escape(Lang.Plugins.logs.Text.DownloadSysLogFile) ?></button>
|
||||
</p>
|
||||
</form><?cs
|
||||
/if ?>
|
||||
<?cs else ?>
|
||||
<p style="text-align:center">
|
||||
<?cs call:hint("Plugins.logs.EmptyLog") ?>
|
||||
|
|
|
@ -434,7 +434,22 @@ class WebInterfaceSites:
|
|||
time.sleep(1)
|
||||
yield "</ul></p></html>"
|
||||
|
||||
|
||||
@cherrypy.expose
|
||||
def syslog(self, weblang="", help="0", device=None):
|
||||
"""export syslog
|
||||
"""
|
||||
from cherrypy.lib.cptools import serveFile
|
||||
try:
|
||||
syslogfile = self.cbox.prefs["PluginSettings"]["logs"]["syslogfile"]
|
||||
if os.access(syslogfile, os.R_OK):
|
||||
return serveFile(syslogfile, disposition="attachment", name="syslog")
|
||||
else:
|
||||
self.cbox.log.error("'%s' could not be exposed" % syslogfile)
|
||||
except KeyError:
|
||||
self.cbox.log.error(
|
||||
"could not evaluate the config setting: "
|
||||
+ "[logs]->syslogfile %s")
|
||||
|
||||
|
||||
##################### input checker ##########################
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue