Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue plesk error log #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions modsec-log-parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

"""


from src.modsec_log_parser import ModSecLogParser
import argparse

Expand All @@ -33,35 +32,33 @@ def main():
files = args.files
summary = args.summary
delim = args.delim
if len(files) == 0:
if files is None or len(files) == 0:
files = "/dev/stdin"
if len(summary) == 0:
if summary is None or len(summary) == 0:
summary = "id,msg"

msclp = ModSecLogParser(files)
data = msclp.run()

ar = {}
if data == None:
if data is None:
return

for i in data:
z = ""
for xx in summary.split(","):
for xx in summary.split(","):
if len(z) > 0:
z = z + str(delim)
z = z + str(delim)
z = z + str(i.__dict__[xx])

if i.id in ar:
ar[z] = ar[str(i.id)] + 1
else:
ar[z] = 1

if i.id in ar:
ar[z] = ar[str(i.id)] + 1
else:
ar[z] = 1

for i in ar:
print str(i)

if __name__=="__main__":
main()
print(str(i))


if __name__ == "__main__":
main()
13 changes: 6 additions & 7 deletions src/modsec_log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@


"""

from . log_entry import LogEntry
import fileinput
from log_entry import LogEntry


class ModSecLogParser:
def __init__(self, watch = None):
def __init__(self, watch=None):
self.watch = watch
self.logs = []

def run(self):
for line in fileinput.input(self.watch):
l = LogEntry(string = line)
self.logs.append(l)
for line in fileinput.input(self.watch):
log = LogEntry(string=line)
self.logs.append(log)
return self.logs

self.sumarize()