SUMMARYPATH = "/mnt/andrew/temp/logparse-test.html"
OUTPUTPATH = "/mnt/andrew/temp/logparse-test2.html"
MAILPATH = "/mnt/andrew/temp/log-parse-test-3.html"
SUMMARYPATH = "/mnt/andrew/temp/logparse-test.html"
OUTPUTPATH = "/mnt/andrew/temp/logparse-test2.html"
MAILPATH = "/mnt/andrew/temp/log-parse-test-3.html"
- 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):
def writelog(path = None, content = "", mode = 'w'): # read file, substituting known paths
if (path == None or content == None):
writedata(subtitle, data)
if (len(commands) > 0):
commands = addtag(commands, 'code')
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("starting smbd section")
opentag('div', 1, 'smbd', 'section')
files = glob.glob(SMBDDIR + "/log.*[!\.gz][!\.old]") # find list of logfiles
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
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
# 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)
# 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("starting zfs section")
opentag('div', 1, 'zfs', 'section')
zfslog = readlog('zfs')
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)
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)