{"action":"created","comment":{"url":"https://api.github.com/repos/feedhenry/nagios-container/pulls/comments/71135132","id":71135132,"diff_hunk":"@@ -0,0 +1,110 @@\n+#!/bin/bash\n+######################################################################\n+#\n+# Nagios wrapper plugin to retrieve mongo admin password from\n+# same project where nagios is located and then perform the\n+# check requested\n+#\n+######################################################################\n+\n+################################\n+# GLOBALS\n+################################\n+# Nagios exit codes\n+NAGIOS_OK=0\n+NAGIOS_WARN=1\n+NAGIOS_CRIT=2\n+NAGIOS_UNKNOWN=3\n+\n+################################\n+# FUNCTIONS\n+################################\n+usage() {\n+ echo \"Usage:\"\n+ echo \" -w <warn>    Warning threshold (default 0)\"\n+ echo \" -c <crit>    Critical threshold (default 0)\"\n+ echo \" -A <action>  Action as defined\"\n+ echo \" -S <name>     OpenShift selector name\"\n+ echo \" -h           Show this message\"\n+ echo \"Example: $0 -A connect -S mongodb-server -w 0 -c 0\"\n+}\n+\n+################################\n+# ARGUMENT PROCESSING\n+################################\n+WARN=0\n+CRIT=0\n+ACTION=\n+SELECTOR=mongodb-replica\n+while getopts \"h:w:c:A:S:\" OPTION\n+do\n+ case $OPTION in\n+  h) usage; exit $NAGIOS_UNKNOWN ;;\n+  w) WARN=$OPTARG ;;\n+  c) CRIT=$OPTARG ;;\n+  A) ACTION=$OPTARG ;;\n+  S) SELECTOR=$OPTARG ;;\n+  ?) usage; exit $NAGIOS_UNKNOWN ;;\n+ esac\n+done\n+\n+# Ensure all expected variables are populated\n+if [[ -z $ACTION ]] || [[ -z $SELECTOR ]] || [[ -z $WARN ]] || [[ -z $CRIT ]]; then\n+ usage; exit $NAGIOS_UNKNOWN\n+fi\n+\n+# Use a temp file to store list of pods with their mongodb connection info\n+TEMP_FILE=`mktemp`\n+oc get pod --selector=name=$SELECTOR --output json | jq '.items[] | select(.status.phase == \"Running\") | [.metadata.name, .status.podIP, .spec.containers[].ports[].containerPort, ( .spec.containers[].env[] | select(.name == \"MONGODB_ADMIN_PASSWORD\") | .value) ] | @tsv' -r > $TEMP_FILE\n+\n+# The array to store the results for each pod being checked\n+declare -a RESULT_ARR=()\n+\n+# Other prep variables\n+COUNT_WARN=0\n+COUNT_CRIT=0\n+COUNT_OK=0\n+CURR=1\n+\n+# Iterate through each mongodb member, run the check and collect the results \n+while IFS='' read -r line || [[ -n \"$line\" ]]; do\n+  POD=`echo $line | awk '{print $1}'`\n+  IP=`echo $line | awk '{print $2}'`\n+  PORT=`echo $line | awk '{print $3}'`\n+  MONGO_PASS=`echo $line | awk '{print $4}'`\n+\n+  RESULT_ARR[$CURR]=\"$POD - `/opt/rhmap/nagios/plugins/check_mongodb.py -H $IP -P $PORT -C $CRIT -W $WARN -A $ACTION -u admin -p $MONGO_PASS 2>&1`\"\n+\n+  CURRENT_RESULT=$?","path":"plugins/default/check_mongodb_wrapper.sh","position":78,"original_position":78,"commit_id":"9c9f623eafee8d60534b9979ccfdbebd7af18bda","original_commit_id":"9c9f623eafee8d60534b9979ccfdbebd7af18bda","user":{"login":"rhcarvalho","id":88819,"avatar_url":"https://avatars.githubusercontent.com/u/88819?v=3","gravatar_id":"","url":"https://api.github.com/users/rhcarvalho","html_url":"https://github.com/rhcarvalho","followers_url":"https://api.github.com/users/rhcarvalho/followers","following_url":"https://api.github.com/users/rhcarvalho/following{/other_user}","gists_url":"https://api.github.com/users/rhcarvalho/gists{/gist_id}","starred_url":"https://api.github.com/users/rhcarvalho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhcarvalho/subscriptions","organizations_url":"https://api.github.com/users/rhcarvalho/orgs","repos_url":"https://api.github.com/users/rhcarvalho/repos","events_url":"https://api.github.com/users/rhcarvalho/events{/privacy}","received_events_url":"https://api.github.com/users/rhcarvalho/received_events","type":"User","site_admin":false},"body":"This script doesn't set the common options*, and makes use of `$?` to get the exit code of `check_mongodb.py` (I hope that is, and will continue to be, the last command :) ).\r\n\r\nI find it to be error prone, specially alarming for something that will be our nagios check.\r\n\r\nFor instance, there's a `oc get pod` call above, that may fail and the script will continue running.","created_at":"2016-07-18T11:58:01Z","updated_at":"2016-07-18T11:58:01Z","html_url":"https://github.com/feedhenry/nagios-container/pull/6#discussion_r71135132","pull_request_url":"https://api.github.com/repos/feedhenry/nagios-container/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/feedhenry/nagios-container/pulls/comments/71135132"},"html":{"href":"https://github.com/feedhenry/nagios-container/pull/6#discussion_r71135132"},"pull_request":{"href":"https://api.github.com/repos/feedhenry/nagios-container/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/feedhenry/nagios-container/pulls/6","id":77509267,"html_url":"https://github.com/feedhenry/nagios-container/pull/6","diff_url":"https://github.com/feedhenry/nagios-container/pull/6.diff","patch_url":"https://github.com/feedhenry/nagios-container/pull/6.patch","issue_url":"https://api.github.com/repos/feedhenry/nagios-container/issues/6","number":6,"state":"open","locked":false,"title":"Rhmap 6727 add mongodb checks","user":{"login":"jessesarn","id":12660698,"avatar_url":"https://avatars.githubusercontent.com/u/12660698?v=3","gravatar_id":"","url":"https://api.github.com/users/jessesarn","html_url":"https://github.com/jessesarn","followers_url":"https://api.github.com/users/jessesarn/followers","following_url":"https://api.github.com/users/jessesarn/following{/other_user}","gists_url":"https://api.github.com/users/jessesarn/gists{/gist_id}","starred_url":"https://api.github.com/users/jessesarn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessesarn/subscriptions","organizations_url":"https://api.github.com/users/jessesarn/orgs","repos_url":"https://api.github.com/users/jessesarn/repos","events_url":"https://api.github.com/users/jessesarn/events{/privacy}","received_events_url":"https://api.github.com/users/jessesarn/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-14T19:12:22Z","updated_at":"2016-07-18T11:58:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96811d9ed6a25e5c8efe1cf5a750643da2d75103","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/feedhenry/nagios-container/pulls/6/commits","review_comments_url":"https://api.github.com/repos/feedhenry/nagios-container/pulls/6/comments","review_comment_url":"https://api.github.com/repos/feedhenry/nagios-container/pulls/comments{/number}","comments_url":"https://api.github.com/repos/feedhenry/nagios-container/issues/6/comments","statuses_url":"https://api.github.com/repos/feedhenry/nagios-container/statuses/9c9f623eafee8d60534b9979ccfdbebd7af18bda","head":{"label":"jessesarn:RHMAP-6727-add-mongodb-checks","ref":"RHMAP-6727-add-mongodb-checks","sha":"9c9f623eafee8d60534b9979ccfdbebd7af18bda","user":{"login":"jessesarn","id":12660698,"avatar_url":"https://avatars.githubusercontent.com/u/12660698?v=3","gravatar_id":"","url":"https://api.github.com/users/jessesarn","html_url":"https://github.com/jessesarn","followers_url":"https://api.github.com/users/jessesarn/followers","following_url":"https://api.github.com/users/jessesarn/following{/other_user}","gists_url":"https://api.github.com/users/jessesarn/gists{/gist_id}","starred_url":"https://api.github.com/users/jessesarn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessesarn/subscriptions","organizations_url":"https://api.github.com/users/jessesarn/orgs","repos_url":"https://api.github.com/users/jessesarn/repos","events_url":"https://api.github.com/users/jessesarn/events{/privacy}","received_events_url":"https://api.github.com/users/jessesarn/received_events","type":"User","site_admin":false},"repo":{"id":63078463,"name":"nagios-container","full_name":"jessesarn/nagios-container","owner":{"login":"jessesarn","id":12660698,"avatar_url":"https://avatars.githubusercontent.com/u/12660698?v=3","gravatar_id":"","url":"https://api.github.com/users/jessesarn","html_url":"https://github.com/jessesarn","followers_url":"https://api.github.com/users/jessesarn/followers","following_url":"https://api.github.com/users/jessesarn/following{/other_user}","gists_url":"https://api.github.com/users/jessesarn/gists{/gist_id}","starred_url":"https://api.github.com/users/jessesarn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessesarn/subscriptions","organizations_url":"https://api.github.com/users/jessesarn/orgs","repos_url":"https://api.github.com/users/jessesarn/repos","events_url":"https://api.github.com/users/jessesarn/events{/privacy}","received_events_url":"https://api.github.com/users/jessesarn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jessesarn/nagios-container","description":"RHMAP Core Monitoring ","fork":true,"url":"https://api.github.com/repos/jessesarn/nagios-container","forks_url":"https://api.github.com/repos/jessesarn/nagios-container/forks","keys_url":"https://api.github.com/repos/jessesarn/nagios-container/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jessesarn/nagios-container/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jessesarn/nagios-container/teams","hooks_url":"https://api.github.com/repos/jessesarn/nagios-container/hooks","issue_events_url":"https://api.github.com/repos/jessesarn/nagios-container/issues/events{/number}","events_url":"https://api.github.com/repos/jessesarn/nagios-container/events","assignees_url":"https://api.github.com/repos/jessesarn/nagios-container/assignees{/user}","branches_url":"https://api.github.com/repos/jessesarn/nagios-container/branches{/branch}","tags_url":"https://api.github.com/repos/jessesarn/nagios-container/tags","blobs_url":"https://api.github.com/repos/jessesarn/nagios-container/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jessesarn/nagios-container/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jessesarn/nagios-container/git/refs{/sha}","trees_url":"https://api.github.com/repos/jessesarn/nagios-container/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jessesarn/nagios-container/statuses/{sha}","languages_url":"https://api.github.com/repos/jessesarn/nagios-container/languages","stargazers_url":"https://api.github.com/repos/jessesarn/nagios-container/stargazers","contributors_url":"https://api.github.com/repos/jessesarn/nagios-container/contributors","subscribers_url":"https://api.github.com/repos/jessesarn/nagios-container/subscribers","subscription_url":"https://api.github.com/repos/jessesarn/nagios-container/subscription","commits_url":"https://api.github.com/repos/jessesarn/nagios-container/commits{/sha}","git_commits_url":"https://api.github.com/repos/jessesarn/nagios-container/git/commits{/sha}","comments_url":"https://api.github.com/repos/jessesarn/nagios-container/comments{/number}","issue_comment_url":"https://api.github.com/repos/jessesarn/nagios-container/issues/comments{/number}","contents_url":"https://api.github.com/repos/jessesarn/nagios-container/contents/{+path}","compare_url":"https://api.github.com/repos/jessesarn/nagios-container/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jessesarn/nagios-container/merges","archive_url":"https://api.github.com/repos/jessesarn/nagios-container/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jessesarn/nagios-container/downloads","issues_url":"https://api.github.com/repos/jessesarn/nagios-container/issues{/number}","pulls_url":"https://api.github.com/repos/jessesarn/nagios-container/pulls{/number}","milestones_url":"https://api.github.com/repos/jessesarn/nagios-container/milestones{/number}","notifications_url":"https://api.github.com/repos/jessesarn/nagios-container/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jessesarn/nagios-container/labels{/name}","releases_url":"https://api.github.com/repos/jessesarn/nagios-container/releases{/id}","deployments_url":"https://api.github.com/repos/jessesarn/nagios-container/deployments","created_at":"2016-07-11T15:13:34Z","updated_at":"2016-07-14T17:43:26Z","pushed_at":"2016-07-15T17:45:30Z","git_url":"git://github.com/jessesarn/nagios-container.git","ssh_url":"git@github.com:jessesarn/nagios-container.git","clone_url":"https://github.com/jessesarn/nagios-container.git","svn_url":"https://github.com/jessesarn/nagios-container","homepage":null,"size":19,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"feedhenry:master","ref":"master","sha":"adecda1ff0e4a4914f353a78b5144c85b2855267","user":{"login":"feedhenry","id":772226,"avatar_url":"https://avatars.githubusercontent.com/u/772226?v=3","gravatar_id":"","url":"https://api.github.com/users/feedhenry","html_url":"https://github.com/feedhenry","followers_url":"https://api.github.com/users/feedhenry/followers","following_url":"https://api.github.com/users/feedhenry/following{/other_user}","gists_url":"https://api.github.com/users/feedhenry/gists{/gist_id}","starred_url":"https://api.github.com/users/feedhenry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feedhenry/subscriptions","organizations_url":"https://api.github.com/users/feedhenry/orgs","repos_url":"https://api.github.com/users/feedhenry/repos","events_url":"https://api.github.com/users/feedhenry/events{/privacy}","received_events_url":"https://api.github.com/users/feedhenry/received_events","type":"Organization","site_admin":false},"repo":{"id":63078110,"name":"nagios-container","full_name":"feedhenry/nagios-container","owner":{"login":"feedhenry","id":772226,"avatar_url":"https://avatars.githubusercontent.com/u/772226?v=3","gravatar_id":"","url":"https://api.github.com/users/feedhenry","html_url":"https://github.com/feedhenry","followers_url":"https://api.github.com/users/feedhenry/followers","following_url":"https://api.github.com/users/feedhenry/following{/other_user}","gists_url":"https://api.github.com/users/feedhenry/gists{/gist_id}","starred_url":"https://api.github.com/users/feedhenry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feedhenry/subscriptions","organizations_url":"https://api.github.com/users/feedhenry/orgs","repos_url":"https://api.github.com/users/feedhenry/repos","events_url":"https://api.github.com/users/feedhenry/events{/privacy}","received_events_url":"https://api.github.com/users/feedhenry/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/feedhenry/nagios-container","description":"RHMAP Core Monitoring ","fork":false,"url":"https://api.github.com/repos/feedhenry/nagios-container","forks_url":"https://api.github.com/repos/feedhenry/nagios-container/forks","keys_url":"https://api.github.com/repos/feedhenry/nagios-container/keys{/key_id}","collaborators_url":"https://api.github.com/repos/feedhenry/nagios-container/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/feedhenry/nagios-container/teams","hooks_url":"https://api.github.com/repos/feedhenry/nagios-container/hooks","issue_events_url":"https://api.github.com/repos/feedhenry/nagios-container/issues/events{/number}","events_url":"https://api.github.com/repos/feedhenry/nagios-container/events","assignees_url":"https://api.github.com/repos/feedhenry/nagios-container/assignees{/user}","branches_url":"https://api.github.com/repos/feedhenry/nagios-container/branches{/branch}","tags_url":"https://api.github.com/repos/feedhenry/nagios-container/tags","blobs_url":"https://api.github.com/repos/feedhenry/nagios-container/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/feedhenry/nagios-container/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/feedhenry/nagios-container/git/refs{/sha}","trees_url":"https://api.github.com/repos/feedhenry/nagios-container/git/trees{/sha}","statuses_url":"https://api.github.com/repos/feedhenry/nagios-container/statuses/{sha}","languages_url":"https://api.github.com/repos/feedhenry/nagios-container/languages","stargazers_url":"https://api.github.com/repos/feedhenry/nagios-container/stargazers","contributors_url":"https://api.github.com/repos/feedhenry/nagios-container/contributors","subscribers_url":"https://api.github.com/repos/feedhenry/nagios-container/subscribers","subscription_url":"https://api.github.com/repos/feedhenry/nagios-container/subscription","commits_url":"https://api.github.com/repos/feedhenry/nagios-container/commits{/sha}","git_commits_url":"https://api.github.com/repos/feedhenry/nagios-container/git/commits{/sha}","comments_url":"https://api.github.com/repos/feedhenry/nagios-container/comments{/number}","issue_comment_url":"https://api.github.com/repos/feedhenry/nagios-container/issues/comments{/number}","contents_url":"https://api.github.com/repos/feedhenry/nagios-container/contents/{+path}","compare_url":"https://api.github.com/repos/feedhenry/nagios-container/compare/{base}...{head}","merges_url":"https://api.github.com/repos/feedhenry/nagios-container/merges","archive_url":"https://api.github.com/repos/feedhenry/nagios-container/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/feedhenry/nagios-container/downloads","issues_url":"https://api.github.com/repos/feedhenry/nagios-container/issues{/number}","pulls_url":"https://api.github.com/repos/feedhenry/nagios-container/pulls{/number}","milestones_url":"https://api.github.com/repos/feedhenry/nagios-container/milestones{/number}","notifications_url":"https://api.github.com/repos/feedhenry/nagios-container/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/feedhenry/nagios-container/labels{/name}","releases_url":"https://api.github.com/repos/feedhenry/nagios-container/releases{/id}","deployments_url":"https://api.github.com/repos/feedhenry/nagios-container/deployments","created_at":"2016-07-11T15:09:01Z","updated_at":"2016-07-14T13:21:01Z","pushed_at":"2016-07-15T17:45:30Z","git_url":"git://github.com/feedhenry/nagios-container.git","ssh_url":"git@github.com:feedhenry/nagios-container.git","clone_url":"https://github.com/feedhenry/nagios-container.git","svn_url":"https://github.com/feedhenry/nagios-container","homepage":null,"size":21,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/feedhenry/nagios-container/pulls/6"},"html":{"href":"https://github.com/feedhenry/nagios-container/pull/6"},"issue":{"href":"https://api.github.com/repos/feedhenry/nagios-container/issues/6"},"comments":{"href":"https://api.github.com/repos/feedhenry/nagios-container/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/feedhenry/nagios-container/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/feedhenry/nagios-container/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/feedhenry/nagios-container/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/feedhenry/nagios-container/statuses/9c9f623eafee8d60534b9979ccfdbebd7af18bda"}}}}
{"actor":{"display_login":"rhcarvalho"}}