{"action":"created","comment":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/29945032","id":29945032,"diff_hunk":"@@ -13,18 +14,30 @@\n import sys\n import traceback\n import copy\n+import timeit\n from pprint import pprint\n from collections import defaultdict\n \n from util import LaconicFilter, get_os, get_hostname, get_next_id, yLoader\n from config import get_confd_path\n from checks import check_status\n+from checks.utils import pretty_statistics\n \n # 3rd party\n import yaml\n \n+try:\n+    import psutil\n+    PSUTIL_PRESENT = True","path":"checks/__init__.py","position":26,"original_position":26,"commit_id":"726abef5665e97b056d704dad5dccd4e32328af5","original_commit_id":"726abef5665e97b056d704dad5dccd4e32328af5","user":{"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},"body":"e.g. https://github.com/DataDog/dd-agent/blob/1bef95f968c1d884e6aeddc93a692d8a387535c8/checks/system/win32.py#L5-L8","created_at":"2015-05-08T14:44:34Z","updated_at":"2015-05-08T14:44:34Z","html_url":"https://github.com/DataDog/dd-agent/pull/1577#discussion_r29945032","pull_request_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1577","_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/29945032"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/1577#discussion_r29945032"},"pull_request":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1577"}}},"pull_request":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1577","id":34062083,"html_url":"https://github.com/DataDog/dd-agent/pull/1577","diff_url":"https://github.com/DataDog/dd-agent/pull/1577.diff","patch_url":"https://github.com/DataDog/dd-agent/pull/1577.patch","issue_url":"https://api.github.com/repos/DataDog/dd-agent/issues/1577","number":1577,"state":"open","locked":false,"title":"Talwai/agent dev mode","user":{"login":"talwai","id":3237580,"avatar_url":"https://avatars.githubusercontent.com/u/3237580?v=3","gravatar_id":"","url":"https://api.github.com/users/talwai","html_url":"https://github.com/talwai","followers_url":"https://api.github.com/users/talwai/followers","following_url":"https://api.github.com/users/talwai/following{/other_user}","gists_url":"https://api.github.com/users/talwai/gists{/gist_id}","starred_url":"https://api.github.com/users/talwai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/talwai/subscriptions","organizations_url":"https://api.github.com/users/talwai/orgs","repos_url":"https://api.github.com/users/talwai/repos","events_url":"https://api.github.com/users/talwai/events{/privacy}","received_events_url":"https://api.github.com/users/talwai/received_events","type":"User","site_admin":false},"body":"This adds a \"developer mode\" to the agent, that can be enabled by the `--profile` command line flag or by the `developer_mode` setting in `agentConfig`. \r\n\r\nDeveloper mode can be enabled at the `check` level or the `collector` level. When enabled at the check\r\nlevel, e.g. `./agent.py check nginx --profile`, the `check.run()` function is profiled with `cProfile` and the `pstats` output is dumped to the log. \r\n\r\nWhen enabled at the `collector` level, the following behavior is enabled:\r\n- Every run of the collector loop is profiled with `cProfile`, in the same way as above\r\n- The `AgentMetrics` check (`checks.d/agent_metrics.py`) is run at the end of each collector loop. This check can be configured to run a set of additional `psutil.Process` methods on the current process. These additional metrics are flushed to the dispatcher as well as dumped to the log. See `conf.d/agent_metrics.yaml.default` for the default configuration, which can be extended as needed. Currently a setting under `process_metrics` is ignored if there is no corresponding `psutil.Process` method.\r\n","created_at":"2015-04-24T16:03:17Z","updated_at":"2015-05-08T14:44:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a96e8c2796e7ea8a814c4514214459bf553cadad","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1577/commits","review_comments_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1577/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/1577/comments","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/726abef5665e97b056d704dad5dccd4e32328af5","head":{"label":"DataDog:talwai/agent_dev_mode","ref":"talwai/agent_dev_mode","sha":"726abef5665e97b056d704dad5dccd4e32328af5","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}","created_at":"2010-12-31T03:02:47Z","updated_at":"2015-05-08T00:20:55Z","pushed_at":"2015-05-07T22:25:28Z","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":52630,"stargazers_count":275,"watchers_count":275,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":204,"mirror_url":null,"open_issues_count":168,"forks":204,"open_issues":168,"watchers":275,"default_branch":"master"}},"base":{"label":"DataDog:master","ref":"master","sha":"547f8c97b1a528ecd0d02d6fe11f401d94307113","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}","created_at":"2010-12-31T03:02:47Z","updated_at":"2015-05-08T00:20:55Z","pushed_at":"2015-05-07T22:25:28Z","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":52630,"stargazers_count":275,"watchers_count":275,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":204,"mirror_url":null,"open_issues_count":168,"forks":204,"open_issues":168,"watchers":275,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1577"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/1577"},"issue":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/1577"},"comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/1577/comments"},"review_comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1577/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/1577/commits"},"statuses":{"href":"https://api.github.com/repos/DataDog/dd-agent/statuses/726abef5665e97b056d704dad5dccd4e32328af5"}}}}