SUMMARYPATH = "/mnt/andrew/temp/logparse-test.html"
OUTPUTPATH = "/mnt/andrew/temp/logparse-test2.html"
MAILPATH = "/mnt/andrew/temp/log-parse-test-3.html"
-HEADERPATH = "header.html"
+HEADERPATH = os.path.dirname(os.path.realpath(__file__)) + "/header.html"
STYLEPATH = "main.css"
MAILOUT = ""
HTMLOUT = ""
return
else:
path = pathpattern.sub(lambda m: pathfilter[re.escape(m.group(0))], path)
- return open(path, mode).read()
+ if (os.path.isfile(path) is False):
+ logger.error(path + " does not exist")
+ return ''
+ else:
+ return open(path, mode).read()
def writelog(path = None, content = "", mode = 'w'): # read file, substituting known paths
if (path == None or content == None):
else:
for user in users:
data.append(user[0] + ' (' + str(user[1]) + ')')
- logger.debug("found " + str(len(matches)) + " sudo sessions for users " + str(data))
+ logger.debug("found " + str(num) + " sudo sessions for users " + str(data))
writedata(subtitle, data)
if (len(commands) > 0):
commands = addtag(commands, 'code')
logger.debug("starting smbd section")
opentag('div', 1, 'smbd', 'section')
files = glob.glob(SMBDDIR + "/log.*[!\.gz][!\.old]") # find list of logfiles
+ logger.debug("found log files " + str(files))
n_auths = 0 # total number of logins from all users
sigma_auths = [] # contains users
output = ""
for file in files: # one log file for each client
+ logger.debug("looking at file " + file)
+
# find the machine (ip or hostname) that this file represents
ip = re.search('log\.(.*)', file).group(1) # get ip or hostname from file path (/var/log/samba/log.host)
host = resolve(ip)
logger.debug("starting zfs section")
opentag('div', 1, 'zfs', 'section')
zfslog = readlog('zfs')
+ logger.debug("zfs log is " + zfslog)
logger.debug("got zfs logfile\n" + zfslog + "---end log---")
pool = re.search('.*---\n(\w*)', zfslog).group(1)
scrub = re.search('.*scrub repaired (\d*) in \d*h\d*m with (\d*) errors on (\S*\s)(\S*)\s(\d+\s)', zfslog)