{"action":"created","comment":{"url":"https://api.github.com/repos/teknico/snabb/pulls/comments/60925975","id":60925975,"diff_hunk":"@@ -14,19 +15,63 @@ function parse_args(args)\n    local handlers = {}\n    function handlers.h() show_usage(0) end\n    args = lib.dogetopt(args, handlers, \"h\", { help=\"h\" })\n-   if #args ~= 5 then show_usage(1) end\n+   if #args ~= 5 and #args ~= 6 then show_usage(1) end\n    return unpack(args)\n end\n \n+function load_requested_counters(counters)\n+   local results = dofile(counters)\n+   return results\n+end\n+\n+function read_counters(c, req_counters)\n+   local results = {}\n+   local cntrs = app.app_table.lwaftr.counters\n+   for name, incr in pairs(req_counters) do\n+      results[name] = counter.read(cntrs[name])\n+   end\n+   return results\n+end\n+\n+function diff_counters(final, initial)\n+   local results = {}\n+   for name, ref in pairs(initial) do\n+      cur = final[name]\n+      if cur ~= ref then\n+         results[name] = tonumber(cur - ref)\n+      end\n+   end\n+   return results\n+end\n+\n+function validate_diff(actual, expected)\n+   if not lib.equal(actual, expected) then\n+      print(\"--- Expected\")\n+      for k, v in pairs(expected) do print(k, \"=\", v) end\n+      print(\"--- actual\")\n+      for k, v in pairs(actual) do print(k, \"=\", v) end\n+      error(\"counters did not match\")\n+   end\n+end\n+\n function run(args)\n-   local conf_file, inv4_pcap, inv6_pcap, outv4_pcap, outv6_pcap =\n+   local conf_file, inv4_pcap, inv6_pcap, outv4_pcap, outv6_pcap, counters_path =\n       parse_args(args)\n \n    local conf = require('apps.lwaftr.conf').load_lwaftr_config(conf_file)\n \n    local c = config.new()\n    setup.load_check(c, conf, inv4_pcap, inv6_pcap, outv4_pcap, outv6_pcap)\n    app.configure(c)\n+   if counters_path then\n+      req_counters = load_requested_counters(counters_path)","path":"src/program/lwaftr/check/check.lua","position":63,"original_position":63,"commit_id":"15af3a5e105af98376f1e42dbd9ff2ac8680d784","original_commit_id":"15af3a5e105af98376f1e42dbd9ff2ac8680d784","user":{"login":"wingo","id":1745903,"avatar_url":"https://avatars.githubusercontent.com/u/1745903?v=3","gravatar_id":"","url":"https://api.github.com/users/wingo","html_url":"https://github.com/wingo","followers_url":"https://api.github.com/users/wingo/followers","following_url":"https://api.github.com/users/wingo/following{/other_user}","gists_url":"https://api.github.com/users/wingo/gists{/gist_id}","starred_url":"https://api.github.com/users/wingo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wingo/subscriptions","organizations_url":"https://api.github.com/users/wingo/orgs","repos_url":"https://api.github.com/users/wingo/repos","events_url":"https://api.github.com/users/wingo/events{/privacy}","received_events_url":"https://api.github.com/users/wingo/received_events","type":"User","site_admin":false},"body":"this will create a new global variable. weird, right?  you want \"local req_counters = ...\".  Same with initial_counters.","created_at":"2016-04-25T14:51:09Z","updated_at":"2016-04-25T14:51:09Z","html_url":"https://github.com/teknico/snabb/pull/1#discussion_r60925975","pull_request_url":"https://api.github.com/repos/teknico/snabb/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/teknico/snabb/pulls/comments/60925975"},"html":{"href":"https://github.com/teknico/snabb/pull/1#discussion_r60925975"},"pull_request":{"href":"https://api.github.com/repos/teknico/snabb/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/teknico/snabb/pulls/1","id":67729002,"html_url":"https://github.com/teknico/snabb/pull/1","diff_url":"https://github.com/teknico/snabb/pull/1.diff","patch_url":"https://github.com/teknico/snabb/pull/1.patch","issue_url":"https://api.github.com/repos/teknico/snabb/issues/1","number":1,"state":"open","locked":false,"title":"Setup checking counters","user":{"login":"teknico","id":172521,"avatar_url":"https://avatars.githubusercontent.com/u/172521?v=3","gravatar_id":"","url":"https://api.github.com/users/teknico","html_url":"https://github.com/teknico","followers_url":"https://api.github.com/users/teknico/followers","following_url":"https://api.github.com/users/teknico/following{/other_user}","gists_url":"https://api.github.com/users/teknico/gists{/gist_id}","starred_url":"https://api.github.com/users/teknico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teknico/subscriptions","organizations_url":"https://api.github.com/users/teknico/orgs","repos_url":"https://api.github.com/users/teknico/repos","events_url":"https://api.github.com/users/teknico/events{/privacy}","received_events_url":"https://api.github.com/users/teknico/received_events","type":"User","site_admin":false},"body":"Setup the structure for checking counters with the 'lwafter check' command, handling one first counter: `lwaftr.v4/rxbytes`.\r\n\r\nTested running this command from the `src/` directory:\r\n```\r\n# ./snabb lwaftr check program/lwaftr/tests/data/icmp_on_fail.conf program/lwaftr/tests/data/tcp-frominet-bound.pcap program/lwaftr/tests/data/empty.pcap /tmp/endoutv4.pcap /tmp/endoutv6.pcap /tmp/counters.lua\r\n```\r\nwhere the `/tmp/counters.lua` file contains:\r\n```\r\nreturn {\r\n    v4rxbytes = 1,\r\n}\r\n```","created_at":"2016-04-25T14:28:05Z","updated_at":"2016-04-25T14:51:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0ca3577cdbd4445272fd66f91a10449e081b04d2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/teknico/snabb/pulls/1/commits","review_comments_url":"https://api.github.com/repos/teknico/snabb/pulls/1/comments","review_comment_url":"https://api.github.com/repos/teknico/snabb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/teknico/snabb/issues/1/comments","statuses_url":"https://api.github.com/repos/teknico/snabb/statuses/15af3a5e105af98376f1e42dbd9ff2ac8680d784","head":{"label":"teknico:setup-counters-check","ref":"setup-counters-check","sha":"15af3a5e105af98376f1e42dbd9ff2ac8680d784","user":{"login":"teknico","id":172521,"avatar_url":"https://avatars.githubusercontent.com/u/172521?v=3","gravatar_id":"","url":"https://api.github.com/users/teknico","html_url":"https://github.com/teknico","followers_url":"https://api.github.com/users/teknico/followers","following_url":"https://api.github.com/users/teknico/following{/other_user}","gists_url":"https://api.github.com/users/teknico/gists{/gist_id}","starred_url":"https://api.github.com/users/teknico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teknico/subscriptions","organizations_url":"https://api.github.com/users/teknico/orgs","repos_url":"https://api.github.com/users/teknico/repos","events_url":"https://api.github.com/users/teknico/events{/privacy}","received_events_url":"https://api.github.com/users/teknico/received_events","type":"User","site_admin":false},"repo":{"id":57029075,"name":"snabb","full_name":"teknico/snabb","owner":{"login":"teknico","id":172521,"avatar_url":"https://avatars.githubusercontent.com/u/172521?v=3","gravatar_id":"","url":"https://api.github.com/users/teknico","html_url":"https://github.com/teknico","followers_url":"https://api.github.com/users/teknico/followers","following_url":"https://api.github.com/users/teknico/following{/other_user}","gists_url":"https://api.github.com/users/teknico/gists{/gist_id}","starred_url":"https://api.github.com/users/teknico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teknico/subscriptions","organizations_url":"https://api.github.com/users/teknico/orgs","repos_url":"https://api.github.com/users/teknico/repos","events_url":"https://api.github.com/users/teknico/events{/privacy}","received_events_url":"https://api.github.com/users/teknico/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/teknico/snabb","description":"Snabb Switch: Fast open source packet processing","fork":true,"url":"https://api.github.com/repos/teknico/snabb","forks_url":"https://api.github.com/repos/teknico/snabb/forks","keys_url":"https://api.github.com/repos/teknico/snabb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teknico/snabb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teknico/snabb/teams","hooks_url":"https://api.github.com/repos/teknico/snabb/hooks","issue_events_url":"https://api.github.com/repos/teknico/snabb/issues/events{/number}","events_url":"https://api.github.com/repos/teknico/snabb/events","assignees_url":"https://api.github.com/repos/teknico/snabb/assignees{/user}","branches_url":"https://api.github.com/repos/teknico/snabb/branches{/branch}","tags_url":"https://api.github.com/repos/teknico/snabb/tags","blobs_url":"https://api.github.com/repos/teknico/snabb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teknico/snabb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teknico/snabb/git/refs{/sha}","trees_url":"https://api.github.com/repos/teknico/snabb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teknico/snabb/statuses/{sha}","languages_url":"https://api.github.com/repos/teknico/snabb/languages","stargazers_url":"https://api.github.com/repos/teknico/snabb/stargazers","contributors_url":"https://api.github.com/repos/teknico/snabb/contributors","subscribers_url":"https://api.github.com/repos/teknico/snabb/subscribers","subscription_url":"https://api.github.com/repos/teknico/snabb/subscription","commits_url":"https://api.github.com/repos/teknico/snabb/commits{/sha}","git_commits_url":"https://api.github.com/repos/teknico/snabb/git/commits{/sha}","comments_url":"https://api.github.com/repos/teknico/snabb/comments{/number}","issue_comment_url":"https://api.github.com/repos/teknico/snabb/issues/comments{/number}","contents_url":"https://api.github.com/repos/teknico/snabb/contents/{+path}","compare_url":"https://api.github.com/repos/teknico/snabb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teknico/snabb/merges","archive_url":"https://api.github.com/repos/teknico/snabb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teknico/snabb/downloads","issues_url":"https://api.github.com/repos/teknico/snabb/issues{/number}","pulls_url":"https://api.github.com/repos/teknico/snabb/pulls{/number}","milestones_url":"https://api.github.com/repos/teknico/snabb/milestones{/number}","notifications_url":"https://api.github.com/repos/teknico/snabb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teknico/snabb/labels{/name}","releases_url":"https://api.github.com/repos/teknico/snabb/releases{/id}","deployments_url":"https://api.github.com/repos/teknico/snabb/deployments","created_at":"2016-04-25T09:25:57Z","updated_at":"2016-04-25T09:26:01Z","pushed_at":"2016-04-25T14:28:06Z","git_url":"git://github.com/teknico/snabb.git","ssh_url":"git@github.com:teknico/snabb.git","clone_url":"https://github.com/teknico/snabb.git","svn_url":"https://github.com/teknico/snabb","homepage":"","size":8565,"stargazers_count":0,"watchers_count":0,"language":"Lua","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"lwaftr"}},"base":{"label":"teknico:lwaftr","ref":"lwaftr","sha":"1ccbab259d21cbc89349538eecd09c03c6844c4b","user":{"login":"teknico","id":172521,"avatar_url":"https://avatars.githubusercontent.com/u/172521?v=3","gravatar_id":"","url":"https://api.github.com/users/teknico","html_url":"https://github.com/teknico","followers_url":"https://api.github.com/users/teknico/followers","following_url":"https://api.github.com/users/teknico/following{/other_user}","gists_url":"https://api.github.com/users/teknico/gists{/gist_id}","starred_url":"https://api.github.com/users/teknico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teknico/subscriptions","organizations_url":"https://api.github.com/users/teknico/orgs","repos_url":"https://api.github.com/users/teknico/repos","events_url":"https://api.github.com/users/teknico/events{/privacy}","received_events_url":"https://api.github.com/users/teknico/received_events","type":"User","site_admin":false},"repo":{"id":57029075,"name":"snabb","full_name":"teknico/snabb","owner":{"login":"teknico","id":172521,"avatar_url":"https://avatars.githubusercontent.com/u/172521?v=3","gravatar_id":"","url":"https://api.github.com/users/teknico","html_url":"https://github.com/teknico","followers_url":"https://api.github.com/users/teknico/followers","following_url":"https://api.github.com/users/teknico/following{/other_user}","gists_url":"https://api.github.com/users/teknico/gists{/gist_id}","starred_url":"https://api.github.com/users/teknico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teknico/subscriptions","organizations_url":"https://api.github.com/users/teknico/orgs","repos_url":"https://api.github.com/users/teknico/repos","events_url":"https://api.github.com/users/teknico/events{/privacy}","received_events_url":"https://api.github.com/users/teknico/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/teknico/snabb","description":"Snabb Switch: Fast open source packet processing","fork":true,"url":"https://api.github.com/repos/teknico/snabb","forks_url":"https://api.github.com/repos/teknico/snabb/forks","keys_url":"https://api.github.com/repos/teknico/snabb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teknico/snabb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teknico/snabb/teams","hooks_url":"https://api.github.com/repos/teknico/snabb/hooks","issue_events_url":"https://api.github.com/repos/teknico/snabb/issues/events{/number}","events_url":"https://api.github.com/repos/teknico/snabb/events","assignees_url":"https://api.github.com/repos/teknico/snabb/assignees{/user}","branches_url":"https://api.github.com/repos/teknico/snabb/branches{/branch}","tags_url":"https://api.github.com/repos/teknico/snabb/tags","blobs_url":"https://api.github.com/repos/teknico/snabb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teknico/snabb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teknico/snabb/git/refs{/sha}","trees_url":"https://api.github.com/repos/teknico/snabb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teknico/snabb/statuses/{sha}","languages_url":"https://api.github.com/repos/teknico/snabb/languages","stargazers_url":"https://api.github.com/repos/teknico/snabb/stargazers","contributors_url":"https://api.github.com/repos/teknico/snabb/contributors","subscribers_url":"https://api.github.com/repos/teknico/snabb/subscribers","subscription_url":"https://api.github.com/repos/teknico/snabb/subscription","commits_url":"https://api.github.com/repos/teknico/snabb/commits{/sha}","git_commits_url":"https://api.github.com/repos/teknico/snabb/git/commits{/sha}","comments_url":"https://api.github.com/repos/teknico/snabb/comments{/number}","issue_comment_url":"https://api.github.com/repos/teknico/snabb/issues/comments{/number}","contents_url":"https://api.github.com/repos/teknico/snabb/contents/{+path}","compare_url":"https://api.github.com/repos/teknico/snabb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teknico/snabb/merges","archive_url":"https://api.github.com/repos/teknico/snabb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teknico/snabb/downloads","issues_url":"https://api.github.com/repos/teknico/snabb/issues{/number}","pulls_url":"https://api.github.com/repos/teknico/snabb/pulls{/number}","milestones_url":"https://api.github.com/repos/teknico/snabb/milestones{/number}","notifications_url":"https://api.github.com/repos/teknico/snabb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teknico/snabb/labels{/name}","releases_url":"https://api.github.com/repos/teknico/snabb/releases{/id}","deployments_url":"https://api.github.com/repos/teknico/snabb/deployments","created_at":"2016-04-25T09:25:57Z","updated_at":"2016-04-25T09:26:01Z","pushed_at":"2016-04-25T14:28:06Z","git_url":"git://github.com/teknico/snabb.git","ssh_url":"git@github.com:teknico/snabb.git","clone_url":"https://github.com/teknico/snabb.git","svn_url":"https://github.com/teknico/snabb","homepage":"","size":8565,"stargazers_count":0,"watchers_count":0,"language":"Lua","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"lwaftr"}},"_links":{"self":{"href":"https://api.github.com/repos/teknico/snabb/pulls/1"},"html":{"href":"https://github.com/teknico/snabb/pull/1"},"issue":{"href":"https://api.github.com/repos/teknico/snabb/issues/1"},"comments":{"href":"https://api.github.com/repos/teknico/snabb/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/teknico/snabb/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/teknico/snabb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/teknico/snabb/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/teknico/snabb/statuses/15af3a5e105af98376f1e42dbd9ff2ac8680d784"}}}}