This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html = """ | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<script type="text/javascript" src="https://www.google.com/jsapi"></script> | |
<script type="text/javascript"> | |
google.load('visualization', '1', {{'packages':['timeline']}}); | |
google.setOnLoadCallback(drawChart); | |
function drawChart() {{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buf = [] | |
for num, item in enumerate (start_session_logs): | |
st = item | |
tm = item["terminate log"] | |
text = "[ '{0}', '{1}'".format (1+num, st["User"]) | |
text = text + ", new Date({0})".format (st["DateTime"].strftime ('%Y, %m, %d, %H, %M, %S')) | |
if tm: | |
text = text + ", new Date({0})".format (tm["DateTime"].strftime ('%Y, %m, %d, %H, %M, %S')) | |
text = text + "]," | |
buf.append (text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def toDateTime (log_datetime): | |
date = (log_datetime.split(' '))[3:] | |
return datetime.datetime.strptime (' '.join (date), "%b %d %H:%M:%S %Z") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_start_session_from_log(line): | |
sep = line.rstrip().split (': ') | |
result = {} | |
result["terminate log"] = None | |
result["line"] = line | |
# | |
result["Message"] = sep[2] | |
result["Class"] = sep[1] | |
result["DateTime"] = toDateTime (sep[0]) | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start_session_logs = [] | |
terminate_session_logs = [] | |
for line in sys.stdin: | |
if re.search (r'%ASA-[^:]+?-113039:', line): | |
start_session_logs.append ( | |
extract_start_session_from_log (line)) | |
# | |
if re.search (r'%ASA-[^:]+?-113019:', line): | |
terminate_session_logs.append ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for start in start_session_logs: | |
term = next(itertools.ifilter(lambda it:it["DateTime"] >= start["DateTime"] and it["IP"] == start["IP"], terminate_session_logs), None) | |
if term: | |
start["terminate log"] = term | |
term["start log"] = start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
term = next(itertools.ifilter(lambda it:it["DateTime"] >= start["DateTime"] and it["IP"] == start["IP"], terminate_session_logs), None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipR, pipW = os.pipe () | |
os.close (pipR) | |
os.dup2 (3, pipW) | |
unterminated_file = os.fdopen (pipW, "w") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for item in itertools.ifilter(lambda it:it["terminate log"] == None, start_session_logs): | |
print >> unterminated_file, item["line"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for item in itertools.ifilter(lambda it:it["start log"] == None, terminate_session_logs): | |
print >> sys.stderr, "This record," | |
print >> sys.stderr, item["line"] , | |
print >> sys.stderr, " has no relationship!" |
OlderNewer