{"action":"created","comment":{"url":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/comments/25513771","id":25513771,"diff_hunk":"@@ -51,11 +98,84 @@ public boolean isRunning() {\n \n     @Override\n     public void write(Message message) throws Exception {\n-        // TODO: implement writing\n+\n+        JSONObject jsonData = new JSONObject();\n+        jsonData.put(\"host\",configuration.getString(CK_REPORTER_HOST));\n+\n+\n+        String keyString = GetFormattedResult(message, configuration.getString(CK_KEY_PATTERN));\n+        String valueString = GetFormattedResult(message, configuration.getString(CK_VALUE_PATTERN));\n+\n+        jsonData.put(\"key\", keyString);\n+        jsonData.put(\"value\", valueString);\n+\n+        JSONObject json = new JSONObject();\n+        json.put(\"request\", REQUEST_FIELD_VALUE);\n+        json.put(\"data\", Arrays.asList(jsonData));\n+\n+        String str = json.toString().replaceAll(\"\\\\\\\\\", \"\");\n+\n+        byte[] data = str.getBytes();\n+        byte[] header = ZABBIX_HEADER.getBytes();\n+\n+        ByteBuffer buffer = ByteBuffer.allocate(header.length + 8 + data.length);\n+        buffer.order(ByteOrder.LITTLE_ENDIAN);\n+\n+        int currentOffset = 0;\n+        buffer.put(header, 0, header.length);\n+        currentOffset += header.length;\n+\n+        buffer.putInt(currentOffset, data.length);\n+        currentOffset += 8;\n+\n+        buffer.position(currentOffset);\n+        buffer.put(data, 0, data.length);\n+\n+        outputStream.write(buffer.array());\n+        String response = new String();\n+        while (true){\n+            byte[] buff = new byte[1024];\n+            try {\n+                int i = inputStream.read(buff);\n+\n+                if(i == -1){\n+                    break;\n+                }\n+\n+                String dataPart = new String(buff, 0, i, \"UTF-8\");\n+                if(dataPart.length()<8){\n+                    continue;\n+                }\n+\n+                response = dataPart.substring(8);\n+            } catch (IOException e) {\n+                e.printStackTrace();\n+            }\n+        }\n+        if(!response.contains(\"processed: 1\") || response.contains(\"failed: 1\")){\n+            LOG.error(response);\n+        }\n+    }\n+\n+    private String GetFormattedResult(Message message, String pattern) {","path":"src/main/java/org/kurdyukov/sensu/ZabbixServerOutput.java","position":159,"original_position":159,"commit_id":"cb5bc4a2fc5da88b29efab5fead593e99eeb90a4","original_commit_id":"cb5bc4a2fc5da88b29efab5fead593e99eeb90a4","user":{"login":"akurdyukov","id":78690,"avatar_url":"https://avatars.githubusercontent.com/u/78690?v=3","gravatar_id":"","url":"https://api.github.com/users/akurdyukov","html_url":"https://github.com/akurdyukov","followers_url":"https://api.github.com/users/akurdyukov/followers","following_url":"https://api.github.com/users/akurdyukov/following{/other_user}","gists_url":"https://api.github.com/users/akurdyukov/gists{/gist_id}","starred_url":"https://api.github.com/users/akurdyukov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akurdyukov/subscriptions","organizations_url":"https://api.github.com/users/akurdyukov/orgs","repos_url":"https://api.github.com/users/akurdyukov/repos","events_url":"https://api.github.com/users/akurdyukov/events{/privacy}","received_events_url":"https://api.github.com/users/akurdyukov/received_events","type":"User","site_admin":false},"body":"wrong casing","created_at":"2015-02-27T15:34:02Z","updated_at":"2015-02-27T15:34:02Z","html_url":"https://github.com/akurdyukov/sensu-client-output/pull/1#discussion_r25513771","pull_request_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/comments/25513771"},"html":{"href":"https://github.com/akurdyukov/sensu-client-output/pull/1#discussion_r25513771"},"pull_request":{"href":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/1","id":30088594,"html_url":"https://github.com/akurdyukov/sensu-client-output/pull/1","diff_url":"https://github.com/akurdyukov/sensu-client-output/pull/1.diff","patch_url":"https://github.com/akurdyukov/sensu-client-output/pull/1.patch","issue_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/issues/1","number":1,"state":"open","locked":false,"title":"zabbix ouput plugin implemented","user":{"login":"alexrazg","id":11210277,"avatar_url":"https://avatars.githubusercontent.com/u/11210277?v=3","gravatar_id":"","url":"https://api.github.com/users/alexrazg","html_url":"https://github.com/alexrazg","followers_url":"https://api.github.com/users/alexrazg/followers","following_url":"https://api.github.com/users/alexrazg/following{/other_user}","gists_url":"https://api.github.com/users/alexrazg/gists{/gist_id}","starred_url":"https://api.github.com/users/alexrazg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexrazg/subscriptions","organizations_url":"https://api.github.com/users/alexrazg/orgs","repos_url":"https://api.github.com/users/alexrazg/repos","events_url":"https://api.github.com/users/alexrazg/events{/privacy}","received_events_url":"https://api.github.com/users/alexrazg/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-26T15:47:43Z","updated_at":"2015-02-27T15:34:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bec24f76c70feac85a2047951c5545b4c7351297","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/1/commits","review_comments_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/1/comments","review_comment_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/issues/1/comments","statuses_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/statuses/cb5bc4a2fc5da88b29efab5fead593e99eeb90a4","head":{"label":"alexrazg:master","ref":"master","sha":"cb5bc4a2fc5da88b29efab5fead593e99eeb90a4","user":{"login":"alexrazg","id":11210277,"avatar_url":"https://avatars.githubusercontent.com/u/11210277?v=3","gravatar_id":"","url":"https://api.github.com/users/alexrazg","html_url":"https://github.com/alexrazg","followers_url":"https://api.github.com/users/alexrazg/followers","following_url":"https://api.github.com/users/alexrazg/following{/other_user}","gists_url":"https://api.github.com/users/alexrazg/gists{/gist_id}","starred_url":"https://api.github.com/users/alexrazg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexrazg/subscriptions","organizations_url":"https://api.github.com/users/alexrazg/orgs","repos_url":"https://api.github.com/users/alexrazg/repos","events_url":"https://api.github.com/users/alexrazg/events{/privacy}","received_events_url":"https://api.github.com/users/alexrazg/received_events","type":"User","site_admin":false},"repo":{"id":31362740,"name":"sensu-client-output","full_name":"alexrazg/sensu-client-output","owner":{"login":"alexrazg","id":11210277,"avatar_url":"https://avatars.githubusercontent.com/u/11210277?v=3","gravatar_id":"","url":"https://api.github.com/users/alexrazg","html_url":"https://github.com/alexrazg","followers_url":"https://api.github.com/users/alexrazg/followers","following_url":"https://api.github.com/users/alexrazg/following{/other_user}","gists_url":"https://api.github.com/users/alexrazg/gists{/gist_id}","starred_url":"https://api.github.com/users/alexrazg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexrazg/subscriptions","organizations_url":"https://api.github.com/users/alexrazg/orgs","repos_url":"https://api.github.com/users/alexrazg/repos","events_url":"https://api.github.com/users/alexrazg/events{/privacy}","received_events_url":"https://api.github.com/users/alexrazg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexrazg/sensu-client-output","description":"Gralog2 output plugin for posting log lines as sense events","fork":true,"url":"https://api.github.com/repos/alexrazg/sensu-client-output","forks_url":"https://api.github.com/repos/alexrazg/sensu-client-output/forks","keys_url":"https://api.github.com/repos/alexrazg/sensu-client-output/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexrazg/sensu-client-output/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexrazg/sensu-client-output/teams","hooks_url":"https://api.github.com/repos/alexrazg/sensu-client-output/hooks","issue_events_url":"https://api.github.com/repos/alexrazg/sensu-client-output/issues/events{/number}","events_url":"https://api.github.com/repos/alexrazg/sensu-client-output/events","assignees_url":"https://api.github.com/repos/alexrazg/sensu-client-output/assignees{/user}","branches_url":"https://api.github.com/repos/alexrazg/sensu-client-output/branches{/branch}","tags_url":"https://api.github.com/repos/alexrazg/sensu-client-output/tags","blobs_url":"https://api.github.com/repos/alexrazg/sensu-client-output/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexrazg/sensu-client-output/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexrazg/sensu-client-output/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexrazg/sensu-client-output/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexrazg/sensu-client-output/statuses/{sha}","languages_url":"https://api.github.com/repos/alexrazg/sensu-client-output/languages","stargazers_url":"https://api.github.com/repos/alexrazg/sensu-client-output/stargazers","contributors_url":"https://api.github.com/repos/alexrazg/sensu-client-output/contributors","subscribers_url":"https://api.github.com/repos/alexrazg/sensu-client-output/subscribers","subscription_url":"https://api.github.com/repos/alexrazg/sensu-client-output/subscription","commits_url":"https://api.github.com/repos/alexrazg/sensu-client-output/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexrazg/sensu-client-output/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexrazg/sensu-client-output/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexrazg/sensu-client-output/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexrazg/sensu-client-output/contents/{+path}","compare_url":"https://api.github.com/repos/alexrazg/sensu-client-output/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexrazg/sensu-client-output/merges","archive_url":"https://api.github.com/repos/alexrazg/sensu-client-output/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexrazg/sensu-client-output/downloads","issues_url":"https://api.github.com/repos/alexrazg/sensu-client-output/issues{/number}","pulls_url":"https://api.github.com/repos/alexrazg/sensu-client-output/pulls{/number}","milestones_url":"https://api.github.com/repos/alexrazg/sensu-client-output/milestones{/number}","notifications_url":"https://api.github.com/repos/alexrazg/sensu-client-output/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexrazg/sensu-client-output/labels{/name}","releases_url":"https://api.github.com/repos/alexrazg/sensu-client-output/releases{/id}","created_at":"2015-02-26T10:47:14Z","updated_at":"2015-02-27T15:29:17Z","pushed_at":"2015-02-27T15:29:17Z","git_url":"git://github.com/alexrazg/sensu-client-output.git","ssh_url":"git@github.com:alexrazg/sensu-client-output.git","clone_url":"https://github.com/alexrazg/sensu-client-output.git","svn_url":"https://github.com/alexrazg/sensu-client-output","homepage":"","size":93,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"akurdyukov:master","ref":"master","sha":"025dd7ee05565e7b9586e9e712db2a7af9f69c76","user":{"login":"akurdyukov","id":78690,"avatar_url":"https://avatars.githubusercontent.com/u/78690?v=3","gravatar_id":"","url":"https://api.github.com/users/akurdyukov","html_url":"https://github.com/akurdyukov","followers_url":"https://api.github.com/users/akurdyukov/followers","following_url":"https://api.github.com/users/akurdyukov/following{/other_user}","gists_url":"https://api.github.com/users/akurdyukov/gists{/gist_id}","starred_url":"https://api.github.com/users/akurdyukov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akurdyukov/subscriptions","organizations_url":"https://api.github.com/users/akurdyukov/orgs","repos_url":"https://api.github.com/users/akurdyukov/repos","events_url":"https://api.github.com/users/akurdyukov/events{/privacy}","received_events_url":"https://api.github.com/users/akurdyukov/received_events","type":"User","site_admin":false},"repo":{"id":24912970,"name":"sensu-client-output","full_name":"akurdyukov/sensu-client-output","owner":{"login":"akurdyukov","id":78690,"avatar_url":"https://avatars.githubusercontent.com/u/78690?v=3","gravatar_id":"","url":"https://api.github.com/users/akurdyukov","html_url":"https://github.com/akurdyukov","followers_url":"https://api.github.com/users/akurdyukov/followers","following_url":"https://api.github.com/users/akurdyukov/following{/other_user}","gists_url":"https://api.github.com/users/akurdyukov/gists{/gist_id}","starred_url":"https://api.github.com/users/akurdyukov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akurdyukov/subscriptions","organizations_url":"https://api.github.com/users/akurdyukov/orgs","repos_url":"https://api.github.com/users/akurdyukov/repos","events_url":"https://api.github.com/users/akurdyukov/events{/privacy}","received_events_url":"https://api.github.com/users/akurdyukov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/akurdyukov/sensu-client-output","description":"Gralog2 output plugin for posting log lines as sense events","fork":false,"url":"https://api.github.com/repos/akurdyukov/sensu-client-output","forks_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/forks","keys_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/teams","hooks_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/hooks","issue_events_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/issues/events{/number}","events_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/events","assignees_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/assignees{/user}","branches_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/branches{/branch}","tags_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/tags","blobs_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/git/refs{/sha}","trees_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/statuses/{sha}","languages_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/languages","stargazers_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/stargazers","contributors_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/contributors","subscribers_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/subscribers","subscription_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/subscription","commits_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/commits{/sha}","git_commits_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/git/commits{/sha}","comments_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/comments{/number}","issue_comment_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/issues/comments{/number}","contents_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/contents/{+path}","compare_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/merges","archive_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/downloads","issues_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/issues{/number}","pulls_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls{/number}","milestones_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/milestones{/number}","notifications_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/labels{/name}","releases_url":"https://api.github.com/repos/akurdyukov/sensu-client-output/releases{/id}","created_at":"2014-10-07T21:43:15Z","updated_at":"2015-02-26T10:42:43Z","pushed_at":"2015-02-26T10:42:42Z","git_url":"git://github.com/akurdyukov/sensu-client-output.git","ssh_url":"git@github.com:akurdyukov/sensu-client-output.git","clone_url":"https://github.com/akurdyukov/sensu-client-output.git","svn_url":"https://github.com/akurdyukov/sensu-client-output","homepage":"","size":188,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/1"},"html":{"href":"https://github.com/akurdyukov/sensu-client-output/pull/1"},"issue":{"href":"https://api.github.com/repos/akurdyukov/sensu-client-output/issues/1"},"comments":{"href":"https://api.github.com/repos/akurdyukov/sensu-client-output/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akurdyukov/sensu-client-output/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/akurdyukov/sensu-client-output/statuses/cb5bc4a2fc5da88b29efab5fead593e99eeb90a4"}}}}