{"action":"created","comment":{"url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/comments/23047124","id":23047124,"diff_hunk":"@@ -0,0 +1,121 @@\n+package collectors\n+\n+import (\n+\t\"io/ioutil\"\n+\t\"log\"\n+\t\"net/http\"\n+\t\"strconv\"\n+\t\"strings\"\n+\t\"time\"\n+\n+\t\"golang.org/x/net/html\"\n+\n+\t\"bosun.org/metadata\"\n+\t\"bosun.org/opentsdb\"\n+)\n+\n+func init() {\n+\tcollectors = append(collectors, &IntervalCollector{F: c_apache_mod_info, Interval: time.Minute * 30})\n+}\n+\n+// Extract from HTML recieved from http://127.0.0.1/server-info?server\n+// Find the line that looks like:\n+// \"Timeouts: connection: 60 keep-alive: 15\"\n+// Returns the two values contained therein.\n+\n+func extract_timeouts(doc *html.Node) (int, int) {\n+\n+\t// Walk the node tree.\n+\t// If the node is a \"dt\",\n+\t//     walk its children until we find CONTENTS \"Timeouts:\"\n+\t//         At which point we walk those children to find \"connection\".\n+\t// Else, keep walking.\n+\t//     Then continue walking Children to find CONTENTS startswith \"connection\":\n+\t//     Return contents\n+\n+\tvar value string\n+\tvar search_children func(*html.Node) string\n+\tsearch_children = func(n *html.Node) string {\n+\t\tif n.Type == html.TextNode {\n+\t\t\tif strings.HasPrefix(n.Data, \"connection:\") {\n+\t\t\t\tvalue = n.Data\n+\t\t\t\treturn value\n+\t\t\t}\n+\t\t}\n+\t\tfor c := n.FirstChild; c != nil; c = c.NextSibling {\n+\t\t\tif value = search_children(c); value != \"\" {\n+\t\t\t\treturn value\n+\t\t\t}\n+\t\t}\n+\t\treturn value\n+\t}\n+\n+\tvar walk_subtree func(*html.Node) string\n+\twalk_subtree = func(n *html.Node) string {\n+\t\tif n.Type == html.ElementNode && n.Data == \"dt\" {\n+\t\t\tif val := search_children(n); val != \"\" {\n+\t\t\t\treturn val\n+\t\t\t}\n+\t\t} else {\n+\t\t\tfor c := n.FirstChild; c != nil; c = c.NextSibling {\n+\t\t\t\tif val := walk_subtree(c); val != \"\" {\n+\t\t\t\t\treturn val\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t\treturn \"\"\n+\t}\n+\n+\toriginal := walk_subtree(doc)\n+\tparts := strings.Fields(original)\n+\tif (parts[0] != \"connection:\") || (parts[2] != \"keep-alive:\") {\n+\t\tlog.Fatal(\"Format of connection: / keep-alive: line changed\")\n+\t}\n+\n+\tc, _ := strconv.Atoi(parts[1])\n+\tk, _ := strconv.Atoi(parts[3])\n+\treturn c, k\n+","path":"cmd/scollector/collectors/apache_mod_info.go","position":78,"original_position":78,"commit_id":"bf41bb1d0060f139f6a35391da21c4e8fda8e827","original_commit_id":"bf41bb1d0060f139f6a35391da21c4e8fda8e827","user":{"login":"mjibson","id":41181,"avatar_url":"https://avatars.githubusercontent.com/u/41181?v=3","gravatar_id":"","url":"https://api.github.com/users/mjibson","html_url":"https://github.com/mjibson","followers_url":"https://api.github.com/users/mjibson/followers","following_url":"https://api.github.com/users/mjibson/following{/other_user}","gists_url":"https://api.github.com/users/mjibson/gists{/gist_id}","starred_url":"https://api.github.com/users/mjibson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjibson/subscriptions","organizations_url":"https://api.github.com/users/mjibson/orgs","repos_url":"https://api.github.com/users/mjibson/repos","events_url":"https://api.github.com/users/mjibson/events{/privacy}","received_events_url":"https://api.github.com/users/mjibson/received_events","type":"User","site_admin":false},"body":"remove this newline","created_at":"2015-01-15T21:55:46Z","updated_at":"2015-01-15T21:55:46Z","html_url":"https://github.com/bosun-monitor/bosun/pull/659#discussion_r23047124","pull_request_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/659","_links":{"self":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/comments/23047124"},"html":{"href":"https://github.com/bosun-monitor/bosun/pull/659#discussion_r23047124"},"pull_request":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/659"}}},"pull_request":{"url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/659","id":27462515,"html_url":"https://github.com/bosun-monitor/bosun/pull/659","diff_url":"https://github.com/bosun-monitor/bosun/pull/659.diff","patch_url":"https://github.com/bosun-monitor/bosun/pull/659.patch","issue_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/659","number":659,"state":"open","locked":false,"title":"New collector: Apache mod_info","user":{"login":"tlimoncelli","id":6293917,"avatar_url":"https://avatars.githubusercontent.com/u/6293917?v=3","gravatar_id":"","url":"https://api.github.com/users/tlimoncelli","html_url":"https://github.com/tlimoncelli","followers_url":"https://api.github.com/users/tlimoncelli/followers","following_url":"https://api.github.com/users/tlimoncelli/following{/other_user}","gists_url":"https://api.github.com/users/tlimoncelli/gists{/gist_id}","starred_url":"https://api.github.com/users/tlimoncelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlimoncelli/subscriptions","organizations_url":"https://api.github.com/users/tlimoncelli/orgs","repos_url":"https://api.github.com/users/tlimoncelli/repos","events_url":"https://api.github.com/users/tlimoncelli/events{/privacy}","received_events_url":"https://api.github.com/users/tlimoncelli/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-15T21:11:54Z","updated_at":"2015-01-15T21:55:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b29a97e6289b953e21b50ee9f1565db53e9f205","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/659/commits","review_comments_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/659/comments","review_comment_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/comments/{number}","comments_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/659/comments","statuses_url":"https://api.github.com/repos/bosun-monitor/bosun/statuses/bf41bb1d0060f139f6a35391da21c4e8fda8e827","head":{"label":"bosun-monitor:tlim_apache","ref":"tlim_apache","sha":"bf41bb1d0060f139f6a35391da21c4e8fda8e827","user":{"login":"bosun-monitor","id":9555242,"avatar_url":"https://avatars.githubusercontent.com/u/9555242?v=3","gravatar_id":"","url":"https://api.github.com/users/bosun-monitor","html_url":"https://github.com/bosun-monitor","followers_url":"https://api.github.com/users/bosun-monitor/followers","following_url":"https://api.github.com/users/bosun-monitor/following{/other_user}","gists_url":"https://api.github.com/users/bosun-monitor/gists{/gist_id}","starred_url":"https://api.github.com/users/bosun-monitor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bosun-monitor/subscriptions","organizations_url":"https://api.github.com/users/bosun-monitor/orgs","repos_url":"https://api.github.com/users/bosun-monitor/repos","events_url":"https://api.github.com/users/bosun-monitor/events{/privacy}","received_events_url":"https://api.github.com/users/bosun-monitor/received_events","type":"Organization","site_admin":false},"repo":{"id":14410778,"name":"bosun","full_name":"bosun-monitor/bosun","owner":{"login":"bosun-monitor","id":9555242,"avatar_url":"https://avatars.githubusercontent.com/u/9555242?v=3","gravatar_id":"","url":"https://api.github.com/users/bosun-monitor","html_url":"https://github.com/bosun-monitor","followers_url":"https://api.github.com/users/bosun-monitor/followers","following_url":"https://api.github.com/users/bosun-monitor/following{/other_user}","gists_url":"https://api.github.com/users/bosun-monitor/gists{/gist_id}","starred_url":"https://api.github.com/users/bosun-monitor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bosun-monitor/subscriptions","organizations_url":"https://api.github.com/users/bosun-monitor/orgs","repos_url":"https://api.github.com/users/bosun-monitor/repos","events_url":"https://api.github.com/users/bosun-monitor/events{/privacy}","received_events_url":"https://api.github.com/users/bosun-monitor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bosun-monitor/bosun","description":"Time Series Alerting Framework","fork":false,"url":"https://api.github.com/repos/bosun-monitor/bosun","forks_url":"https://api.github.com/repos/bosun-monitor/bosun/forks","keys_url":"https://api.github.com/repos/bosun-monitor/bosun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bosun-monitor/bosun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bosun-monitor/bosun/teams","hooks_url":"https://api.github.com/repos/bosun-monitor/bosun/hooks","issue_events_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/events{/number}","events_url":"https://api.github.com/repos/bosun-monitor/bosun/events","assignees_url":"https://api.github.com/repos/bosun-monitor/bosun/assignees{/user}","branches_url":"https://api.github.com/repos/bosun-monitor/bosun/branches{/branch}","tags_url":"https://api.github.com/repos/bosun-monitor/bosun/tags","blobs_url":"https://api.github.com/repos/bosun-monitor/bosun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bosun-monitor/bosun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bosun-monitor/bosun/git/refs{/sha}","trees_url":"https://api.github.com/repos/bosun-monitor/bosun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bosun-monitor/bosun/statuses/{sha}","languages_url":"https://api.github.com/repos/bosun-monitor/bosun/languages","stargazers_url":"https://api.github.com/repos/bosun-monitor/bosun/stargazers","contributors_url":"https://api.github.com/repos/bosun-monitor/bosun/contributors","subscribers_url":"https://api.github.com/repos/bosun-monitor/bosun/subscribers","subscription_url":"https://api.github.com/repos/bosun-monitor/bosun/subscription","commits_url":"https://api.github.com/repos/bosun-monitor/bosun/commits{/sha}","git_commits_url":"https://api.github.com/repos/bosun-monitor/bosun/git/commits{/sha}","comments_url":"https://api.github.com/repos/bosun-monitor/bosun/comments{/number}","issue_comment_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/comments/{number}","contents_url":"https://api.github.com/repos/bosun-monitor/bosun/contents/{+path}","compare_url":"https://api.github.com/repos/bosun-monitor/bosun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bosun-monitor/bosun/merges","archive_url":"https://api.github.com/repos/bosun-monitor/bosun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bosun-monitor/bosun/downloads","issues_url":"https://api.github.com/repos/bosun-monitor/bosun/issues{/number}","pulls_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls{/number}","milestones_url":"https://api.github.com/repos/bosun-monitor/bosun/milestones{/number}","notifications_url":"https://api.github.com/repos/bosun-monitor/bosun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bosun-monitor/bosun/labels{/name}","releases_url":"https://api.github.com/repos/bosun-monitor/bosun/releases{/id}","created_at":"2013-11-15T00:12:27Z","updated_at":"2015-01-15T21:44:59Z","pushed_at":"2015-01-15T21:45:14Z","git_url":"git://github.com/bosun-monitor/bosun.git","ssh_url":"git@github.com:bosun-monitor/bosun.git","clone_url":"https://github.com/bosun-monitor/bosun.git","svn_url":"https://github.com/bosun-monitor/bosun","homepage":"http://bosun.org","size":17438,"stargazers_count":667,"watchers_count":667,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":50,"mirror_url":null,"open_issues_count":145,"forks":50,"open_issues":145,"watchers":667,"default_branch":"master"}},"base":{"label":"bosun-monitor:master","ref":"master","sha":"27cba0a2ba3a58011045815b666571bbd9174459","user":{"login":"bosun-monitor","id":9555242,"avatar_url":"https://avatars.githubusercontent.com/u/9555242?v=3","gravatar_id":"","url":"https://api.github.com/users/bosun-monitor","html_url":"https://github.com/bosun-monitor","followers_url":"https://api.github.com/users/bosun-monitor/followers","following_url":"https://api.github.com/users/bosun-monitor/following{/other_user}","gists_url":"https://api.github.com/users/bosun-monitor/gists{/gist_id}","starred_url":"https://api.github.com/users/bosun-monitor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bosun-monitor/subscriptions","organizations_url":"https://api.github.com/users/bosun-monitor/orgs","repos_url":"https://api.github.com/users/bosun-monitor/repos","events_url":"https://api.github.com/users/bosun-monitor/events{/privacy}","received_events_url":"https://api.github.com/users/bosun-monitor/received_events","type":"Organization","site_admin":false},"repo":{"id":14410778,"name":"bosun","full_name":"bosun-monitor/bosun","owner":{"login":"bosun-monitor","id":9555242,"avatar_url":"https://avatars.githubusercontent.com/u/9555242?v=3","gravatar_id":"","url":"https://api.github.com/users/bosun-monitor","html_url":"https://github.com/bosun-monitor","followers_url":"https://api.github.com/users/bosun-monitor/followers","following_url":"https://api.github.com/users/bosun-monitor/following{/other_user}","gists_url":"https://api.github.com/users/bosun-monitor/gists{/gist_id}","starred_url":"https://api.github.com/users/bosun-monitor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bosun-monitor/subscriptions","organizations_url":"https://api.github.com/users/bosun-monitor/orgs","repos_url":"https://api.github.com/users/bosun-monitor/repos","events_url":"https://api.github.com/users/bosun-monitor/events{/privacy}","received_events_url":"https://api.github.com/users/bosun-monitor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bosun-monitor/bosun","description":"Time Series Alerting Framework","fork":false,"url":"https://api.github.com/repos/bosun-monitor/bosun","forks_url":"https://api.github.com/repos/bosun-monitor/bosun/forks","keys_url":"https://api.github.com/repos/bosun-monitor/bosun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bosun-monitor/bosun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bosun-monitor/bosun/teams","hooks_url":"https://api.github.com/repos/bosun-monitor/bosun/hooks","issue_events_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/events{/number}","events_url":"https://api.github.com/repos/bosun-monitor/bosun/events","assignees_url":"https://api.github.com/repos/bosun-monitor/bosun/assignees{/user}","branches_url":"https://api.github.com/repos/bosun-monitor/bosun/branches{/branch}","tags_url":"https://api.github.com/repos/bosun-monitor/bosun/tags","blobs_url":"https://api.github.com/repos/bosun-monitor/bosun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bosun-monitor/bosun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bosun-monitor/bosun/git/refs{/sha}","trees_url":"https://api.github.com/repos/bosun-monitor/bosun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bosun-monitor/bosun/statuses/{sha}","languages_url":"https://api.github.com/repos/bosun-monitor/bosun/languages","stargazers_url":"https://api.github.com/repos/bosun-monitor/bosun/stargazers","contributors_url":"https://api.github.com/repos/bosun-monitor/bosun/contributors","subscribers_url":"https://api.github.com/repos/bosun-monitor/bosun/subscribers","subscription_url":"https://api.github.com/repos/bosun-monitor/bosun/subscription","commits_url":"https://api.github.com/repos/bosun-monitor/bosun/commits{/sha}","git_commits_url":"https://api.github.com/repos/bosun-monitor/bosun/git/commits{/sha}","comments_url":"https://api.github.com/repos/bosun-monitor/bosun/comments{/number}","issue_comment_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/comments/{number}","contents_url":"https://api.github.com/repos/bosun-monitor/bosun/contents/{+path}","compare_url":"https://api.github.com/repos/bosun-monitor/bosun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bosun-monitor/bosun/merges","archive_url":"https://api.github.com/repos/bosun-monitor/bosun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bosun-monitor/bosun/downloads","issues_url":"https://api.github.com/repos/bosun-monitor/bosun/issues{/number}","pulls_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls{/number}","milestones_url":"https://api.github.com/repos/bosun-monitor/bosun/milestones{/number}","notifications_url":"https://api.github.com/repos/bosun-monitor/bosun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bosun-monitor/bosun/labels{/name}","releases_url":"https://api.github.com/repos/bosun-monitor/bosun/releases{/id}","created_at":"2013-11-15T00:12:27Z","updated_at":"2015-01-15T21:44:59Z","pushed_at":"2015-01-15T21:45:14Z","git_url":"git://github.com/bosun-monitor/bosun.git","ssh_url":"git@github.com:bosun-monitor/bosun.git","clone_url":"https://github.com/bosun-monitor/bosun.git","svn_url":"https://github.com/bosun-monitor/bosun","homepage":"http://bosun.org","size":17438,"stargazers_count":667,"watchers_count":667,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":50,"mirror_url":null,"open_issues_count":145,"forks":50,"open_issues":145,"watchers":667,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/659"},"html":{"href":"https://github.com/bosun-monitor/bosun/pull/659"},"issue":{"href":"https://api.github.com/repos/bosun-monitor/bosun/issues/659"},"comments":{"href":"https://api.github.com/repos/bosun-monitor/bosun/issues/659/comments"},"review_comments":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/659/comments"},"review_comment":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/659/commits"},"statuses":{"href":"https://api.github.com/repos/bosun-monitor/bosun/statuses/bf41bb1d0060f139f6a35391da21c4e8fda8e827"}}}}