{"action":"created","comment":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/35248007","id":35248007,"diff_hunk":"@@ -51,8 +105,12 @@ def check(self, instance):\n         tags = instance.get('tags', [])\n         cx_args = (host, port, timeout)\n         sc_tags = [\"host:{0}\".format(host), \"port:{0}\".format(port)]\n+        hostname = socket.gethostname()","path":"checks.d/zk.py","position":86,"original_position":86,"commit_id":"8edb86bf34e92b27d69dda3cb607ff532720b525","original_commit_id":"8edb86bf34e92b27d69dda3cb607ff532720b525","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":"The preferred way to do this in the agent is via `get_hostname` in the `util` module. See [the mongo check](https://github.com/DataDog/dd-agent/blob/7312a61a6d359e461c3481e24bd98ae6e489306a/checks.d/mongo.py#L10) for an example","created_at":"2015-07-22T18:40:08Z","updated_at":"2015-07-22T18:40:08Z","html_url":"https://github.com/DataDog/dd-agent/pull/1770#discussion_r35248007","pull_request_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1770","_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/35248007"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/1770#discussion_r35248007"},"pull_request":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1770"}}},"pull_request":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1770","id":39953862,"html_url":"https://github.com/DataDog/dd-agent/pull/1770","diff_url":"https://github.com/DataDog/dd-agent/pull/1770.diff","patch_url":"https://github.com/DataDog/dd-agent/pull/1770.patch","issue_url":"https://api.github.com/repos/DataDog/dd-agent/issues/1770","number":1770,"state":"open","locked":false,"title":"gather stats from zookeeper mntr command","user":{"login":"jpittis","id":5767836,"avatar_url":"https://avatars.githubusercontent.com/u/5767836?v=3","gravatar_id":"","url":"https://api.github.com/users/jpittis","html_url":"https://github.com/jpittis","followers_url":"https://api.github.com/users/jpittis/followers","following_url":"https://api.github.com/users/jpittis/following{/other_user}","gists_url":"https://api.github.com/users/jpittis/gists{/gist_id}","starred_url":"https://api.github.com/users/jpittis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpittis/subscriptions","organizations_url":"https://api.github.com/users/jpittis/orgs","repos_url":"https://api.github.com/users/jpittis/repos","events_url":"https://api.github.com/users/jpittis/events{/privacy}","received_events_url":"https://api.github.com/users/jpittis/received_events","type":"User","site_admin":false},"body":"With zookeeper `3.4.0`, the `mntr` 4 letter admin command was added.\r\nIt provides zookeeper stats in key value form and is designed to be parsed.\r\nFuture stats will be added to the `mntr` command output specifically for this reason.\r\n\r\n#### First Change\r\nThis change updates `checks.d/zk.py` to first parse the original `stat` command. If the zookeeper version supports the `mntr` command, it parses it too.\r\n\r\nHere is an example output of the `mntr` command.\r\n```\r\nzk_version  3.4.5-cdh4.4.0--1, built on 09/04/2013 01:46 GMT\r\nzk_avg_latency  0\r\nzk_max_latency  0\r\nzk_min_latency  0\r\nzk_packets_received 4\r\nzk_packets_sent 3\r\nzk_num_alive_connections    1\r\nzk_outstanding_requests 0\r\nzk_server_state standalone\r\nzk_znode_count  4\r\nzk_watch_count  0\r\nzk_ephemerals_count 0\r\nzk_approximate_data_size    27\r\nzk_open_file_descriptor_count   29\r\nzk_max_file_descriptor_count    4096\r\n```\r\n\r\n#### Second Change\r\nThis change adds `report_instance_mode` which when called, sends stats regarding the zookeeper status.\r\n\r\nA zookeeper node can be one of a `leader`, `follower`, `observer` or `standalone`. In addition, this check will report a mode of:\r\n- `down` when the check cannot connect to zookeeper\r\n- `inactive` when a node looses connection with the cluster\r\n- `unknown` when the check fails in an unexpected way\r\n\r\nThis data is reported firstly in a set `zookeeper.instances` as well as 7 gauges that can be set to `0` or `1` named `zookeeper.instances.<mode>`.\r\n\r\nWhen a node shifts say from `leader` to `down`, it's `zookeeper.instances.leader` value will be set to `0` and it's `zookeeper.instances.down` value will be set to `1`. This means you can rely on these values to notify you right when a node goes down.\r\n\r\nThe new mode system facilitates creating dashes and alerts for the change and distribution state in the cluster.\r\n\r\nThis patch is designed to be backwards compatible.","created_at":"2015-07-14T19:40:06Z","updated_at":"2015-07-22T18:40:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3434ba014c08e41aa894a435bfac76536251ce8c","assignee":{"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},"milestone":null,"commits_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1770/commits","review_comments_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1770/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/1770/comments","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/8edb86bf34e92b27d69dda3cb607ff532720b525","head":{"label":"Shopify:zookeeper-mntr-upstream","ref":"zookeeper-mntr-upstream","sha":"8edb86bf34e92b27d69dda3cb607ff532720b525","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":14601384,"name":"dd-agent","full_name":"Shopify/dd-agent","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/dd-agent","description":"Datadog Agent","fork":true,"url":"https://api.github.com/repos/Shopify/dd-agent","forks_url":"https://api.github.com/repos/Shopify/dd-agent/forks","keys_url":"https://api.github.com/repos/Shopify/dd-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/dd-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/dd-agent/teams","hooks_url":"https://api.github.com/repos/Shopify/dd-agent/hooks","issue_events_url":"https://api.github.com/repos/Shopify/dd-agent/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/dd-agent/events","assignees_url":"https://api.github.com/repos/Shopify/dd-agent/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/dd-agent/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/dd-agent/tags","blobs_url":"https://api.github.com/repos/Shopify/dd-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/dd-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/dd-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/dd-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/dd-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/dd-agent/languages","stargazers_url":"https://api.github.com/repos/Shopify/dd-agent/stargazers","contributors_url":"https://api.github.com/repos/Shopify/dd-agent/contributors","subscribers_url":"https://api.github.com/repos/Shopify/dd-agent/subscribers","subscription_url":"https://api.github.com/repos/Shopify/dd-agent/subscription","commits_url":"https://api.github.com/repos/Shopify/dd-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/dd-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/dd-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/dd-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/dd-agent/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/dd-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/dd-agent/merges","archive_url":"https://api.github.com/repos/Shopify/dd-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/dd-agent/downloads","issues_url":"https://api.github.com/repos/Shopify/dd-agent/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/dd-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/dd-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/dd-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/dd-agent/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/dd-agent/releases{/id}","created_at":"2013-11-21T22:03:43Z","updated_at":"2014-07-03T18:02:30Z","pushed_at":"2015-07-17T15:00:41Z","git_url":"git://github.com/Shopify/dd-agent.git","ssh_url":"git@github.com:Shopify/dd-agent.git","clone_url":"https://github.com/Shopify/dd-agent.git","svn_url":"https://github.com/Shopify/dd-agent","homepage":"http://docs.datadoghq.com/","size":27944,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"DataDog:master","ref":"master","sha":"7ac665cc870be5076469f368fb412332f1e32ce1","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-07-20T19:00:34Z","pushed_at":"2015-07-22T17:10:29Z","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":50636,"stargazers_count":312,"watchers_count":312,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":247,"mirror_url":null,"open_issues_count":176,"forks":247,"open_issues":176,"watchers":312,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1770"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/1770"},"issue":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/1770"},"comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/1770/comments"},"review_comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1770/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/1770/commits"},"statuses":{"href":"https://api.github.com/repos/DataDog/dd-agent/statuses/8edb86bf34e92b27d69dda3cb607ff532720b525"}}}}