{"action":"created","comment":{"url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/comments/189851125","pull_request_review_id":122104033,"id":189851125,"diff_hunk":"@@ -1,11 +1,74 @@\n-#!/bin/bash\n+#!/usr/bin/env python\n \n-OUTPUT=`testsocket $1 \"<control:alive/>\" |grep Status |grep ok -c`\n+from __future__ import print_function\n+import subprocess\n+import re\n+import sys\n \n-if [ \"$OUTPUT\" -eq \"1\" ]; then\n-    echo \"OK\"\n-    exit 0\n-else\n-    echo \"CRITICAL\"\n-    exit 2\n-fi\n+# Output usage if argument is missing\n+try:\n+    IP = sys.argv[ 1 ]\n+except IndexError:\n+    print ( \"\\nNeeds IP address of the target server\" )\n+    print ( \"\"\"\n+Usage:\n+        check_roxie <ip-address>\n+\"\"\" )\n+    sys.exit ( 1 )\n+\n+# Nagios exit codes\n+ok = 0\n+warning = 1\n+critical = 2\n+\n+cmd_roxie_status = '2>/dev/null testsocket %s \"<control:state/>\"' % IP\n+status = subprocess.Popen ( cmd_roxie_status.strip ( ) , stdout=subprocess.PIPE , shell=True )\n+status_result = status.communicate ( )[ 0 ]\n+roxie_status = re.findall ( '\\<Status\\>(.+?)\\</Status\\>+?' , status_result )\n+my_hash = re.findall ( \"hash='(.*?)'\" , status_result )\n+\n+# Check if roxie process is up and running\n+if roxie_status and roxie_status[ 0 ] == 'ok':\n+    # Get state hashes from roxie cluster\n+    hashes = [ ]\n+    try:\n+        cmd_cluster_state = '2>/dev/null testsocket %s -lock \"<control:state/>\"' % IP\n+        cluster_state = subprocess.Popen ( cmd_cluster_state.strip ( ) , stdout=subprocess.PIPE , shell=True )\n+        cluster_state_result = cluster_state.communicate ( )[ 0 ]\n+        for cluster_result in cluster_state_result.split():\n+            if \"hash\" in cluster_result:\n+                state_hash = re.findall ( \"hash=\\\"(.*?)\\\"\" , cluster_result )\n+                hashes.append ( state_hash[ 0 ] )\n+    except:\n+        pass\n+\n+    total_hashes = len ( hashes )\n+    same_hash = [ ]\n+    different_hash = [ ]\n+\n+    # Compare hash state between self and cluster\n+    while total_hashes > 0:\n+        for i in hashes:\n+            if my_hash[ 0 ] == i:\n+                same_hash.append ( i )\n+                total_hashes -= 1\n+            elif my_hash[ 0 ] != i:\n+                different_hash.append ( i )\n+                total_hashes -= 1\n+        if len ( same_hash ) < len ( different_hash ) and my_hash[ 0 ] in same_hash:","path":"utils/check_roxie/check_roxie","position":67,"original_position":67,"commit_id":"f6e707ac7e7e7568734a63e531bff9aed4659a29","original_commit_id":"f6e707ac7e7e7568734a63e531bff9aed4659a29","user":{"login":"AttilaVamos","id":3518475,"avatar_url":"https://avatars3.githubusercontent.com/u/3518475?v=4","gravatar_id":"","url":"https://api.github.com/users/AttilaVamos","html_url":"https://github.com/AttilaVamos","followers_url":"https://api.github.com/users/AttilaVamos/followers","following_url":"https://api.github.com/users/AttilaVamos/following{/other_user}","gists_url":"https://api.github.com/users/AttilaVamos/gists{/gist_id}","starred_url":"https://api.github.com/users/AttilaVamos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AttilaVamos/subscriptions","organizations_url":"https://api.github.com/users/AttilaVamos/orgs","repos_url":"https://api.github.com/users/AttilaVamos/repos","events_url":"https://api.github.com/users/AttilaVamos/events{/privacy}","received_events_url":"https://api.github.com/users/AttilaVamos/received_events","type":"User","site_admin":false},"body":"Could you explain the aim behind this conditional chain?","created_at":"2018-05-22T10:25:33Z","updated_at":"2018-05-22T10:27:04Z","html_url":"https://github.com/hpcc-systems/nagios-monitoring/pull/21#discussion_r189851125","pull_request_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/21","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/comments/189851125"},"html":{"href":"https://github.com/hpcc-systems/nagios-monitoring/pull/21#discussion_r189851125"},"pull_request":{"href":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/21","id":99264457,"html_url":"https://github.com/hpcc-systems/nagios-monitoring/pull/21","diff_url":"https://github.com/hpcc-systems/nagios-monitoring/pull/21.diff","patch_url":"https://github.com/hpcc-systems/nagios-monitoring/pull/21.patch","issue_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/issues/21","number":21,"state":"open","locked":false,"title":"HPCC-17686 Python version of check_roxie that also gets state hash","user":{"login":"eorochena","id":6799455,"avatar_url":"https://avatars1.githubusercontent.com/u/6799455?v=4","gravatar_id":"","url":"https://api.github.com/users/eorochena","html_url":"https://github.com/eorochena","followers_url":"https://api.github.com/users/eorochena/followers","following_url":"https://api.github.com/users/eorochena/following{/other_user}","gists_url":"https://api.github.com/users/eorochena/gists{/gist_id}","starred_url":"https://api.github.com/users/eorochena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eorochena/subscriptions","organizations_url":"https://api.github.com/users/eorochena/orgs","repos_url":"https://api.github.com/users/eorochena/repos","events_url":"https://api.github.com/users/eorochena/events{/privacy}","received_events_url":"https://api.github.com/users/eorochena/received_events","type":"User","site_admin":false},"body":"Expanded check_roxie to also validate state hash between roxie peers  [Jira isue](https://track.hpccsystems.com/browse/HPCC-17686)","created_at":"2016-12-23T17:13:54Z","updated_at":"2018-05-22T10:27:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83cccf4e29dbd45c05a670d3701970cf39ea17cb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/21/commits","review_comments_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/21/comments","review_comment_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/issues/21/comments","statuses_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/statuses/f6e707ac7e7e7568734a63e531bff9aed4659a29","head":{"label":"eorochena:master","ref":"master","sha":"f6e707ac7e7e7568734a63e531bff9aed4659a29","user":{"login":"eorochena","id":6799455,"avatar_url":"https://avatars1.githubusercontent.com/u/6799455?v=4","gravatar_id":"","url":"https://api.github.com/users/eorochena","html_url":"https://github.com/eorochena","followers_url":"https://api.github.com/users/eorochena/followers","following_url":"https://api.github.com/users/eorochena/following{/other_user}","gists_url":"https://api.github.com/users/eorochena/gists{/gist_id}","starred_url":"https://api.github.com/users/eorochena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eorochena/subscriptions","organizations_url":"https://api.github.com/users/eorochena/orgs","repos_url":"https://api.github.com/users/eorochena/repos","events_url":"https://api.github.com/users/eorochena/events{/privacy}","received_events_url":"https://api.github.com/users/eorochena/received_events","type":"User","site_admin":false},"repo":{"id":77233176,"name":"nagios-monitoring","full_name":"eorochena/nagios-monitoring","owner":{"login":"eorochena","id":6799455,"avatar_url":"https://avatars1.githubusercontent.com/u/6799455?v=4","gravatar_id":"","url":"https://api.github.com/users/eorochena","html_url":"https://github.com/eorochena","followers_url":"https://api.github.com/users/eorochena/followers","following_url":"https://api.github.com/users/eorochena/following{/other_user}","gists_url":"https://api.github.com/users/eorochena/gists{/gist_id}","starred_url":"https://api.github.com/users/eorochena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eorochena/subscriptions","organizations_url":"https://api.github.com/users/eorochena/orgs","repos_url":"https://api.github.com/users/eorochena/repos","events_url":"https://api.github.com/users/eorochena/events{/privacy}","received_events_url":"https://api.github.com/users/eorochena/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eorochena/nagios-monitoring","description":null,"fork":true,"url":"https://api.github.com/repos/eorochena/nagios-monitoring","forks_url":"https://api.github.com/repos/eorochena/nagios-monitoring/forks","keys_url":"https://api.github.com/repos/eorochena/nagios-monitoring/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eorochena/nagios-monitoring/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eorochena/nagios-monitoring/teams","hooks_url":"https://api.github.com/repos/eorochena/nagios-monitoring/hooks","issue_events_url":"https://api.github.com/repos/eorochena/nagios-monitoring/issues/events{/number}","events_url":"https://api.github.com/repos/eorochena/nagios-monitoring/events","assignees_url":"https://api.github.com/repos/eorochena/nagios-monitoring/assignees{/user}","branches_url":"https://api.github.com/repos/eorochena/nagios-monitoring/branches{/branch}","tags_url":"https://api.github.com/repos/eorochena/nagios-monitoring/tags","blobs_url":"https://api.github.com/repos/eorochena/nagios-monitoring/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eorochena/nagios-monitoring/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eorochena/nagios-monitoring/git/refs{/sha}","trees_url":"https://api.github.com/repos/eorochena/nagios-monitoring/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eorochena/nagios-monitoring/statuses/{sha}","languages_url":"https://api.github.com/repos/eorochena/nagios-monitoring/languages","stargazers_url":"https://api.github.com/repos/eorochena/nagios-monitoring/stargazers","contributors_url":"https://api.github.com/repos/eorochena/nagios-monitoring/contributors","subscribers_url":"https://api.github.com/repos/eorochena/nagios-monitoring/subscribers","subscription_url":"https://api.github.com/repos/eorochena/nagios-monitoring/subscription","commits_url":"https://api.github.com/repos/eorochena/nagios-monitoring/commits{/sha}","git_commits_url":"https://api.github.com/repos/eorochena/nagios-monitoring/git/commits{/sha}","comments_url":"https://api.github.com/repos/eorochena/nagios-monitoring/comments{/number}","issue_comment_url":"https://api.github.com/repos/eorochena/nagios-monitoring/issues/comments{/number}","contents_url":"https://api.github.com/repos/eorochena/nagios-monitoring/contents/{+path}","compare_url":"https://api.github.com/repos/eorochena/nagios-monitoring/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eorochena/nagios-monitoring/merges","archive_url":"https://api.github.com/repos/eorochena/nagios-monitoring/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eorochena/nagios-monitoring/downloads","issues_url":"https://api.github.com/repos/eorochena/nagios-monitoring/issues{/number}","pulls_url":"https://api.github.com/repos/eorochena/nagios-monitoring/pulls{/number}","milestones_url":"https://api.github.com/repos/eorochena/nagios-monitoring/milestones{/number}","notifications_url":"https://api.github.com/repos/eorochena/nagios-monitoring/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eorochena/nagios-monitoring/labels{/name}","releases_url":"https://api.github.com/repos/eorochena/nagios-monitoring/releases{/id}","deployments_url":"https://api.github.com/repos/eorochena/nagios-monitoring/deployments","created_at":"2016-12-23T15:15:22Z","updated_at":"2018-05-15T14:03:16Z","pushed_at":"2018-05-15T14:03:14Z","git_url":"git://github.com/eorochena/nagios-monitoring.git","ssh_url":"git@github.com:eorochena/nagios-monitoring.git","clone_url":"https://github.com/eorochena/nagios-monitoring.git","svn_url":"https://github.com/eorochena/nagios-monitoring","homepage":null,"size":156,"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,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hpcc-systems:master","ref":"master","sha":"55fa6e1ce46d3f0cb447bac58c6f1e2af51eb530","user":{"login":"hpcc-systems","id":900867,"avatar_url":"https://avatars3.githubusercontent.com/u/900867?v=4","gravatar_id":"","url":"https://api.github.com/users/hpcc-systems","html_url":"https://github.com/hpcc-systems","followers_url":"https://api.github.com/users/hpcc-systems/followers","following_url":"https://api.github.com/users/hpcc-systems/following{/other_user}","gists_url":"https://api.github.com/users/hpcc-systems/gists{/gist_id}","starred_url":"https://api.github.com/users/hpcc-systems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hpcc-systems/subscriptions","organizations_url":"https://api.github.com/users/hpcc-systems/orgs","repos_url":"https://api.github.com/users/hpcc-systems/repos","events_url":"https://api.github.com/users/hpcc-systems/events{/privacy}","received_events_url":"https://api.github.com/users/hpcc-systems/received_events","type":"Organization","site_admin":false},"repo":{"id":19313631,"name":"nagios-monitoring","full_name":"hpcc-systems/nagios-monitoring","owner":{"login":"hpcc-systems","id":900867,"avatar_url":"https://avatars3.githubusercontent.com/u/900867?v=4","gravatar_id":"","url":"https://api.github.com/users/hpcc-systems","html_url":"https://github.com/hpcc-systems","followers_url":"https://api.github.com/users/hpcc-systems/followers","following_url":"https://api.github.com/users/hpcc-systems/following{/other_user}","gists_url":"https://api.github.com/users/hpcc-systems/gists{/gist_id}","starred_url":"https://api.github.com/users/hpcc-systems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hpcc-systems/subscriptions","organizations_url":"https://api.github.com/users/hpcc-systems/orgs","repos_url":"https://api.github.com/users/hpcc-systems/repos","events_url":"https://api.github.com/users/hpcc-systems/events{/privacy}","received_events_url":"https://api.github.com/users/hpcc-systems/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hpcc-systems/nagios-monitoring","description":null,"fork":true,"url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring","forks_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/forks","keys_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/teams","hooks_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/hooks","issue_events_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/issues/events{/number}","events_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/events","assignees_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/assignees{/user}","branches_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/branches{/branch}","tags_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/tags","blobs_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/git/refs{/sha}","trees_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/statuses/{sha}","languages_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/languages","stargazers_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/stargazers","contributors_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/contributors","subscribers_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/subscribers","subscription_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/subscription","commits_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/commits{/sha}","git_commits_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/git/commits{/sha}","comments_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/comments{/number}","issue_comment_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/issues/comments{/number}","contents_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/contents/{+path}","compare_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/merges","archive_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/downloads","issues_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/issues{/number}","pulls_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls{/number}","milestones_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/milestones{/number}","notifications_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/labels{/name}","releases_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/releases{/id}","deployments_url":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/deployments","created_at":"2014-04-30T12:58:34Z","updated_at":"2018-05-21T16:07:34Z","pushed_at":"2018-05-21T16:07:32Z","git_url":"git://github.com/hpcc-systems/nagios-monitoring.git","ssh_url":"git@github.com:hpcc-systems/nagios-monitoring.git","clone_url":"https://github.com/hpcc-systems/nagios-monitoring.git","svn_url":"https://github.com/hpcc-systems/nagios-monitoring","homepage":null,"size":169,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/21"},"html":{"href":"https://github.com/hpcc-systems/nagios-monitoring/pull/21"},"issue":{"href":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/issues/21"},"comments":{"href":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/hpcc-systems/nagios-monitoring/statuses/f6e707ac7e7e7568734a63e531bff9aed4659a29"}},"author_association":"NONE"}}
{"actor":{"display_login":"AttilaVamos"}}