{"action":"created","comment":{"url":"https://api.github.com/repos/bisdn/basebox/pulls/comments/151443794","pull_request_review_id":77151946,"id":151443794,"diff_hunk":"@@ -0,0 +1,65 @@\n+#include \"basebox_grpc_statistics.h\"\n+#include \"netlink/cnetlink.hpp\"\n+#include <glog/logging.h>\n+#include <vector>\n+\n+namespace basebox {\n+\n+using openconfig_interfaces::Interface_State;\n+using openconfig_interfaces::Interface_State_Counters;\n+using openconfig_interfaces::Interfaces;\n+using openconfig_interfaces::Interfaces_Interface;\n+\n+NetworkStats::NetworkStats(std::shared_ptr<switch_interface> swi) : swi(swi) {}\n+\n+::grpc::Status NetworkStats::GetStatistics(::grpc::ServerContext *context,\n+                                           const Empty *request,\n+                                           Interfaces *response) {\n+  VLOG(2) << __FUNCTION__ << \": received grpc call\";\n+\n+  std::vector<switch_interface::sai_port_stat_t> counter_ids = {\n+      switch_interface::SAI_PORT_STAT_RX_PACKETS,\n+      switch_interface::SAI_PORT_STAT_TX_PACKETS,\n+      switch_interface::SAI_PORT_STAT_RX_BYTES,\n+      switch_interface::SAI_PORT_STAT_TX_BYTES,\n+      switch_interface::SAI_PORT_STAT_RX_DROPPED,\n+      switch_interface::SAI_PORT_STAT_TX_DROPPED,\n+      switch_interface::SAI_PORT_STAT_RX_ERRORS,\n+      switch_interface::SAI_PORT_STAT_TX_ERRORS,\n+      switch_interface::SAI_PORT_STAT_RX_FRAME_ERR,\n+      switch_interface::SAI_PORT_STAT_RX_OVER_ERR,\n+      switch_interface::SAI_PORT_STAT_RX_CRC_ERR,\n+      switch_interface::SAI_PORT_STAT_COLLISIONS};\n+  std::vector<uint64_t> stats(counter_ids.size());\n+  std::map<std::string, uint32_t> ports =\n+      cnetlink::get_instance().get_registered_ports();\n+\n+  for (const auto &port : ports) {\n+    std::cout << port.second << std::endl;\n+    int rv = swi->get_statistics(port.second, counter_ids.size(),\n+                                 counter_ids.data(), stats.data());\n+    if (rv != 0)\n+      continue;\n+\n+    ::openconfig_interfaces::Interface_State *state =\n+        response->add_interface()->mutable_state();\n+    state->set_name(port.first);\n+    ::openconfig_interfaces::Interface_State_Counters *counters =\n+        state->mutable_counters();\n+\n+    counters->set_in_discards(stats[5]);","path":"src/basebox_grpc_statistics.cc","position":50,"original_position":50,"commit_id":"1251401cc2b7a4e15273698eed27d9885b7569fa","original_commit_id":"1251401cc2b7a4e15273698eed27d9885b7569fa","user":{"login":"DFritzsche","id":9460252,"avatar_url":"https://avatars0.githubusercontent.com/u/9460252?v=4","gravatar_id":"","url":"https://api.github.com/users/DFritzsche","html_url":"https://github.com/DFritzsche","followers_url":"https://api.github.com/users/DFritzsche/followers","following_url":"https://api.github.com/users/DFritzsche/following{/other_user}","gists_url":"https://api.github.com/users/DFritzsche/gists{/gist_id}","starred_url":"https://api.github.com/users/DFritzsche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DFritzsche/subscriptions","organizations_url":"https://api.github.com/users/DFritzsche/orgs","repos_url":"https://api.github.com/users/DFritzsche/repos","events_url":"https://api.github.com/users/DFritzsche/events{/privacy}","received_events_url":"https://api.github.com/users/DFritzsche/received_events","type":"User","site_admin":false},"body":"yeah, now we don't have to check anymore, but it would have helped finding the bug","created_at":"2017-11-16T15:21:55Z","updated_at":"2017-11-16T15:21:55Z","html_url":"https://github.com/bisdn/basebox/pull/68#discussion_r151443794","pull_request_url":"https://api.github.com/repos/bisdn/basebox/pulls/68","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/bisdn/basebox/pulls/comments/151443794"},"html":{"href":"https://github.com/bisdn/basebox/pull/68#discussion_r151443794"},"pull_request":{"href":"https://api.github.com/repos/bisdn/basebox/pulls/68"}},"in_reply_to_id":150790229},"pull_request":{"url":"https://api.github.com/repos/bisdn/basebox/pulls/68","id":151756798,"html_url":"https://github.com/bisdn/basebox/pull/68","diff_url":"https://github.com/bisdn/basebox/pull/68.diff","patch_url":"https://github.com/bisdn/basebox/pull/68.patch","issue_url":"https://api.github.com/repos/bisdn/basebox/issues/68","number":68,"state":"open","locked":false,"title":"grpc interface for statistics","user":{"login":"toanju","id":1773291,"avatar_url":"https://avatars1.githubusercontent.com/u/1773291?v=4","gravatar_id":"","url":"https://api.github.com/users/toanju","html_url":"https://github.com/toanju","followers_url":"https://api.github.com/users/toanju/followers","following_url":"https://api.github.com/users/toanju/following{/other_user}","gists_url":"https://api.github.com/users/toanju/gists{/gist_id}","starred_url":"https://api.github.com/users/toanju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toanju/subscriptions","organizations_url":"https://api.github.com/users/toanju/orgs","repos_url":"https://api.github.com/users/toanju/repos","events_url":"https://api.github.com/users/toanju/events{/privacy}","received_events_url":"https://api.github.com/users/toanju/received_events","type":"User","site_admin":false},"body":"These are the first steps to get datapath statistics out of baseboxd. We use a subset of OpenConfig directly with a gRPC service for now to receive device statistics. Since the OpenFlow data model diverges from the OpenConfig model not all fields can be filled though. The current provided values are:\r\nin_discards\r\nin_errors\r\nin_fcs_errors\r\nin_octets\r\nin_unicast_pkts\r\nout_discards\r\nout_errors\r\nout_octets\r\nout_unicast_pkts\r\n\r\nThanks go as well to @rubensfig who did a lot of work for this.","created_at":"2017-11-09T20:39:50Z","updated_at":"2017-11-16T15:21:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c30dc9c03da1f0ccc15fcd1cf37d53e884fc612","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/bisdn/basebox/pulls/68/commits","review_comments_url":"https://api.github.com/repos/bisdn/basebox/pulls/68/comments","review_comment_url":"https://api.github.com/repos/bisdn/basebox/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bisdn/basebox/issues/68/comments","statuses_url":"https://api.github.com/repos/bisdn/basebox/statuses/1251401cc2b7a4e15273698eed27d9885b7569fa","head":{"label":"toanju:grpc","ref":"grpc","sha":"1251401cc2b7a4e15273698eed27d9885b7569fa","user":{"login":"toanju","id":1773291,"avatar_url":"https://avatars1.githubusercontent.com/u/1773291?v=4","gravatar_id":"","url":"https://api.github.com/users/toanju","html_url":"https://github.com/toanju","followers_url":"https://api.github.com/users/toanju/followers","following_url":"https://api.github.com/users/toanju/following{/other_user}","gists_url":"https://api.github.com/users/toanju/gists{/gist_id}","starred_url":"https://api.github.com/users/toanju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toanju/subscriptions","organizations_url":"https://api.github.com/users/toanju/orgs","repos_url":"https://api.github.com/users/toanju/repos","events_url":"https://api.github.com/users/toanju/events{/privacy}","received_events_url":"https://api.github.com/users/toanju/received_events","type":"User","site_admin":false},"repo":{"id":37120530,"name":"basebox","full_name":"toanju/basebox","owner":{"login":"toanju","id":1773291,"avatar_url":"https://avatars1.githubusercontent.com/u/1773291?v=4","gravatar_id":"","url":"https://api.github.com/users/toanju","html_url":"https://github.com/toanju","followers_url":"https://api.github.com/users/toanju/followers","following_url":"https://api.github.com/users/toanju/following{/other_user}","gists_url":"https://api.github.com/users/toanju/gists{/gist_id}","starred_url":"https://api.github.com/users/toanju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toanju/subscriptions","organizations_url":"https://api.github.com/users/toanju/orgs","repos_url":"https://api.github.com/users/toanju/repos","events_url":"https://api.github.com/users/toanju/events{/privacy}","received_events_url":"https://api.github.com/users/toanju/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/toanju/basebox","description":"A tiny OpenFlow controller turning a datapath element into a basic routing switch.","fork":true,"url":"https://api.github.com/repos/toanju/basebox","forks_url":"https://api.github.com/repos/toanju/basebox/forks","keys_url":"https://api.github.com/repos/toanju/basebox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/toanju/basebox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/toanju/basebox/teams","hooks_url":"https://api.github.com/repos/toanju/basebox/hooks","issue_events_url":"https://api.github.com/repos/toanju/basebox/issues/events{/number}","events_url":"https://api.github.com/repos/toanju/basebox/events","assignees_url":"https://api.github.com/repos/toanju/basebox/assignees{/user}","branches_url":"https://api.github.com/repos/toanju/basebox/branches{/branch}","tags_url":"https://api.github.com/repos/toanju/basebox/tags","blobs_url":"https://api.github.com/repos/toanju/basebox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/toanju/basebox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/toanju/basebox/git/refs{/sha}","trees_url":"https://api.github.com/repos/toanju/basebox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/toanju/basebox/statuses/{sha}","languages_url":"https://api.github.com/repos/toanju/basebox/languages","stargazers_url":"https://api.github.com/repos/toanju/basebox/stargazers","contributors_url":"https://api.github.com/repos/toanju/basebox/contributors","subscribers_url":"https://api.github.com/repos/toanju/basebox/subscribers","subscription_url":"https://api.github.com/repos/toanju/basebox/subscription","commits_url":"https://api.github.com/repos/toanju/basebox/commits{/sha}","git_commits_url":"https://api.github.com/repos/toanju/basebox/git/commits{/sha}","comments_url":"https://api.github.com/repos/toanju/basebox/comments{/number}","issue_comment_url":"https://api.github.com/repos/toanju/basebox/issues/comments{/number}","contents_url":"https://api.github.com/repos/toanju/basebox/contents/{+path}","compare_url":"https://api.github.com/repos/toanju/basebox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/toanju/basebox/merges","archive_url":"https://api.github.com/repos/toanju/basebox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/toanju/basebox/downloads","issues_url":"https://api.github.com/repos/toanju/basebox/issues{/number}","pulls_url":"https://api.github.com/repos/toanju/basebox/pulls{/number}","milestones_url":"https://api.github.com/repos/toanju/basebox/milestones{/number}","notifications_url":"https://api.github.com/repos/toanju/basebox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/toanju/basebox/labels{/name}","releases_url":"https://api.github.com/repos/toanju/basebox/releases{/id}","deployments_url":"https://api.github.com/repos/toanju/basebox/deployments","created_at":"2015-06-09T08:39:37Z","updated_at":"2016-07-09T08:07:41Z","pushed_at":"2017-11-12T19:36:45Z","git_url":"git://github.com/toanju/basebox.git","ssh_url":"git@github.com:toanju/basebox.git","clone_url":"https://github.com/toanju/basebox.git","svn_url":"https://github.com/toanju/basebox","homepage":null,"size":1911,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bisdn:master","ref":"master","sha":"7986d1c6cdf2634ddc1f0ff41ba25eff3f9d99df","user":{"login":"bisdn","id":7427030,"avatar_url":"https://avatars3.githubusercontent.com/u/7427030?v=4","gravatar_id":"","url":"https://api.github.com/users/bisdn","html_url":"https://github.com/bisdn","followers_url":"https://api.github.com/users/bisdn/followers","following_url":"https://api.github.com/users/bisdn/following{/other_user}","gists_url":"https://api.github.com/users/bisdn/gists{/gist_id}","starred_url":"https://api.github.com/users/bisdn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bisdn/subscriptions","organizations_url":"https://api.github.com/users/bisdn/orgs","repos_url":"https://api.github.com/users/bisdn/repos","events_url":"https://api.github.com/users/bisdn/events{/privacy}","received_events_url":"https://api.github.com/users/bisdn/received_events","type":"Organization","site_admin":false},"repo":{"id":26112074,"name":"basebox","full_name":"bisdn/basebox","owner":{"login":"bisdn","id":7427030,"avatar_url":"https://avatars3.githubusercontent.com/u/7427030?v=4","gravatar_id":"","url":"https://api.github.com/users/bisdn","html_url":"https://github.com/bisdn","followers_url":"https://api.github.com/users/bisdn/followers","following_url":"https://api.github.com/users/bisdn/following{/other_user}","gists_url":"https://api.github.com/users/bisdn/gists{/gist_id}","starred_url":"https://api.github.com/users/bisdn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bisdn/subscriptions","organizations_url":"https://api.github.com/users/bisdn/orgs","repos_url":"https://api.github.com/users/bisdn/repos","events_url":"https://api.github.com/users/bisdn/events{/privacy}","received_events_url":"https://api.github.com/users/bisdn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bisdn/basebox","description":"A tiny OpenFlow controller for OF-DPA switches.","fork":false,"url":"https://api.github.com/repos/bisdn/basebox","forks_url":"https://api.github.com/repos/bisdn/basebox/forks","keys_url":"https://api.github.com/repos/bisdn/basebox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bisdn/basebox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bisdn/basebox/teams","hooks_url":"https://api.github.com/repos/bisdn/basebox/hooks","issue_events_url":"https://api.github.com/repos/bisdn/basebox/issues/events{/number}","events_url":"https://api.github.com/repos/bisdn/basebox/events","assignees_url":"https://api.github.com/repos/bisdn/basebox/assignees{/user}","branches_url":"https://api.github.com/repos/bisdn/basebox/branches{/branch}","tags_url":"https://api.github.com/repos/bisdn/basebox/tags","blobs_url":"https://api.github.com/repos/bisdn/basebox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bisdn/basebox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bisdn/basebox/git/refs{/sha}","trees_url":"https://api.github.com/repos/bisdn/basebox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bisdn/basebox/statuses/{sha}","languages_url":"https://api.github.com/repos/bisdn/basebox/languages","stargazers_url":"https://api.github.com/repos/bisdn/basebox/stargazers","contributors_url":"https://api.github.com/repos/bisdn/basebox/contributors","subscribers_url":"https://api.github.com/repos/bisdn/basebox/subscribers","subscription_url":"https://api.github.com/repos/bisdn/basebox/subscription","commits_url":"https://api.github.com/repos/bisdn/basebox/commits{/sha}","git_commits_url":"https://api.github.com/repos/bisdn/basebox/git/commits{/sha}","comments_url":"https://api.github.com/repos/bisdn/basebox/comments{/number}","issue_comment_url":"https://api.github.com/repos/bisdn/basebox/issues/comments{/number}","contents_url":"https://api.github.com/repos/bisdn/basebox/contents/{+path}","compare_url":"https://api.github.com/repos/bisdn/basebox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bisdn/basebox/merges","archive_url":"https://api.github.com/repos/bisdn/basebox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bisdn/basebox/downloads","issues_url":"https://api.github.com/repos/bisdn/basebox/issues{/number}","pulls_url":"https://api.github.com/repos/bisdn/basebox/pulls{/number}","milestones_url":"https://api.github.com/repos/bisdn/basebox/milestones{/number}","notifications_url":"https://api.github.com/repos/bisdn/basebox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bisdn/basebox/labels{/name}","releases_url":"https://api.github.com/repos/bisdn/basebox/releases{/id}","deployments_url":"https://api.github.com/repos/bisdn/basebox/deployments","created_at":"2014-11-03T09:33:45Z","updated_at":"2017-11-16T15:15:08Z","pushed_at":"2017-11-13T06:56:42Z","git_url":"git://github.com/bisdn/basebox.git","ssh_url":"git@github.com:bisdn/basebox.git","clone_url":"https://github.com/bisdn/basebox.git","svn_url":"https://github.com/bisdn/basebox","homepage":"","size":1832,"stargazers_count":8,"watchers_count":8,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":1,"forks":5,"open_issues":1,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bisdn/basebox/pulls/68"},"html":{"href":"https://github.com/bisdn/basebox/pull/68"},"issue":{"href":"https://api.github.com/repos/bisdn/basebox/issues/68"},"comments":{"href":"https://api.github.com/repos/bisdn/basebox/issues/68/comments"},"review_comments":{"href":"https://api.github.com/repos/bisdn/basebox/pulls/68/comments"},"review_comment":{"href":"https://api.github.com/repos/bisdn/basebox/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bisdn/basebox/pulls/68/commits"},"statuses":{"href":"https://api.github.com/repos/bisdn/basebox/statuses/1251401cc2b7a4e15273698eed27d9885b7569fa"}},"author_association":"OWNER"}}
{"actor":{"display_login":"DFritzsche"}}