Skip to content

Instantly share code, notes, and snippets.

@ak1211
Created March 2, 2016 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ak1211/61db9759de4b04d0a033 to your computer and use it in GitHub Desktop.
Save ak1211/61db9759de4b04d0a033 to your computer and use it in GitHub Desktop.
ログのメッセージフィールドから必要な値をとる
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])
#
matches = re.match (r'Group <(.*?)> User <(.*?)> IP <(.*?)>', sep[2])
result["Group"] = matches.group(1)
result["User"] = matches.group(2)
result["IP"] = matches.group(3)
return result
def extract_terminate_session_from_log(line):
sep = line.rstrip().split (': ')
result = {}
result["start log"] = None
result["line"] = line
#
result["Message"] = ': '.join (sep[2:])
result["Class"] = sep[1]
result["DateTime"] = toDateTime (sep[0])
#
matches = re.match (r'Group = (.*?), Username = (.*?), IP = (.*?), Session disconnected\. Session Type: (.*?), Duration: (.*?), ', result["Message"])
result["Group"] = matches.group(1)
result["User"] = matches.group(2)
result["IP"] = matches.group(3)
result["SessionType"] = matches.group(4)
result["Duration"] = matches.group(5)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment