{"action":"created","comment":{"url":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/comments/32846442","id":32846442,"diff_hunk":"@@ -0,0 +1,87 @@\n+/**\n+ * @file snmp_accumulator_table.cpp\n+ *\n+ * Project Clearwater - IMS in the Cloud\n+ * Copyright (C) 2015 Metaswitch Networks Ltd\n+ *\n+ * This program is free software: you can redistribute it and/or modify it\n+ * under the terms of the GNU General Public License as published by the\n+ * Free Software Foundation, either version 3 of the License, or (at your\n+ * option) any later version, along with the \"Special Exception\" for use of\n+ * the program along with SSL, set forth below. This program is distributed\n+ * in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR\n+ * A PARTICULAR PURPOSE.  See the GNU General Public License for more\n+ * details. You should have received a copy of the GNU General Public\n+ * License along with this program.  If not, see\n+ * <http://www.gnu.org/licenses/>.\n+ *\n+ * The author can be reached by email at clearwater@metaswitch.com or by\n+ * post at Metaswitch Networks Ltd, 100 Church St, Enfield EN2 6BQ, UK\n+ *\n+ * Special Exception\n+ * Metaswitch Networks Ltd  grants you permission to copy, modify,\n+ * propagate, and distribute a work formed by combining OpenSSL with The\n+ * Software, or a work derivative of such a combination, even if such\n+ * copying, modification, propagation, or distribution would otherwise\n+ * violate the terms of the GPL. You must comply with the GPL in all\n+ * respects for all of the code used other than OpenSSL.\n+ * \"OpenSSL\" means OpenSSL toolkit software distributed by the OpenSSL\n+ * Project and licensed under the OpenSSL Licenses, or a work based on such\n+ * software and licensed under the OpenSSL Licenses.\n+ * \"OpenSSL Licenses\" means the OpenSSL License and Original SSLeay License\n+ * under which the OpenSSL Project distributes the OpenSSL toolkit software,\n+ * as those licenses appear in the file LICENSE-OPENSSL.\n+ */\n+\n+#include \"snmp_accumulator_table.h\"\n+\n+namespace SNMP\n+{\n+\n+ColumnData AccumulatorRow::get_columns()\n+{\n+  Statistics accumulated = *(_view->get_data());\n+  uint32_t sum = accumulated.sum;\n+  uint32_t sumsq = accumulated.sqsum;\n+  uint32_t count = accumulated.count;\n+\n+  // Calculate the average and the variance from the stored sum and sum-of-squares.\n+  uint32_t avg = sum/std::max(count, 1u);","path":"src/snmp_accumulator_table.cpp","position":50,"original_position":50,"commit_id":"76d1ebf939335a9208c78892054939bdc3ae4137","original_commit_id":"76d1ebf939335a9208c78892054939bdc3ae4137","user":{"login":"mirw","id":2963879,"avatar_url":"https://avatars.githubusercontent.com/u/2963879?v=3","gravatar_id":"","url":"https://api.github.com/users/mirw","html_url":"https://github.com/mirw","followers_url":"https://api.github.com/users/mirw/followers","following_url":"https://api.github.com/users/mirw/following{/other_user}","gists_url":"https://api.github.com/users/mirw/gists{/gist_id}","starred_url":"https://api.github.com/users/mirw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirw/subscriptions","organizations_url":"https://api.github.com/users/mirw/orgs","repos_url":"https://api.github.com/users/mirw/repos","events_url":"https://api.github.com/users/mirw/events{/privacy}","received_events_url":"https://api.github.com/users/mirw/received_events","type":"User","site_admin":false},"body":"Why std::max?  (I know, but it's worth a comment.)","created_at":"2015-06-19T16:43:51Z","updated_at":"2015-06-19T16:43:51Z","html_url":"https://github.com/Metaswitch/cpp-common/pull/311#discussion_r32846442","pull_request_url":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/311","_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/comments/32846442"},"html":{"href":"https://github.com/Metaswitch/cpp-common/pull/311#discussion_r32846442"},"pull_request":{"href":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/311"}}},"pull_request":{"url":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/311","id":38098548,"html_url":"https://github.com/Metaswitch/cpp-common/pull/311","diff_url":"https://github.com/Metaswitch/cpp-common/pull/311.diff","patch_url":"https://github.com/Metaswitch/cpp-common/pull/311.patch","issue_url":"https://api.github.com/repos/Metaswitch/cpp-common/issues/311","number":311,"state":"open","locked":false,"title":"[Reviewer: Matt] SNMP tooling","user":{"login":"rkd-msw","id":4363492,"avatar_url":"https://avatars.githubusercontent.com/u/4363492?v=3","gravatar_id":"","url":"https://api.github.com/users/rkd-msw","html_url":"https://github.com/rkd-msw","followers_url":"https://api.github.com/users/rkd-msw/followers","following_url":"https://api.github.com/users/rkd-msw/following{/other_user}","gists_url":"https://api.github.com/users/rkd-msw/gists{/gist_id}","starred_url":"https://api.github.com/users/rkd-msw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkd-msw/subscriptions","organizations_url":"https://api.github.com/users/rkd-msw/orgs","repos_url":"https://api.github.com/users/rkd-msw/repos","events_url":"https://api.github.com/users/rkd-msw/events{/privacy}","received_events_url":"https://api.github.com/users/rkd-msw/received_events","type":"User","site_admin":false},"body":"Matt,\r\n\r\nCan you review my code to add SNMP helpers so that Sprout can become an AgentX subagent?\r\n\r\nThere's\r\n- snmp_agent.{h, cpp} which sets up the AgentX thread\r\n- snmp_scalar.h, snmp_table.h and snmp_table.cpp which set up the general infrastructure\r\n- snmp_time_period_table.h, snmp_counter_table.{h, cpp}, snmp_accumulator_table.{h, cpp} and snmp_ip_count_table.h which define specific table structures\r\n- a change to HTTPConnection so that it can be created with a SNMP::IPCountTable* instead of the current 0MQ classes","created_at":"2015-06-19T11:23:05Z","updated_at":"2015-06-19T16:43:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"43b71e03b790388fcb683f1e4e32523622324fa1","assignee":{"login":"mirw","id":2963879,"avatar_url":"https://avatars.githubusercontent.com/u/2963879?v=3","gravatar_id":"","url":"https://api.github.com/users/mirw","html_url":"https://github.com/mirw","followers_url":"https://api.github.com/users/mirw/followers","following_url":"https://api.github.com/users/mirw/following{/other_user}","gists_url":"https://api.github.com/users/mirw/gists{/gist_id}","starred_url":"https://api.github.com/users/mirw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirw/subscriptions","organizations_url":"https://api.github.com/users/mirw/orgs","repos_url":"https://api.github.com/users/mirw/repos","events_url":"https://api.github.com/users/mirw/events{/privacy}","received_events_url":"https://api.github.com/users/mirw/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/311/commits","review_comments_url":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/311/comments","review_comment_url":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Metaswitch/cpp-common/issues/311/comments","statuses_url":"https://api.github.com/repos/Metaswitch/cpp-common/statuses/76d1ebf939335a9208c78892054939bdc3ae4137","head":{"label":"Metaswitch:snmp","ref":"snmp","sha":"76d1ebf939335a9208c78892054939bdc3ae4137","user":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"repo":{"id":15284898,"name":"cpp-common","full_name":"Metaswitch/cpp-common","owner":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metaswitch/cpp-common","description":"Common C/C++ modules for Clearwater components","fork":false,"url":"https://api.github.com/repos/Metaswitch/cpp-common","forks_url":"https://api.github.com/repos/Metaswitch/cpp-common/forks","keys_url":"https://api.github.com/repos/Metaswitch/cpp-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metaswitch/cpp-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metaswitch/cpp-common/teams","hooks_url":"https://api.github.com/repos/Metaswitch/cpp-common/hooks","issue_events_url":"https://api.github.com/repos/Metaswitch/cpp-common/issues/events{/number}","events_url":"https://api.github.com/repos/Metaswitch/cpp-common/events","assignees_url":"https://api.github.com/repos/Metaswitch/cpp-common/assignees{/user}","branches_url":"https://api.github.com/repos/Metaswitch/cpp-common/branches{/branch}","tags_url":"https://api.github.com/repos/Metaswitch/cpp-common/tags","blobs_url":"https://api.github.com/repos/Metaswitch/cpp-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metaswitch/cpp-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metaswitch/cpp-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metaswitch/cpp-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metaswitch/cpp-common/statuses/{sha}","languages_url":"https://api.github.com/repos/Metaswitch/cpp-common/languages","stargazers_url":"https://api.github.com/repos/Metaswitch/cpp-common/stargazers","contributors_url":"https://api.github.com/repos/Metaswitch/cpp-common/contributors","subscribers_url":"https://api.github.com/repos/Metaswitch/cpp-common/subscribers","subscription_url":"https://api.github.com/repos/Metaswitch/cpp-common/subscription","commits_url":"https://api.github.com/repos/Metaswitch/cpp-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metaswitch/cpp-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metaswitch/cpp-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metaswitch/cpp-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metaswitch/cpp-common/contents/{+path}","compare_url":"https://api.github.com/repos/Metaswitch/cpp-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metaswitch/cpp-common/merges","archive_url":"https://api.github.com/repos/Metaswitch/cpp-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metaswitch/cpp-common/downloads","issues_url":"https://api.github.com/repos/Metaswitch/cpp-common/issues{/number}","pulls_url":"https://api.github.com/repos/Metaswitch/cpp-common/pulls{/number}","milestones_url":"https://api.github.com/repos/Metaswitch/cpp-common/milestones{/number}","notifications_url":"https://api.github.com/repos/Metaswitch/cpp-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metaswitch/cpp-common/labels{/name}","releases_url":"https://api.github.com/repos/Metaswitch/cpp-common/releases{/id}","created_at":"2013-12-18T14:11:57Z","updated_at":"2015-05-07T12:01:06Z","pushed_at":"2015-06-19T16:24:04Z","git_url":"git://github.com/Metaswitch/cpp-common.git","ssh_url":"git@github.com:Metaswitch/cpp-common.git","clone_url":"https://github.com/Metaswitch/cpp-common.git","svn_url":"https://github.com/Metaswitch/cpp-common","homepage":null,"size":3803,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":16,"forks":3,"open_issues":16,"watchers":0,"default_branch":"master"}},"base":{"label":"Metaswitch:log_trc_rename","ref":"log_trc_rename","sha":"9e7b940b2b0a9f85f1736913a7a86597301d582a","user":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"repo":{"id":15284898,"name":"cpp-common","full_name":"Metaswitch/cpp-common","owner":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metaswitch/cpp-common","description":"Common C/C++ modules for Clearwater components","fork":false,"url":"https://api.github.com/repos/Metaswitch/cpp-common","forks_url":"https://api.github.com/repos/Metaswitch/cpp-common/forks","keys_url":"https://api.github.com/repos/Metaswitch/cpp-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metaswitch/cpp-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metaswitch/cpp-common/teams","hooks_url":"https://api.github.com/repos/Metaswitch/cpp-common/hooks","issue_events_url":"https://api.github.com/repos/Metaswitch/cpp-common/issues/events{/number}","events_url":"https://api.github.com/repos/Metaswitch/cpp-common/events","assignees_url":"https://api.github.com/repos/Metaswitch/cpp-common/assignees{/user}","branches_url":"https://api.github.com/repos/Metaswitch/cpp-common/branches{/branch}","tags_url":"https://api.github.com/repos/Metaswitch/cpp-common/tags","blobs_url":"https://api.github.com/repos/Metaswitch/cpp-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metaswitch/cpp-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metaswitch/cpp-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metaswitch/cpp-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metaswitch/cpp-common/statuses/{sha}","languages_url":"https://api.github.com/repos/Metaswitch/cpp-common/languages","stargazers_url":"https://api.github.com/repos/Metaswitch/cpp-common/stargazers","contributors_url":"https://api.github.com/repos/Metaswitch/cpp-common/contributors","subscribers_url":"https://api.github.com/repos/Metaswitch/cpp-common/subscribers","subscription_url":"https://api.github.com/repos/Metaswitch/cpp-common/subscription","commits_url":"https://api.github.com/repos/Metaswitch/cpp-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metaswitch/cpp-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metaswitch/cpp-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metaswitch/cpp-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metaswitch/cpp-common/contents/{+path}","compare_url":"https://api.github.com/repos/Metaswitch/cpp-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metaswitch/cpp-common/merges","archive_url":"https://api.github.com/repos/Metaswitch/cpp-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metaswitch/cpp-common/downloads","issues_url":"https://api.github.com/repos/Metaswitch/cpp-common/issues{/number}","pulls_url":"https://api.github.com/repos/Metaswitch/cpp-common/pulls{/number}","milestones_url":"https://api.github.com/repos/Metaswitch/cpp-common/milestones{/number}","notifications_url":"https://api.github.com/repos/Metaswitch/cpp-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metaswitch/cpp-common/labels{/name}","releases_url":"https://api.github.com/repos/Metaswitch/cpp-common/releases{/id}","created_at":"2013-12-18T14:11:57Z","updated_at":"2015-05-07T12:01:06Z","pushed_at":"2015-06-19T16:24:04Z","git_url":"git://github.com/Metaswitch/cpp-common.git","ssh_url":"git@github.com:Metaswitch/cpp-common.git","clone_url":"https://github.com/Metaswitch/cpp-common.git","svn_url":"https://github.com/Metaswitch/cpp-common","homepage":null,"size":3803,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":16,"forks":3,"open_issues":16,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/311"},"html":{"href":"https://github.com/Metaswitch/cpp-common/pull/311"},"issue":{"href":"https://api.github.com/repos/Metaswitch/cpp-common/issues/311"},"comments":{"href":"https://api.github.com/repos/Metaswitch/cpp-common/issues/311/comments"},"review_comments":{"href":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/311/comments"},"review_comment":{"href":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Metaswitch/cpp-common/pulls/311/commits"},"statuses":{"href":"https://api.github.com/repos/Metaswitch/cpp-common/statuses/76d1ebf939335a9208c78892054939bdc3ae4137"}}}}