{"action":"created","comment":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/77340282","id":77340282,"diff_hunk":"@@ -491,14 +511,34 @@ def _report_container_size(self, containers_by_id):\n             tags = self._get_tags(container, PERFORMANCE)\n             m_func = FUNC_MAP[GAUGE][self.use_histogram]\n             if \"SizeRw\" in container:\n-\n                 m_func(self, 'docker.container.size_rw', container['SizeRw'],\n                        tags=tags)\n             if \"SizeRootFs\" in container:\n                 m_func(\n                     self, 'docker.container.size_rootfs', container['SizeRootFs'],\n                     tags=tags)\n \n+    def _report_container_count_by_state(self, containers_by_id, state=\"Any\"):\n+        count = 0\n+        tags = {}\n+        filterlambda = lambda x: not self._is_container_excluded(x) and state is \"Any\" or container[\"State\"] is state","path":"checks.d/docker_daemon.py","position":49,"original_position":49,"commit_id":"7c4716b2ac62f4f071ec2158352d3206922a1f80","original_commit_id":"7c4716b2ac62f4f071ec2158352d3206922a1f80","user":{"login":"hkaj","id":5287287,"avatar_url":"https://avatars.githubusercontent.com/u/5287287?v=3","gravatar_id":"","url":"https://api.github.com/users/hkaj","html_url":"https://github.com/hkaj","followers_url":"https://api.github.com/users/hkaj/followers","following_url":"https://api.github.com/users/hkaj/following{/other_user}","gists_url":"https://api.github.com/users/hkaj/gists{/gist_id}","starred_url":"https://api.github.com/users/hkaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hkaj/subscriptions","organizations_url":"https://api.github.com/users/hkaj/orgs","repos_url":"https://api.github.com/users/hkaj/repos","events_url":"https://api.github.com/users/hkaj/events{/privacy}","received_events_url":"https://api.github.com/users/hkaj/received_events","type":"User","site_admin":false},"body":"`container[\"State\"]` --> `x[\"State\"]`, or rename x to container and `self._is_container_excluded(x)` --> `self._is_container_excluded(container)` ","created_at":"2016-09-02T12:49:59Z","updated_at":"2016-09-02T12:49:59Z","html_url":"https://github.com/DataDog/dd-agent/pull/2740#discussion_r77340282","pull_request_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/2740","_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/77340282"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/2740#discussion_r77340282"},"pull_request":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/2740"}}},"pull_request":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/2740","id":80545589,"html_url":"https://github.com/DataDog/dd-agent/pull/2740","diff_url":"https://github.com/DataDog/dd-agent/pull/2740.diff","patch_url":"https://github.com/DataDog/dd-agent/pull/2740.patch","issue_url":"https://api.github.com/repos/DataDog/dd-agent/issues/2740","number":2740,"state":"open","locked":false,"title":"[docker_daemon] Add 5 opt-in checks for container & volume counts","user":{"login":"parkr","id":237985,"avatar_url":"https://avatars.githubusercontent.com/u/237985?v=3","gravatar_id":"","url":"https://api.github.com/users/parkr","html_url":"https://github.com/parkr","followers_url":"https://api.github.com/users/parkr/followers","following_url":"https://api.github.com/users/parkr/following{/other_user}","gists_url":"https://api.github.com/users/parkr/gists{/gist_id}","starred_url":"https://api.github.com/users/parkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkr/subscriptions","organizations_url":"https://api.github.com/users/parkr/orgs","repos_url":"https://api.github.com/users/parkr/repos","events_url":"https://api.github.com/users/parkr/events{/privacy}","received_events_url":"https://api.github.com/users/parkr/received_events","type":"User","site_admin":true},"body":"### What does this PR do?\r\n\r\nThis pull request adds 5 new metrics:\r\n\r\n- `docker.containers.count` – equivalent to `docker ps -a | wc -l`\r\n- `docker.containers.state_dead.count` – count of all dead containers\r\n- `docker.containers.state_exited.count` – count of all exited containers\r\n- `docker.volumes.count` – count of all volumes\r\n- `docker.volumes.dangling.count` – count of all dangling volumes\r\n\r\nEach metric has its own toggle in the settings so you can opt in to each on its own.\r\n\r\n### Motivation\r\n\r\nWe've been battling a bit of weirdness with containers and volumes lying around. We use ephemeral docker containers for some operations but found that volumes would be lying around in the \"dangling\" state, and that some containers weren't properly cleaned up.\r\n\r\n### Testing Guidelines\r\n\r\nAn overview on [testing](https://github.com/DataDog/dd-agent/blob/master/tests/README.md)\r\nis available in our contribution guidelines.\r\n\r\n### Additional Notes\r\n\r\nI went with one monolithic commit here because the code was too close together for Git to play nicely with cherry-picking the commits. Let me know if that wasn't the right way to go and I can make 5 distinct commits.","created_at":"2016-08-09T00:48:40Z","updated_at":"2016-09-02T12:49:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b9c390797370f7db40933fb1a9142e2ff4cb9ad","assignee":{"login":"remh","id":1311477,"avatar_url":"https://avatars.githubusercontent.com/u/1311477?v=3","gravatar_id":"","url":"https://api.github.com/users/remh","html_url":"https://github.com/remh","followers_url":"https://api.github.com/users/remh/followers","following_url":"https://api.github.com/users/remh/following{/other_user}","gists_url":"https://api.github.com/users/remh/gists{/gist_id}","starred_url":"https://api.github.com/users/remh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remh/subscriptions","organizations_url":"https://api.github.com/users/remh/orgs","repos_url":"https://api.github.com/users/remh/repos","events_url":"https://api.github.com/users/remh/events{/privacy}","received_events_url":"https://api.github.com/users/remh/received_events","type":"User","site_admin":false},"assignees":[{"login":"remh","id":1311477,"avatar_url":"https://avatars.githubusercontent.com/u/1311477?v=3","gravatar_id":"","url":"https://api.github.com/users/remh","html_url":"https://github.com/remh","followers_url":"https://api.github.com/users/remh/followers","following_url":"https://api.github.com/users/remh/following{/other_user}","gists_url":"https://api.github.com/users/remh/gists{/gist_id}","starred_url":"https://api.github.com/users/remh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remh/subscriptions","organizations_url":"https://api.github.com/users/remh/orgs","repos_url":"https://api.github.com/users/remh/repos","events_url":"https://api.github.com/users/remh/events{/privacy}","received_events_url":"https://api.github.com/users/remh/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/DataDog/dd-agent/milestones/62","html_url":"https://github.com/DataDog/dd-agent/milestones/Triage","labels_url":"https://api.github.com/repos/DataDog/dd-agent/milestones/62/labels","id":1485890,"number":62,"title":"Triage","description":null,"creator":{"login":"remh","id":1311477,"avatar_url":"https://avatars.githubusercontent.com/u/1311477?v=3","gravatar_id":"","url":"https://api.github.com/users/remh","html_url":"https://github.com/remh","followers_url":"https://api.github.com/users/remh/followers","following_url":"https://api.github.com/users/remh/following{/other_user}","gists_url":"https://api.github.com/users/remh/gists{/gist_id}","starred_url":"https://api.github.com/users/remh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remh/subscriptions","organizations_url":"https://api.github.com/users/remh/orgs","repos_url":"https://api.github.com/users/remh/repos","events_url":"https://api.github.com/users/remh/events{/privacy}","received_events_url":"https://api.github.com/users/remh/received_events","type":"User","site_admin":false},"open_issues":53,"closed_issues":22,"state":"open","created_at":"2016-01-05T21:06:49Z","updated_at":"2016-08-29T17:03:51Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/2740/commits","review_comments_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/2740/comments","review_comment_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DataDog/dd-agent/issues/2740/comments","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/7c4716b2ac62f4f071ec2158352d3206922a1f80","head":{"label":"parkr:docker-daemon-track-containers-volumes","ref":"docker-daemon-track-containers-volumes","sha":"7c4716b2ac62f4f071ec2158352d3206922a1f80","user":{"login":"parkr","id":237985,"avatar_url":"https://avatars.githubusercontent.com/u/237985?v=3","gravatar_id":"","url":"https://api.github.com/users/parkr","html_url":"https://github.com/parkr","followers_url":"https://api.github.com/users/parkr/followers","following_url":"https://api.github.com/users/parkr/following{/other_user}","gists_url":"https://api.github.com/users/parkr/gists{/gist_id}","starred_url":"https://api.github.com/users/parkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkr/subscriptions","organizations_url":"https://api.github.com/users/parkr/orgs","repos_url":"https://api.github.com/users/parkr/repos","events_url":"https://api.github.com/users/parkr/events{/privacy}","received_events_url":"https://api.github.com/users/parkr/received_events","type":"User","site_admin":true},"repo":{"id":65249695,"name":"dd-agent","full_name":"parkr/dd-agent","owner":{"login":"parkr","id":237985,"avatar_url":"https://avatars.githubusercontent.com/u/237985?v=3","gravatar_id":"","url":"https://api.github.com/users/parkr","html_url":"https://github.com/parkr","followers_url":"https://api.github.com/users/parkr/followers","following_url":"https://api.github.com/users/parkr/following{/other_user}","gists_url":"https://api.github.com/users/parkr/gists{/gist_id}","starred_url":"https://api.github.com/users/parkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkr/subscriptions","organizations_url":"https://api.github.com/users/parkr/orgs","repos_url":"https://api.github.com/users/parkr/repos","events_url":"https://api.github.com/users/parkr/events{/privacy}","received_events_url":"https://api.github.com/users/parkr/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/parkr/dd-agent","description":"Datadog Agent","fork":true,"url":"https://api.github.com/repos/parkr/dd-agent","forks_url":"https://api.github.com/repos/parkr/dd-agent/forks","keys_url":"https://api.github.com/repos/parkr/dd-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/parkr/dd-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/parkr/dd-agent/teams","hooks_url":"https://api.github.com/repos/parkr/dd-agent/hooks","issue_events_url":"https://api.github.com/repos/parkr/dd-agent/issues/events{/number}","events_url":"https://api.github.com/repos/parkr/dd-agent/events","assignees_url":"https://api.github.com/repos/parkr/dd-agent/assignees{/user}","branches_url":"https://api.github.com/repos/parkr/dd-agent/branches{/branch}","tags_url":"https://api.github.com/repos/parkr/dd-agent/tags","blobs_url":"https://api.github.com/repos/parkr/dd-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/parkr/dd-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/parkr/dd-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/parkr/dd-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/parkr/dd-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/parkr/dd-agent/languages","stargazers_url":"https://api.github.com/repos/parkr/dd-agent/stargazers","contributors_url":"https://api.github.com/repos/parkr/dd-agent/contributors","subscribers_url":"https://api.github.com/repos/parkr/dd-agent/subscribers","subscription_url":"https://api.github.com/repos/parkr/dd-agent/subscription","commits_url":"https://api.github.com/repos/parkr/dd-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/parkr/dd-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/parkr/dd-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/parkr/dd-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/parkr/dd-agent/contents/{+path}","compare_url":"https://api.github.com/repos/parkr/dd-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/parkr/dd-agent/merges","archive_url":"https://api.github.com/repos/parkr/dd-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/parkr/dd-agent/downloads","issues_url":"https://api.github.com/repos/parkr/dd-agent/issues{/number}","pulls_url":"https://api.github.com/repos/parkr/dd-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/parkr/dd-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/parkr/dd-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/parkr/dd-agent/labels{/name}","releases_url":"https://api.github.com/repos/parkr/dd-agent/releases{/id}","deployments_url":"https://api.github.com/repos/parkr/dd-agent/deployments","created_at":"2016-08-09T00:35:46Z","updated_at":"2016-08-09T00:35:49Z","pushed_at":"2016-09-02T00:57:21Z","git_url":"git://github.com/parkr/dd-agent.git","ssh_url":"git@github.com:parkr/dd-agent.git","clone_url":"https://github.com/parkr/dd-agent.git","svn_url":"https://github.com/parkr/dd-agent","homepage":"http://docs.datadoghq.com/","size":38887,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"DataDog:master","ref":"master","sha":"e03e6007562f16eee41b189bdfdf3628dc71abd6","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":1210071,"name":"dd-agent","full_name":"DataDog/dd-agent","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/dd-agent","description":"Datadog Agent","fork":false,"url":"https://api.github.com/repos/DataDog/dd-agent","forks_url":"https://api.github.com/repos/DataDog/dd-agent/forks","keys_url":"https://api.github.com/repos/DataDog/dd-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/dd-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/dd-agent/teams","hooks_url":"https://api.github.com/repos/DataDog/dd-agent/hooks","issue_events_url":"https://api.github.com/repos/DataDog/dd-agent/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/dd-agent/events","assignees_url":"https://api.github.com/repos/DataDog/dd-agent/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/dd-agent/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/dd-agent/tags","blobs_url":"https://api.github.com/repos/DataDog/dd-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/dd-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/dd-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/dd-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/dd-agent/languages","stargazers_url":"https://api.github.com/repos/DataDog/dd-agent/stargazers","contributors_url":"https://api.github.com/repos/DataDog/dd-agent/contributors","subscribers_url":"https://api.github.com/repos/DataDog/dd-agent/subscribers","subscription_url":"https://api.github.com/repos/DataDog/dd-agent/subscription","commits_url":"https://api.github.com/repos/DataDog/dd-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/dd-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/dd-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/dd-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/dd-agent/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/dd-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/dd-agent/merges","archive_url":"https://api.github.com/repos/DataDog/dd-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/dd-agent/downloads","issues_url":"https://api.github.com/repos/DataDog/dd-agent/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/dd-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/dd-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/dd-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/dd-agent/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/dd-agent/releases{/id}","deployments_url":"https://api.github.com/repos/DataDog/dd-agent/deployments","created_at":"2010-12-31T03:02:47Z","updated_at":"2016-09-02T08:39:52Z","pushed_at":"2016-09-02T03:07:31Z","git_url":"git://github.com/DataDog/dd-agent.git","ssh_url":"git@github.com:DataDog/dd-agent.git","clone_url":"https://github.com/DataDog/dd-agent.git","svn_url":"https://github.com/DataDog/dd-agent","homepage":"http://docs.datadoghq.com/","size":49414,"stargazers_count":591,"watchers_count":591,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":536,"mirror_url":null,"open_issues_count":218,"forks":536,"open_issues":218,"watchers":591,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/2740"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/2740"},"issue":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/2740"},"comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/2740/comments"},"review_comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/2740/comments"},"review_comment":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/2740/commits"},"statuses":{"href":"https://api.github.com/repos/DataDog/dd-agent/statuses/7c4716b2ac62f4f071ec2158352d3206922a1f80"}}}}
{"actor":{"display_login":"hkaj"}}