{"action":"created","comment":{"url":"https://api.github.com/repos/DataDog/gopsutil/pulls/comments/94235567","pull_request_review_id":14765204,"id":94235567,"diff_hunk":"@@ -52,6 +52,58 @@ func GetDockerStat() ([]CgroupDockerStat, error) {\n \treturn ret, nil\n }\n \n+// Generates a mapping of PIDs to container metadata.\n+func GetContainerStats() (map[string]ContainerStat, error) {\n+\tcontainerMap := make(map[string]ContainerStat)\n+\tpath := common.HostSys(\"fs/cgroup/cpuacct\")\n+\tif common.PathExists(path) {\n+\t\tcontents, err := common.ReadDirectory(path)\n+\t\tif err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\n+\t\t// If docker containers exist, collect their stats.\n+\t\tif common.StringsContains(contents, \"docker\") {\n+\t\t\tdockerStats, err := GetDockerStat()\n+\t\t\tif err != nil {\n+\t\t\t\treturn nil, err\n+\t\t\t}\n+\n+\t\t\tfor _, dockerStat := range dockerStats {\n+\t\t\t\tif !dockerStat.Running {\n+\t\t\t\t\tcontinue\n+\t\t\t\t}\n+\n+\t\t\t\tdockerPids, err := CgroupPIDDocker(dockerStat.ContainerID)\n+\t\t\t\tif err != nil {\n+\t\t\t\t\tcontinue\n+\t\t\t\t}\n+\n+\t\t\t\tbytes, err = json.Marshal(dockerStat)\n+\t\t\t\tif err != nil {\n+\t\t\t\t\tcontinue\n+\t\t\t\t}\n+\n+\t\t\t\tvar jsonMap map[string]string\n+\t\t\t\terr = json.Unmarshal(bytes, &jsonMap)","path":"docker/docker_linux.go","position":37,"original_position":37,"commit_id":"69a6bf64afd61c453f683e5776adbe35c0e30622","original_commit_id":"69a6bf64afd61c453f683e5776adbe35c0e30622","user":{"login":"conorbranagan","id":472446,"avatar_url":"https://avatars.githubusercontent.com/u/472446?v=3","gravatar_id":"","url":"https://api.github.com/users/conorbranagan","html_url":"https://github.com/conorbranagan","followers_url":"https://api.github.com/users/conorbranagan/followers","following_url":"https://api.github.com/users/conorbranagan/following{/other_user}","gists_url":"https://api.github.com/users/conorbranagan/gists{/gist_id}","starred_url":"https://api.github.com/users/conorbranagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conorbranagan/subscriptions","organizations_url":"https://api.github.com/users/conorbranagan/orgs","repos_url":"https://api.github.com/users/conorbranagan/repos","events_url":"https://api.github.com/users/conorbranagan/events{/privacy}","received_events_url":"https://api.github.com/users/conorbranagan/received_events","type":"User","site_admin":false},"body":"Doing a marshal then unmarshal like this is going to be pretty inefficient at higher container volumes (json is pretty slow in go). With an explicit struct you can avoid this altogether","created_at":"2016-12-30T15:29:50Z","updated_at":"2016-12-30T15:39:23Z","html_url":"https://github.com/DataDog/gopsutil/pull/1#discussion_r94235567","pull_request_url":"https://api.github.com/repos/DataDog/gopsutil/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/DataDog/gopsutil/pulls/comments/94235567"},"html":{"href":"https://github.com/DataDog/gopsutil/pull/1#discussion_r94235567"},"pull_request":{"href":"https://api.github.com/repos/DataDog/gopsutil/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/DataDog/gopsutil/pulls/1","id":99709503,"html_url":"https://github.com/DataDog/gopsutil/pull/1","diff_url":"https://github.com/DataDog/gopsutil/pull/1.diff","patch_url":"https://github.com/DataDog/gopsutil/pull/1.patch","issue_url":"https://api.github.com/repos/DataDog/gopsutil/issues/1","number":1,"state":"open","locked":false,"title":"Add container metadata to process payload","user":{"login":"z0br0wn","id":5431182,"avatar_url":"https://avatars.githubusercontent.com/u/5431182?v=3","gravatar_id":"","url":"https://api.github.com/users/z0br0wn","html_url":"https://github.com/z0br0wn","followers_url":"https://api.github.com/users/z0br0wn/followers","following_url":"https://api.github.com/users/z0br0wn/following{/other_user}","gists_url":"https://api.github.com/users/z0br0wn/gists{/gist_id}","starred_url":"https://api.github.com/users/z0br0wn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/z0br0wn/subscriptions","organizations_url":"https://api.github.com/users/z0br0wn/orgs","repos_url":"https://api.github.com/users/z0br0wn/repos","events_url":"https://api.github.com/users/z0br0wn/events{/privacy}","received_events_url":"https://api.github.com/users/z0br0wn/received_events","type":"User","site_admin":false},"body":"currently supports only docker","created_at":"2016-12-29T23:32:42Z","updated_at":"2016-12-30T15:39:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7ec72d47547c1a7f070516a148c16b06c0175909","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/DataDog/gopsutil/pulls/1/commits","review_comments_url":"https://api.github.com/repos/DataDog/gopsutil/pulls/1/comments","review_comment_url":"https://api.github.com/repos/DataDog/gopsutil/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DataDog/gopsutil/issues/1/comments","statuses_url":"https://api.github.com/repos/DataDog/gopsutil/statuses/69a6bf64afd61c453f683e5776adbe35c0e30622","head":{"label":"DataDog:zbrown/docker","ref":"zbrown/docker","sha":"69a6bf64afd61c453f683e5776adbe35c0e30622","user":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"repo":{"id":47970033,"name":"gopsutil","full_name":"DataDog/gopsutil","owner":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DataDog/gopsutil","description":"psutil for golang","fork":true,"url":"https://api.github.com/repos/DataDog/gopsutil","forks_url":"https://api.github.com/repos/DataDog/gopsutil/forks","keys_url":"https://api.github.com/repos/DataDog/gopsutil/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/gopsutil/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/gopsutil/teams","hooks_url":"https://api.github.com/repos/DataDog/gopsutil/hooks","issue_events_url":"https://api.github.com/repos/DataDog/gopsutil/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/gopsutil/events","assignees_url":"https://api.github.com/repos/DataDog/gopsutil/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/gopsutil/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/gopsutil/tags","blobs_url":"https://api.github.com/repos/DataDog/gopsutil/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/gopsutil/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/gopsutil/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/gopsutil/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/gopsutil/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/gopsutil/languages","stargazers_url":"https://api.github.com/repos/DataDog/gopsutil/stargazers","contributors_url":"https://api.github.com/repos/DataDog/gopsutil/contributors","subscribers_url":"https://api.github.com/repos/DataDog/gopsutil/subscribers","subscription_url":"https://api.github.com/repos/DataDog/gopsutil/subscription","commits_url":"https://api.github.com/repos/DataDog/gopsutil/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/gopsutil/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/gopsutil/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/gopsutil/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/gopsutil/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/gopsutil/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/gopsutil/merges","archive_url":"https://api.github.com/repos/DataDog/gopsutil/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/gopsutil/downloads","issues_url":"https://api.github.com/repos/DataDog/gopsutil/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/gopsutil/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/gopsutil/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/gopsutil/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/gopsutil/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/gopsutil/releases{/id}","deployments_url":"https://api.github.com/repos/DataDog/gopsutil/deployments","created_at":"2015-12-14T11:07:21Z","updated_at":"2016-06-02T15:27:16Z","pushed_at":"2016-12-29T23:32:43Z","git_url":"git://github.com/DataDog/gopsutil.git","ssh_url":"git@github.com:DataDog/gopsutil.git","clone_url":"https://github.com/DataDog/gopsutil.git","svn_url":"https://github.com/DataDog/gopsutil","homepage":null,"size":893,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"dd"}},"base":{"label":"DataDog:dd","ref":"dd","sha":"5b8a2e9c151b862bb6271137896ad3c9e99c9eac","user":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"repo":{"id":47970033,"name":"gopsutil","full_name":"DataDog/gopsutil","owner":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DataDog/gopsutil","description":"psutil for golang","fork":true,"url":"https://api.github.com/repos/DataDog/gopsutil","forks_url":"https://api.github.com/repos/DataDog/gopsutil/forks","keys_url":"https://api.github.com/repos/DataDog/gopsutil/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/gopsutil/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/gopsutil/teams","hooks_url":"https://api.github.com/repos/DataDog/gopsutil/hooks","issue_events_url":"https://api.github.com/repos/DataDog/gopsutil/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/gopsutil/events","assignees_url":"https://api.github.com/repos/DataDog/gopsutil/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/gopsutil/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/gopsutil/tags","blobs_url":"https://api.github.com/repos/DataDog/gopsutil/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/gopsutil/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/gopsutil/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/gopsutil/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/gopsutil/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/gopsutil/languages","stargazers_url":"https://api.github.com/repos/DataDog/gopsutil/stargazers","contributors_url":"https://api.github.com/repos/DataDog/gopsutil/contributors","subscribers_url":"https://api.github.com/repos/DataDog/gopsutil/subscribers","subscription_url":"https://api.github.com/repos/DataDog/gopsutil/subscription","commits_url":"https://api.github.com/repos/DataDog/gopsutil/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/gopsutil/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/gopsutil/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/gopsutil/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/gopsutil/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/gopsutil/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/gopsutil/merges","archive_url":"https://api.github.com/repos/DataDog/gopsutil/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/gopsutil/downloads","issues_url":"https://api.github.com/repos/DataDog/gopsutil/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/gopsutil/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/gopsutil/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/gopsutil/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/gopsutil/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/gopsutil/releases{/id}","deployments_url":"https://api.github.com/repos/DataDog/gopsutil/deployments","created_at":"2015-12-14T11:07:21Z","updated_at":"2016-06-02T15:27:16Z","pushed_at":"2016-12-29T23:32:43Z","git_url":"git://github.com/DataDog/gopsutil.git","ssh_url":"git@github.com:DataDog/gopsutil.git","clone_url":"https://github.com/DataDog/gopsutil.git","svn_url":"https://github.com/DataDog/gopsutil","homepage":null,"size":893,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"dd"}},"_links":{"self":{"href":"https://api.github.com/repos/DataDog/gopsutil/pulls/1"},"html":{"href":"https://github.com/DataDog/gopsutil/pull/1"},"issue":{"href":"https://api.github.com/repos/DataDog/gopsutil/issues/1"},"comments":{"href":"https://api.github.com/repos/DataDog/gopsutil/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/DataDog/gopsutil/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/DataDog/gopsutil/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DataDog/gopsutil/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/DataDog/gopsutil/statuses/69a6bf64afd61c453f683e5776adbe35c0e30622"}}}}
{"actor":{"display_login":"conorbranagan"}}