{"action":"created","comment":{"url":"https://api.github.com/repos/kiddinn/playground/pulls/comments/217443815","pull_request_review_id":155157009,"id":217443815,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNzQ0MzgxNQ==","diff_hunk":"@@ -0,0 +1,126 @@\n+#!/usr/bin/python\n+\"\"\"A parser of /var/log/puppet.log.\n+\n+Imports argparse for parsing arguments and then the script\n+accepts file path and year as optional argument. \n+\"\"\"\n+\n+\n+import argparse \n+from datetime import datetime\n+import dateutil.parser\n+import re\n+import collections\n+import os\n+\n+\n+def main():\n+\tparser = argparse.ArgumentParser()\n+\tparser.add_argument(help=\"parse the given filename\", type=str, dest=\"filename\", action=\"store\")\n+\tparser.add_argument(\"-y\",\"--year\", help=\"parse file with given year\", type=int, dest=\"year\", action=\"store\")\n+\targs = parser.parse_args()\n+\tif args.year:\n+\t\tprint(\"year to use: \" + str(args.year))\n+\t\tyear = args.year\n+\n+\telse:\n+\t\tyear = datetime.utcfromtimestamp(os.stat(args.filename).st_mtime).year\n+\t\n+\tpuppet_parser(args.filename,year)\n+\n+\n+def puppet_parser(filepath, year):\n+\t\"\"\"Accepts the puppet file path and parses it out by calling other functions.\n+\n+\t\"\"\"\n+\t#TODO use year from last modification\n+\n+\t# pattern to match from log file and group each finding for referencing\n+\t# pattern looks for a time foormat (x:x:x)any text after which is\n+\t# followed by the process and so on \n+\tpattern = re.compile(r'(^.+:..:..)\\s(\\S+)\\s(\\S+)(\\[\\d+\\]):\\s(.+$)')\n+\t#group 1 = date\n+\t#group 2 = hostname\n+\t#group 3 = proccess\n+\t#group 4 = PID\n+\t#group 5 = message\n+\t\n+\t# add to list for counter purposes \n+\tmessage_list = []\n+\tproccess_list =[]\n+\thostname_list= []\n+\tprocessID_list = []\n+\t\n+\t\n+\tf = open(filepath, \"rU\")\n+\tfor line in f:\n+\n+\t\tif pattern.match(line):\n+\t\t\tif dateutil.parser.parse(pattern.match(line).group(1)).date().year == year:\n+\t\t\t\t\n+\t\t\t\thostname_list.append(pattern.match(line).group(2))\n+\t\t\t\tproccess_list.append(pattern.match(line).group(3))\n+\t\t\t\tprocessID_list.append(pattern.match(line).group(4))\n+\t\t\t\tmessage_list.append(pattern.match(line).group(5))\n+\t\t\t\t\n+\n+\tf.close()\n+\n+\tuniq_process(proccess_list)\n+\thostnames(hostname_list)\n+\ttop_messages(message_list)\n+\t\n+\t\n+\n+def parse_log(logDictionary):\n+\t\"\"\"Prints dictionary in order\n+\n+\t\"\"\"\n+\t#get dictionary and paste it in order \n+\tfor x in logDictionary:\n+\t\tprint x\n+\n+\n+def print_log(dic):\n+\t\"\"\"Print entire log.","path":"jukepoot/puppet_parser.py","position":85,"original_position":85,"commit_id":"ac2c15e85a07012ffbe7491bf511d6ceb3cee872","original_commit_id":"ac2c15e85a07012ffbe7491bf511d6ceb3cee872","user":{"login":"jukepoot","id":32882783,"node_id":"MDQ6VXNlcjMyODgyNzgz","avatar_url":"https://avatars3.githubusercontent.com/u/32882783?v=4","gravatar_id":"","url":"https://api.github.com/users/jukepoot","html_url":"https://github.com/jukepoot","followers_url":"https://api.github.com/users/jukepoot/followers","following_url":"https://api.github.com/users/jukepoot/following{/other_user}","gists_url":"https://api.github.com/users/jukepoot/gists{/gist_id}","starred_url":"https://api.github.com/users/jukepoot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jukepoot/subscriptions","organizations_url":"https://api.github.com/users/jukepoot/orgs","repos_url":"https://api.github.com/users/jukepoot/repos","events_url":"https://api.github.com/users/jukepoot/events{/privacy}","received_events_url":"https://api.github.com/users/jukepoot/received_events","type":"User","site_admin":false},"body":"that was my bad, looks like this was from the first revision where I printed the \"log\" or what I call the log of basically the entire puppet.log file which was fixed after seeing my mistakes in making multiple copies of the data. \r\n\r\n-removing. ","created_at":"2018-09-13T16:06:30Z","updated_at":"2018-09-13T16:06:30Z","html_url":"https://github.com/kiddinn/playground/pull/1#discussion_r217443815","pull_request_url":"https://api.github.com/repos/kiddinn/playground/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/kiddinn/playground/pulls/comments/217443815"},"html":{"href":"https://github.com/kiddinn/playground/pull/1#discussion_r217443815"},"pull_request":{"href":"https://api.github.com/repos/kiddinn/playground/pulls/1"}},"in_reply_to_id":213370856},"pull_request":{"url":"https://api.github.com/repos/kiddinn/playground/pulls/1","id":210398090,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwMzk4MDkw","html_url":"https://github.com/kiddinn/playground/pull/1","diff_url":"https://github.com/kiddinn/playground/pull/1.diff","patch_url":"https://github.com/kiddinn/playground/pull/1.patch","issue_url":"https://api.github.com/repos/kiddinn/playground/issues/1","number":1,"state":"open","locked":false,"title":"added changes from email","user":{"login":"jukepoot","id":32882783,"node_id":"MDQ6VXNlcjMyODgyNzgz","avatar_url":"https://avatars3.githubusercontent.com/u/32882783?v=4","gravatar_id":"","url":"https://api.github.com/users/jukepoot","html_url":"https://github.com/jukepoot","followers_url":"https://api.github.com/users/jukepoot/followers","following_url":"https://api.github.com/users/jukepoot/following{/other_user}","gists_url":"https://api.github.com/users/jukepoot/gists{/gist_id}","starred_url":"https://api.github.com/users/jukepoot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jukepoot/subscriptions","organizations_url":"https://api.github.com/users/jukepoot/orgs","repos_url":"https://api.github.com/users/jukepoot/repos","events_url":"https://api.github.com/users/jukepoot/events{/privacy}","received_events_url":"https://api.github.com/users/jukepoot/received_events","type":"User","site_admin":false},"body":"I hope I am doing this correctly.","created_at":"2018-08-23T10:14:50Z","updated_at":"2018-09-13T16:06:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"df4566e89300b88f36e09607e84283905ae9ba7a","assignee":{"login":"kiddinn","id":8701947,"node_id":"MDQ6VXNlcjg3MDE5NDc=","avatar_url":"https://avatars0.githubusercontent.com/u/8701947?v=4","gravatar_id":"","url":"https://api.github.com/users/kiddinn","html_url":"https://github.com/kiddinn","followers_url":"https://api.github.com/users/kiddinn/followers","following_url":"https://api.github.com/users/kiddinn/following{/other_user}","gists_url":"https://api.github.com/users/kiddinn/gists{/gist_id}","starred_url":"https://api.github.com/users/kiddinn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiddinn/subscriptions","organizations_url":"https://api.github.com/users/kiddinn/orgs","repos_url":"https://api.github.com/users/kiddinn/repos","events_url":"https://api.github.com/users/kiddinn/events{/privacy}","received_events_url":"https://api.github.com/users/kiddinn/received_events","type":"User","site_admin":false},"assignees":[{"login":"kiddinn","id":8701947,"node_id":"MDQ6VXNlcjg3MDE5NDc=","avatar_url":"https://avatars0.githubusercontent.com/u/8701947?v=4","gravatar_id":"","url":"https://api.github.com/users/kiddinn","html_url":"https://github.com/kiddinn","followers_url":"https://api.github.com/users/kiddinn/followers","following_url":"https://api.github.com/users/kiddinn/following{/other_user}","gists_url":"https://api.github.com/users/kiddinn/gists{/gist_id}","starred_url":"https://api.github.com/users/kiddinn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiddinn/subscriptions","organizations_url":"https://api.github.com/users/kiddinn/orgs","repos_url":"https://api.github.com/users/kiddinn/repos","events_url":"https://api.github.com/users/kiddinn/events{/privacy}","received_events_url":"https://api.github.com/users/kiddinn/received_events","type":"User","site_admin":false},{"login":"jukepoot","id":32882783,"node_id":"MDQ6VXNlcjMyODgyNzgz","avatar_url":"https://avatars3.githubusercontent.com/u/32882783?v=4","gravatar_id":"","url":"https://api.github.com/users/jukepoot","html_url":"https://github.com/jukepoot","followers_url":"https://api.github.com/users/jukepoot/followers","following_url":"https://api.github.com/users/jukepoot/following{/other_user}","gists_url":"https://api.github.com/users/jukepoot/gists{/gist_id}","starred_url":"https://api.github.com/users/jukepoot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jukepoot/subscriptions","organizations_url":"https://api.github.com/users/jukepoot/orgs","repos_url":"https://api.github.com/users/jukepoot/repos","events_url":"https://api.github.com/users/jukepoot/events{/privacy}","received_events_url":"https://api.github.com/users/jukepoot/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1026286397,"node_id":"MDU6TGFiZWwxMDI2Mjg2Mzk3","url":"https://api.github.com/repos/kiddinn/playground/labels/enhancement","name":"enhancement","color":"a2eeef","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/kiddinn/playground/pulls/1/commits","review_comments_url":"https://api.github.com/repos/kiddinn/playground/pulls/1/comments","review_comment_url":"https://api.github.com/repos/kiddinn/playground/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kiddinn/playground/issues/1/comments","statuses_url":"https://api.github.com/repos/kiddinn/playground/statuses/ac2c15e85a07012ffbe7491bf511d6ceb3cee872","head":{"label":"jukepoot:puppet_parser","ref":"puppet_parser","sha":"ac2c15e85a07012ffbe7491bf511d6ceb3cee872","user":{"login":"jukepoot","id":32882783,"node_id":"MDQ6VXNlcjMyODgyNzgz","avatar_url":"https://avatars3.githubusercontent.com/u/32882783?v=4","gravatar_id":"","url":"https://api.github.com/users/jukepoot","html_url":"https://github.com/jukepoot","followers_url":"https://api.github.com/users/jukepoot/followers","following_url":"https://api.github.com/users/jukepoot/following{/other_user}","gists_url":"https://api.github.com/users/jukepoot/gists{/gist_id}","starred_url":"https://api.github.com/users/jukepoot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jukepoot/subscriptions","organizations_url":"https://api.github.com/users/jukepoot/orgs","repos_url":"https://api.github.com/users/jukepoot/repos","events_url":"https://api.github.com/users/jukepoot/events{/privacy}","received_events_url":"https://api.github.com/users/jukepoot/received_events","type":"User","site_admin":false},"repo":{"id":145823910,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU4MjM5MTA=","name":"playground","full_name":"jukepoot/playground","owner":{"login":"jukepoot","id":32882783,"node_id":"MDQ6VXNlcjMyODgyNzgz","avatar_url":"https://avatars3.githubusercontent.com/u/32882783?v=4","gravatar_id":"","url":"https://api.github.com/users/jukepoot","html_url":"https://github.com/jukepoot","followers_url":"https://api.github.com/users/jukepoot/followers","following_url":"https://api.github.com/users/jukepoot/following{/other_user}","gists_url":"https://api.github.com/users/jukepoot/gists{/gist_id}","starred_url":"https://api.github.com/users/jukepoot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jukepoot/subscriptions","organizations_url":"https://api.github.com/users/jukepoot/orgs","repos_url":"https://api.github.com/users/jukepoot/repos","events_url":"https://api.github.com/users/jukepoot/events{/privacy}","received_events_url":"https://api.github.com/users/jukepoot/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jukepoot/playground","description":"Just for playing around","fork":true,"url":"https://api.github.com/repos/jukepoot/playground","forks_url":"https://api.github.com/repos/jukepoot/playground/forks","keys_url":"https://api.github.com/repos/jukepoot/playground/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jukepoot/playground/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jukepoot/playground/teams","hooks_url":"https://api.github.com/repos/jukepoot/playground/hooks","issue_events_url":"https://api.github.com/repos/jukepoot/playground/issues/events{/number}","events_url":"https://api.github.com/repos/jukepoot/playground/events","assignees_url":"https://api.github.com/repos/jukepoot/playground/assignees{/user}","branches_url":"https://api.github.com/repos/jukepoot/playground/branches{/branch}","tags_url":"https://api.github.com/repos/jukepoot/playground/tags","blobs_url":"https://api.github.com/repos/jukepoot/playground/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jukepoot/playground/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jukepoot/playground/git/refs{/sha}","trees_url":"https://api.github.com/repos/jukepoot/playground/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jukepoot/playground/statuses/{sha}","languages_url":"https://api.github.com/repos/jukepoot/playground/languages","stargazers_url":"https://api.github.com/repos/jukepoot/playground/stargazers","contributors_url":"https://api.github.com/repos/jukepoot/playground/contributors","subscribers_url":"https://api.github.com/repos/jukepoot/playground/subscribers","subscription_url":"https://api.github.com/repos/jukepoot/playground/subscription","commits_url":"https://api.github.com/repos/jukepoot/playground/commits{/sha}","git_commits_url":"https://api.github.com/repos/jukepoot/playground/git/commits{/sha}","comments_url":"https://api.github.com/repos/jukepoot/playground/comments{/number}","issue_comment_url":"https://api.github.com/repos/jukepoot/playground/issues/comments{/number}","contents_url":"https://api.github.com/repos/jukepoot/playground/contents/{+path}","compare_url":"https://api.github.com/repos/jukepoot/playground/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jukepoot/playground/merges","archive_url":"https://api.github.com/repos/jukepoot/playground/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jukepoot/playground/downloads","issues_url":"https://api.github.com/repos/jukepoot/playground/issues{/number}","pulls_url":"https://api.github.com/repos/jukepoot/playground/pulls{/number}","milestones_url":"https://api.github.com/repos/jukepoot/playground/milestones{/number}","notifications_url":"https://api.github.com/repos/jukepoot/playground/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jukepoot/playground/labels{/name}","releases_url":"https://api.github.com/repos/jukepoot/playground/releases{/id}","deployments_url":"https://api.github.com/repos/jukepoot/playground/deployments","created_at":"2018-08-23T08:24:17Z","updated_at":"2018-08-23T08:24:20Z","pushed_at":"2018-08-23T09:58:49Z","git_url":"git://github.com/jukepoot/playground.git","ssh_url":"git@github.com:jukepoot/playground.git","clone_url":"https://github.com/jukepoot/playground.git","svn_url":"https://github.com/jukepoot/playground","homepage":null,"size":2,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kiddinn:master","ref":"master","sha":"a135cc0472ace7ae74a03bf6b16c3ba7f84d29a3","user":{"login":"kiddinn","id":8701947,"node_id":"MDQ6VXNlcjg3MDE5NDc=","avatar_url":"https://avatars0.githubusercontent.com/u/8701947?v=4","gravatar_id":"","url":"https://api.github.com/users/kiddinn","html_url":"https://github.com/kiddinn","followers_url":"https://api.github.com/users/kiddinn/followers","following_url":"https://api.github.com/users/kiddinn/following{/other_user}","gists_url":"https://api.github.com/users/kiddinn/gists{/gist_id}","starred_url":"https://api.github.com/users/kiddinn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiddinn/subscriptions","organizations_url":"https://api.github.com/users/kiddinn/orgs","repos_url":"https://api.github.com/users/kiddinn/repos","events_url":"https://api.github.com/users/kiddinn/events{/privacy}","received_events_url":"https://api.github.com/users/kiddinn/received_events","type":"User","site_admin":false},"repo":{"id":144998402,"node_id":"MDEwOlJlcG9zaXRvcnkxNDQ5OTg0MDI=","name":"playground","full_name":"kiddinn/playground","owner":{"login":"kiddinn","id":8701947,"node_id":"MDQ6VXNlcjg3MDE5NDc=","avatar_url":"https://avatars0.githubusercontent.com/u/8701947?v=4","gravatar_id":"","url":"https://api.github.com/users/kiddinn","html_url":"https://github.com/kiddinn","followers_url":"https://api.github.com/users/kiddinn/followers","following_url":"https://api.github.com/users/kiddinn/following{/other_user}","gists_url":"https://api.github.com/users/kiddinn/gists{/gist_id}","starred_url":"https://api.github.com/users/kiddinn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiddinn/subscriptions","organizations_url":"https://api.github.com/users/kiddinn/orgs","repos_url":"https://api.github.com/users/kiddinn/repos","events_url":"https://api.github.com/users/kiddinn/events{/privacy}","received_events_url":"https://api.github.com/users/kiddinn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kiddinn/playground","description":"Just for playing around","fork":false,"url":"https://api.github.com/repos/kiddinn/playground","forks_url":"https://api.github.com/repos/kiddinn/playground/forks","keys_url":"https://api.github.com/repos/kiddinn/playground/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kiddinn/playground/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kiddinn/playground/teams","hooks_url":"https://api.github.com/repos/kiddinn/playground/hooks","issue_events_url":"https://api.github.com/repos/kiddinn/playground/issues/events{/number}","events_url":"https://api.github.com/repos/kiddinn/playground/events","assignees_url":"https://api.github.com/repos/kiddinn/playground/assignees{/user}","branches_url":"https://api.github.com/repos/kiddinn/playground/branches{/branch}","tags_url":"https://api.github.com/repos/kiddinn/playground/tags","blobs_url":"https://api.github.com/repos/kiddinn/playground/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kiddinn/playground/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kiddinn/playground/git/refs{/sha}","trees_url":"https://api.github.com/repos/kiddinn/playground/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kiddinn/playground/statuses/{sha}","languages_url":"https://api.github.com/repos/kiddinn/playground/languages","stargazers_url":"https://api.github.com/repos/kiddinn/playground/stargazers","contributors_url":"https://api.github.com/repos/kiddinn/playground/contributors","subscribers_url":"https://api.github.com/repos/kiddinn/playground/subscribers","subscription_url":"https://api.github.com/repos/kiddinn/playground/subscription","commits_url":"https://api.github.com/repos/kiddinn/playground/commits{/sha}","git_commits_url":"https://api.github.com/repos/kiddinn/playground/git/commits{/sha}","comments_url":"https://api.github.com/repos/kiddinn/playground/comments{/number}","issue_comment_url":"https://api.github.com/repos/kiddinn/playground/issues/comments{/number}","contents_url":"https://api.github.com/repos/kiddinn/playground/contents/{+path}","compare_url":"https://api.github.com/repos/kiddinn/playground/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kiddinn/playground/merges","archive_url":"https://api.github.com/repos/kiddinn/playground/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kiddinn/playground/downloads","issues_url":"https://api.github.com/repos/kiddinn/playground/issues{/number}","pulls_url":"https://api.github.com/repos/kiddinn/playground/pulls{/number}","milestones_url":"https://api.github.com/repos/kiddinn/playground/milestones{/number}","notifications_url":"https://api.github.com/repos/kiddinn/playground/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kiddinn/playground/labels{/name}","releases_url":"https://api.github.com/repos/kiddinn/playground/releases{/id}","deployments_url":"https://api.github.com/repos/kiddinn/playground/deployments","created_at":"2018-08-16T14:21:34Z","updated_at":"2018-08-16T14:21:50Z","pushed_at":"2018-08-23T15:29:23Z","git_url":"git://github.com/kiddinn/playground.git","ssh_url":"git@github.com:kiddinn/playground.git","clone_url":"https://github.com/kiddinn/playground.git","svn_url":"https://github.com/kiddinn/playground","homepage":null,"size":1,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kiddinn/playground/pulls/1"},"html":{"href":"https://github.com/kiddinn/playground/pull/1"},"issue":{"href":"https://api.github.com/repos/kiddinn/playground/issues/1"},"comments":{"href":"https://api.github.com/repos/kiddinn/playground/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/kiddinn/playground/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/kiddinn/playground/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kiddinn/playground/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/kiddinn/playground/statuses/ac2c15e85a07012ffbe7491bf511d6ceb3cee872"}},"author_association":"NONE"}}
{"actor":{"display_login":"jukepoot"}}