{"action":"created","comment":{"url":"https://api.github.com/repos/RackHD/on-tasks/pulls/comments/77717473","id":77717473,"diff_hunk":"@@ -354,5 +369,149 @@ describe(require('path').basename(__filename), function () {\n                 }).to.throw(/Unknown poller metric name: unknown/);\n             });\n         });\n+\n+        describe('alerting', function() {\n+            var snmpData = {\r\n+                config: {\r\n+                    oids:[],\r\n+                    alerts:[]\r\n+                },\r\n+                host: '1.2.3.4',\r\n+                community: 'test',\r\n+                workItemId: 'aWorkItemId',\r\n+                node: 'aNodeId',\r\n+                result: []\r\n+            };\r\n+\n+            beforeEach(function() {\n+                this.sandbox.stub(taskProtocol, 'publishPollerAlert').resolves();\n+                snmpData.config.alerts = [];\n+            });\n+\n+            it('should not alert if there are no alerts', function() {\r\n+                return this.snmp._determineAlert(snmpData).should.become([])\r\n+                .then(function() {\r\n+                    expect(taskProtocol.publishPollerAlert).to.not.have.been.called;\n+                });\r\n+            });\r\n+\n+            it('should alert on matching alert string', function() {\r\n+                snmpData.config.alerts.push({'.1.3.6.1.2.1.1.5': 'test value'});\r\n+                snmpData.result.push({\r\n+                    source: '.1.3.6.1.2.1.1.5',\r\n+                    values: {'.1.3.6.1.2.1.1.5': 'test value'}\r\n+                });\r\n+\r\n+                return this.snmp._determineAlert(snmpData)\r\n+                .then(function(out) {\r\n+                    expect(out).to.be.an('Array').with.length(1)\r\n+                    expect(out[0]).to.have.property('oid');\r\n+                    expect(out[0]).to.have.property('value');\r\n+                    expect(out[0]).to.have.property('matched');\r\n+                    expect(out[0]).to.deep.equal({\r\n+                        oid: '.1.3.6.1.2.1.1.5',\r\n+                        value: 'test value',\r\n+                        matched: 'test value'\r\n+                    });\r\n+                    expect(taskProtocol.publishPollerAlert).to.have.been.calledWith(graphId, 'snmp', {\r\n+                        host: '1.2.3.4',\r\n+                        oid: '.1.3.6.1.2.1.1.5',\r\n+                        value: 'test value',\r\n+                        nodeRef: '/nodes/aNodeId',\r\n+                        dataRef: '/pollers/aWorkItemId/data/current',\r\n+                        matched: 'test value'\r\n+                    });\r\n+                });\r\n+            });\n+\n+            it('should alert on matching alert regex', function() {\r\n+                snmpData.config.alerts.push({'.1.3.6.1.2.1.1.5': '/test/'});\r\n+                snmpData.result.push({\r\n+                    source: '.1.3.6.1.2.1.1.5',\r\n+                    values: {'.1.3.6.1.2.1.1.5': 'test value'}\r\n+                });\r\n+\r\n+                return this.snmp._determineAlert(snmpData)\r\n+                .then(function(out) {\r\n+                    expect(out).to.be.an('Array').with.length(1)\r\n+                    expect(out[0]).to.have.property('oid');\r\n+                    expect(out[0]).to.have.property('value');\r\n+                    expect(out[0]).to.have.property('matched');\r\n+                    expect(out[0]).to.deep.equal({\r\n+                        oid: '.1.3.6.1.2.1.1.5',\r\n+                        value: 'test value',\r\n+                        matched: '/test/'\r\n+                    });\r\n+                    expect(taskProtocol.publishPollerAlert).to.have.been.calledWith(graphId, 'snmp', {\r\n+                        host: '1.2.3.4',\r\n+                        oid: '.1.3.6.1.2.1.1.5',\r\n+                        value: 'test value',\r\n+                        nodeRef: '/nodes/aNodeId',\r\n+                        dataRef: '/pollers/aWorkItemId/data/current',\r\n+                        matched: '/test/'\r\n+                    });\r\n+                });\r\n+            });\n+\n+            it('should alert on matching alert with compound logic', function() {\r\n+                snmpData.config.alerts.push({'.1.3.6.1.2.1.1.5': {\r\n+                    \"greaterThan\": 42,\n+                    \"integer\": true\n+                }});\r\n+                snmpData.result.push({\r\n+                    source: '.1.3.6.1.2.1.1.5',\r\n+                    values: {'.1.3.6.1.2.1.1.5': '45'}\r\n+                });\r\n+                return this.snmp._determineAlert(snmpData)\r\n+                .then(function(out) {\r\n+                    expect(out).to.be.an('Array').with.length(1)\r\n+                    expect(out[0]).to.have.property('oid');\r\n+                    expect(out[0]).to.have.property('value');\r\n+                    expect(out[0]).to.have.property('matched');\r\n+                    expect(out[0]).to.deep.equal({\r\n+                        oid: '.1.3.6.1.2.1.1.5',\r\n+                        value: '45',\r\n+                        matched: snmpData.config.alerts[0]['.1.3.6.1.2.1.1.5']\r\n+                    });\r\n+                    expect(taskProtocol.publishPollerAlert).to.have.been.calledWith(graphId, 'snmp', {\r\n+                        host: '1.2.3.4',\r\n+                        oid: '.1.3.6.1.2.1.1.5',\r\n+                        value: '45',\r\n+                        nodeRef: '/nodes/aNodeId',\r\n+                        dataRef: '/pollers/aWorkItemId/data/current',\r\n+                        matched: snmpData.config.alerts[0]['.1.3.6.1.2.1.1.5']\r\n+                    });\r\n+                });\r\n+            });\n+\n+            it('should not alert on non-matching alert with compound logic', function() {\r\n+                snmpData.config.alerts.push({'.1.3.6.1.2.1.1.5': {\r\n+                    \"greaterThan\": 42,\n+                    \"integer\": true\n+                }});\r\n+                snmpData.result.push({\r\n+                    source: '.1.3.6.1.2.1.1.5',\r\n+                    values: {'.1.3.6.1.2.1.1.5': '41'}\r\n+                });\r\n+\r\n+                return this.snmp._determineAlert(snmpData, snmpData.result[0].values).should.become([])\r\n+                .then(function() {\r\n+                    expect(taskProtocol.publishPollerAlert).to.not.have.been.called;\n+                });\n+            });\n+\n+            it('should not alert if there is no change in status', function() {\r\n+                snmpData.config.alerts.push({'.1.3.6.1.2.1.1.5': '/test/'});\r\n+                snmpData.result.push({\r\n+                    source: '.1.3.6.1.2.1.1.5',\r\n+                    values: {'.1.3.6.1.2.1.1.5': 'test value'}\r\n+                });\r\n+\r\n+                return this.snmp._determineAlert(snmpData, snmpData.result[0].values).should.become([])\r","path":"spec/lib/jobs/snmp-job-spec.js","position":301,"original_position":301,"commit_id":"2710b31e0295fde273427037f15b0455d4d9d044","original_commit_id":"2710b31e0295fde273427037f15b0455d4d9d044","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Line is too long.","created_at":"2016-09-06T20:57:19Z","updated_at":"2016-09-06T20:57:19Z","html_url":"https://github.com/RackHD/on-tasks/pull/314#discussion_r77717473","pull_request_url":"https://api.github.com/repos/RackHD/on-tasks/pulls/314","_links":{"self":{"href":"https://api.github.com/repos/RackHD/on-tasks/pulls/comments/77717473"},"html":{"href":"https://github.com/RackHD/on-tasks/pull/314#discussion_r77717473"},"pull_request":{"href":"https://api.github.com/repos/RackHD/on-tasks/pulls/314"}}},"pull_request":{"url":"https://api.github.com/repos/RackHD/on-tasks/pulls/314","id":81037210,"html_url":"https://github.com/RackHD/on-tasks/pull/314","diff_url":"https://github.com/RackHD/on-tasks/pull/314.diff","patch_url":"https://github.com/RackHD/on-tasks/pull/314.patch","issue_url":"https://api.github.com/repos/RackHD/on-tasks/issues/314","number":314,"state":"open","locked":false,"title":"Add task upsert node","user":{"login":"zhangy42","id":14022164,"avatar_url":"https://avatars.githubusercontent.com/u/14022164?v=3","gravatar_id":"","url":"https://api.github.com/users/zhangy42","html_url":"https://github.com/zhangy42","followers_url":"https://api.github.com/users/zhangy42/followers","following_url":"https://api.github.com/users/zhangy42/following{/other_user}","gists_url":"https://api.github.com/users/zhangy42/gists{/gist_id}","starred_url":"https://api.github.com/users/zhangy42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhangy42/subscriptions","organizations_url":"https://api.github.com/users/zhangy42/orgs","repos_url":"https://api.github.com/users/zhangy42/repos","events_url":"https://api.github.com/users/zhangy42/events{/privacy}","received_events_url":"https://api.github.com/users/zhangy42/received_events","type":"User","site_admin":false},"body":"@RackHD/corecommitters \r\n@benbp @yyscamper @pscharla \r\n\r\nThis is a cleaner PR that helps debug the Jenkins issues after rebase.\r\n\r\nOriginal PR is here https://github.com/RackHD/on-tasks/pull/274.","created_at":"2016-08-11T21:49:24Z","updated_at":"2016-09-06T20:57:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0921e0d44954aebcded2493f0c56a211cd607cfd","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/RackHD/on-tasks/pulls/314/commits","review_comments_url":"https://api.github.com/repos/RackHD/on-tasks/pulls/314/comments","review_comment_url":"https://api.github.com/repos/RackHD/on-tasks/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RackHD/on-tasks/issues/314/comments","statuses_url":"https://api.github.com/repos/RackHD/on-tasks/statuses/2710b31e0295fde273427037f15b0455d4d9d044","head":{"label":"zhangy42:add-task-upsert-node","ref":"add-task-upsert-node","sha":"2710b31e0295fde273427037f15b0455d4d9d044","user":{"login":"zhangy42","id":14022164,"avatar_url":"https://avatars.githubusercontent.com/u/14022164?v=3","gravatar_id":"","url":"https://api.github.com/users/zhangy42","html_url":"https://github.com/zhangy42","followers_url":"https://api.github.com/users/zhangy42/followers","following_url":"https://api.github.com/users/zhangy42/following{/other_user}","gists_url":"https://api.github.com/users/zhangy42/gists{/gist_id}","starred_url":"https://api.github.com/users/zhangy42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhangy42/subscriptions","organizations_url":"https://api.github.com/users/zhangy42/orgs","repos_url":"https://api.github.com/users/zhangy42/repos","events_url":"https://api.github.com/users/zhangy42/events{/privacy}","received_events_url":"https://api.github.com/users/zhangy42/received_events","type":"User","site_admin":false},"repo":{"id":55007338,"name":"on-tasks","full_name":"zhangy42/on-tasks","owner":{"login":"zhangy42","id":14022164,"avatar_url":"https://avatars.githubusercontent.com/u/14022164?v=3","gravatar_id":"","url":"https://api.github.com/users/zhangy42","html_url":"https://github.com/zhangy42","followers_url":"https://api.github.com/users/zhangy42/followers","following_url":"https://api.github.com/users/zhangy42/following{/other_user}","gists_url":"https://api.github.com/users/zhangy42/gists{/gist_id}","starred_url":"https://api.github.com/users/zhangy42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhangy42/subscriptions","organizations_url":"https://api.github.com/users/zhangy42/orgs","repos_url":"https://api.github.com/users/zhangy42/repos","events_url":"https://api.github.com/users/zhangy42/events{/privacy}","received_events_url":"https://api.github.com/users/zhangy42/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zhangy42/on-tasks","description":"","fork":true,"url":"https://api.github.com/repos/zhangy42/on-tasks","forks_url":"https://api.github.com/repos/zhangy42/on-tasks/forks","keys_url":"https://api.github.com/repos/zhangy42/on-tasks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zhangy42/on-tasks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zhangy42/on-tasks/teams","hooks_url":"https://api.github.com/repos/zhangy42/on-tasks/hooks","issue_events_url":"https://api.github.com/repos/zhangy42/on-tasks/issues/events{/number}","events_url":"https://api.github.com/repos/zhangy42/on-tasks/events","assignees_url":"https://api.github.com/repos/zhangy42/on-tasks/assignees{/user}","branches_url":"https://api.github.com/repos/zhangy42/on-tasks/branches{/branch}","tags_url":"https://api.github.com/repos/zhangy42/on-tasks/tags","blobs_url":"https://api.github.com/repos/zhangy42/on-tasks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zhangy42/on-tasks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zhangy42/on-tasks/git/refs{/sha}","trees_url":"https://api.github.com/repos/zhangy42/on-tasks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zhangy42/on-tasks/statuses/{sha}","languages_url":"https://api.github.com/repos/zhangy42/on-tasks/languages","stargazers_url":"https://api.github.com/repos/zhangy42/on-tasks/stargazers","contributors_url":"https://api.github.com/repos/zhangy42/on-tasks/contributors","subscribers_url":"https://api.github.com/repos/zhangy42/on-tasks/subscribers","subscription_url":"https://api.github.com/repos/zhangy42/on-tasks/subscription","commits_url":"https://api.github.com/repos/zhangy42/on-tasks/commits{/sha}","git_commits_url":"https://api.github.com/repos/zhangy42/on-tasks/git/commits{/sha}","comments_url":"https://api.github.com/repos/zhangy42/on-tasks/comments{/number}","issue_comment_url":"https://api.github.com/repos/zhangy42/on-tasks/issues/comments{/number}","contents_url":"https://api.github.com/repos/zhangy42/on-tasks/contents/{+path}","compare_url":"https://api.github.com/repos/zhangy42/on-tasks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zhangy42/on-tasks/merges","archive_url":"https://api.github.com/repos/zhangy42/on-tasks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zhangy42/on-tasks/downloads","issues_url":"https://api.github.com/repos/zhangy42/on-tasks/issues{/number}","pulls_url":"https://api.github.com/repos/zhangy42/on-tasks/pulls{/number}","milestones_url":"https://api.github.com/repos/zhangy42/on-tasks/milestones{/number}","notifications_url":"https://api.github.com/repos/zhangy42/on-tasks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zhangy42/on-tasks/labels{/name}","releases_url":"https://api.github.com/repos/zhangy42/on-tasks/releases{/id}","deployments_url":"https://api.github.com/repos/zhangy42/on-tasks/deployments","created_at":"2016-03-29T20:11:44Z","updated_at":"2016-03-29T20:11:46Z","pushed_at":"2016-09-06T20:56:20Z","git_url":"git://github.com/zhangy42/on-tasks.git","ssh_url":"git@github.com:zhangy42/on-tasks.git","clone_url":"https://github.com/zhangy42/on-tasks.git","svn_url":"https://github.com/zhangy42/on-tasks","homepage":null,"size":1776,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"RackHD:master","ref":"master","sha":"ede293f0ab5dbdf86f394d53d03fe40398fae937","user":{"login":"RackHD","id":13982662,"avatar_url":"https://avatars.githubusercontent.com/u/13982662?v=3","gravatar_id":"","url":"https://api.github.com/users/RackHD","html_url":"https://github.com/RackHD","followers_url":"https://api.github.com/users/RackHD/followers","following_url":"https://api.github.com/users/RackHD/following{/other_user}","gists_url":"https://api.github.com/users/RackHD/gists{/gist_id}","starred_url":"https://api.github.com/users/RackHD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RackHD/subscriptions","organizations_url":"https://api.github.com/users/RackHD/orgs","repos_url":"https://api.github.com/users/RackHD/repos","events_url":"https://api.github.com/users/RackHD/events{/privacy}","received_events_url":"https://api.github.com/users/RackHD/received_events","type":"Organization","site_admin":false},"repo":{"id":41690099,"name":"on-tasks","full_name":"RackHD/on-tasks","owner":{"login":"RackHD","id":13982662,"avatar_url":"https://avatars.githubusercontent.com/u/13982662?v=3","gravatar_id":"","url":"https://api.github.com/users/RackHD","html_url":"https://github.com/RackHD","followers_url":"https://api.github.com/users/RackHD/followers","following_url":"https://api.github.com/users/RackHD/following{/other_user}","gists_url":"https://api.github.com/users/RackHD/gists{/gist_id}","starred_url":"https://api.github.com/users/RackHD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RackHD/subscriptions","organizations_url":"https://api.github.com/users/RackHD/orgs","repos_url":"https://api.github.com/users/RackHD/repos","events_url":"https://api.github.com/users/RackHD/events{/privacy}","received_events_url":"https://api.github.com/users/RackHD/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RackHD/on-tasks","description":"","fork":false,"url":"https://api.github.com/repos/RackHD/on-tasks","forks_url":"https://api.github.com/repos/RackHD/on-tasks/forks","keys_url":"https://api.github.com/repos/RackHD/on-tasks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RackHD/on-tasks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RackHD/on-tasks/teams","hooks_url":"https://api.github.com/repos/RackHD/on-tasks/hooks","issue_events_url":"https://api.github.com/repos/RackHD/on-tasks/issues/events{/number}","events_url":"https://api.github.com/repos/RackHD/on-tasks/events","assignees_url":"https://api.github.com/repos/RackHD/on-tasks/assignees{/user}","branches_url":"https://api.github.com/repos/RackHD/on-tasks/branches{/branch}","tags_url":"https://api.github.com/repos/RackHD/on-tasks/tags","blobs_url":"https://api.github.com/repos/RackHD/on-tasks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RackHD/on-tasks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RackHD/on-tasks/git/refs{/sha}","trees_url":"https://api.github.com/repos/RackHD/on-tasks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RackHD/on-tasks/statuses/{sha}","languages_url":"https://api.github.com/repos/RackHD/on-tasks/languages","stargazers_url":"https://api.github.com/repos/RackHD/on-tasks/stargazers","contributors_url":"https://api.github.com/repos/RackHD/on-tasks/contributors","subscribers_url":"https://api.github.com/repos/RackHD/on-tasks/subscribers","subscription_url":"https://api.github.com/repos/RackHD/on-tasks/subscription","commits_url":"https://api.github.com/repos/RackHD/on-tasks/commits{/sha}","git_commits_url":"https://api.github.com/repos/RackHD/on-tasks/git/commits{/sha}","comments_url":"https://api.github.com/repos/RackHD/on-tasks/comments{/number}","issue_comment_url":"https://api.github.com/repos/RackHD/on-tasks/issues/comments{/number}","contents_url":"https://api.github.com/repos/RackHD/on-tasks/contents/{+path}","compare_url":"https://api.github.com/repos/RackHD/on-tasks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RackHD/on-tasks/merges","archive_url":"https://api.github.com/repos/RackHD/on-tasks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RackHD/on-tasks/downloads","issues_url":"https://api.github.com/repos/RackHD/on-tasks/issues{/number}","pulls_url":"https://api.github.com/repos/RackHD/on-tasks/pulls{/number}","milestones_url":"https://api.github.com/repos/RackHD/on-tasks/milestones{/number}","notifications_url":"https://api.github.com/repos/RackHD/on-tasks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RackHD/on-tasks/labels{/name}","releases_url":"https://api.github.com/repos/RackHD/on-tasks/releases{/id}","deployments_url":"https://api.github.com/repos/RackHD/on-tasks/deployments","created_at":"2015-08-31T17:29:32Z","updated_at":"2016-05-17T08:18:08Z","pushed_at":"2016-09-06T20:56:22Z","git_url":"git://github.com/RackHD/on-tasks.git","ssh_url":"git@github.com:RackHD/on-tasks.git","clone_url":"https://github.com/RackHD/on-tasks.git","svn_url":"https://github.com/RackHD/on-tasks","homepage":null,"size":1991,"stargazers_count":7,"watchers_count":7,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":6,"forks":47,"open_issues":6,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RackHD/on-tasks/pulls/314"},"html":{"href":"https://github.com/RackHD/on-tasks/pull/314"},"issue":{"href":"https://api.github.com/repos/RackHD/on-tasks/issues/314"},"comments":{"href":"https://api.github.com/repos/RackHD/on-tasks/issues/314/comments"},"review_comments":{"href":"https://api.github.com/repos/RackHD/on-tasks/pulls/314/comments"},"review_comment":{"href":"https://api.github.com/repos/RackHD/on-tasks/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RackHD/on-tasks/pulls/314/commits"},"statuses":{"href":"https://api.github.com/repos/RackHD/on-tasks/statuses/2710b31e0295fde273427037f15b0455d4d9d044"}}}}
{"actor":{"display_login":"houndci-bot"}}