{"action":"created","comment":{"url":"https://api.github.com/repos/TheSophon/sophon/pulls/comments/54240980","id":54240980,"diff_hunk":"@@ -0,0 +1,50 @@\n+#!/usr/bin/env python2\n+# -*- coding: utf-8 -*-\n+\n+import commands\n+\n+command = {\n+    \"cpu\": \"top -b -n 1\",\n+    \"disk\": \"df -h .\"\n+}\n+\n+def get_index(result, word):\n+    index = 0\n+    for x in result:\n+        index = index + 1\n+        if x == word:\n+            return index\n+    return 0\n+\n+def get_host_status():\n+    ret = {\n+        \"Status\": \"\",\n+        \"CPU Load\": \"\", \n+        \"Memory Usage\": \"\",\n+        \"Disk Usage\": \"\"\n+    }\n+    cpu = 'ansible all -a \"%s\"' % (command[\"cpu\"])\n+    disk = 'ansible all -a \"%s\"' % (command[\"disk\"])\n+    cpu_result = commands.getstatusoutput(cpu)\n+    disk_result = commands.getstatusoutput(disk)\n+    cpu_result = cpu_result[1].split()\n+    disk_result = disk_result[1].split()\n+    if cpu_result[2] == \"FAILED\":\n+        ret[\"Status\"] = \"Down\"\n+        ret[\"CPU Load\"] = 0\n+        ret[\"Memory Usage\"] = (0, 0)\n+        ret[\"Disk Usage\"] = (0, 0)\n+    else:\n+        cpu_index = get_index(cpu_result, \"average:\")\n+        mem_index = get_index(cpu_result, \"Mem:\")\n+        disk_index = get_index(disk_result, \"/\")\n+        mem_used = int(cpu_result[mem_index + 2][:-1]) ","path":"sophon/utils/status.py","position":41,"original_position":41,"commit_id":"4a4977560ffb125b0ba98ce7a5a1deed7f9e20a7","original_commit_id":"4a4977560ffb125b0ba98ce7a5a1deed7f9e20a7","user":{"login":"brickgao","id":2117598,"avatar_url":"https://avatars.githubusercontent.com/u/2117598?v=3","gravatar_id":"","url":"https://api.github.com/users/brickgao","html_url":"https://github.com/brickgao","followers_url":"https://api.github.com/users/brickgao/followers","following_url":"https://api.github.com/users/brickgao/following{/other_user}","gists_url":"https://api.github.com/users/brickgao/gists{/gist_id}","starred_url":"https://api.github.com/users/brickgao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brickgao/subscriptions","organizations_url":"https://api.github.com/users/brickgao/orgs","repos_url":"https://api.github.com/users/brickgao/repos","events_url":"https://api.github.com/users/brickgao/events{/privacy}","received_events_url":"https://api.github.com/users/brickgao/received_events","type":"User","site_admin":false},"body":"C: 41, 0: Trailing whitespace (trailing-whitespace)","created_at":"2016-02-26T13:16:09Z","updated_at":"2016-02-26T13:16:09Z","html_url":"https://github.com/TheSophon/sophon/pull/28#discussion_r54240980","pull_request_url":"https://api.github.com/repos/TheSophon/sophon/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/TheSophon/sophon/pulls/comments/54240980"},"html":{"href":"https://github.com/TheSophon/sophon/pull/28#discussion_r54240980"},"pull_request":{"href":"https://api.github.com/repos/TheSophon/sophon/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/TheSophon/sophon/pulls/28","id":60839244,"html_url":"https://github.com/TheSophon/sophon/pull/28","diff_url":"https://github.com/TheSophon/sophon/pull/28.diff","patch_url":"https://github.com/TheSophon/sophon/pull/28.patch","issue_url":"https://api.github.com/repos/TheSophon/sophon/issues/28","number":28,"state":"open","locked":false,"title":"Implement the function that could get server status","user":{"login":"DevilBin","id":5550803,"avatar_url":"https://avatars.githubusercontent.com/u/5550803?v=3","gravatar_id":"","url":"https://api.github.com/users/DevilBin","html_url":"https://github.com/DevilBin","followers_url":"https://api.github.com/users/DevilBin/followers","following_url":"https://api.github.com/users/DevilBin/following{/other_user}","gists_url":"https://api.github.com/users/DevilBin/gists{/gist_id}","starred_url":"https://api.github.com/users/DevilBin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevilBin/subscriptions","organizations_url":"https://api.github.com/users/DevilBin/orgs","repos_url":"https://api.github.com/users/DevilBin/repos","events_url":"https://api.github.com/users/DevilBin/events{/privacy}","received_events_url":"https://api.github.com/users/DevilBin/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-26T13:07:24Z","updated_at":"2016-02-26T13:16:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b518da9570f14da40603fa502964c05d0c4903c8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/TheSophon/sophon/pulls/28/commits","review_comments_url":"https://api.github.com/repos/TheSophon/sophon/pulls/28/comments","review_comment_url":"https://api.github.com/repos/TheSophon/sophon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TheSophon/sophon/issues/28/comments","statuses_url":"https://api.github.com/repos/TheSophon/sophon/statuses/4a4977560ffb125b0ba98ce7a5a1deed7f9e20a7","head":{"label":"DevilBin:dev","ref":"dev","sha":"4a4977560ffb125b0ba98ce7a5a1deed7f9e20a7","user":{"login":"DevilBin","id":5550803,"avatar_url":"https://avatars.githubusercontent.com/u/5550803?v=3","gravatar_id":"","url":"https://api.github.com/users/DevilBin","html_url":"https://github.com/DevilBin","followers_url":"https://api.github.com/users/DevilBin/followers","following_url":"https://api.github.com/users/DevilBin/following{/other_user}","gists_url":"https://api.github.com/users/DevilBin/gists{/gist_id}","starred_url":"https://api.github.com/users/DevilBin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevilBin/subscriptions","organizations_url":"https://api.github.com/users/DevilBin/orgs","repos_url":"https://api.github.com/users/DevilBin/repos","events_url":"https://api.github.com/users/DevilBin/events{/privacy}","received_events_url":"https://api.github.com/users/DevilBin/received_events","type":"User","site_admin":false},"repo":{"id":48429124,"name":"sophon","full_name":"DevilBin/sophon","owner":{"login":"DevilBin","id":5550803,"avatar_url":"https://avatars.githubusercontent.com/u/5550803?v=3","gravatar_id":"","url":"https://api.github.com/users/DevilBin","html_url":"https://github.com/DevilBin","followers_url":"https://api.github.com/users/DevilBin/followers","following_url":"https://api.github.com/users/DevilBin/following{/other_user}","gists_url":"https://api.github.com/users/DevilBin/gists{/gist_id}","starred_url":"https://api.github.com/users/DevilBin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevilBin/subscriptions","organizations_url":"https://api.github.com/users/DevilBin/orgs","repos_url":"https://api.github.com/users/DevilBin/repos","events_url":"https://api.github.com/users/DevilBin/events{/privacy}","received_events_url":"https://api.github.com/users/DevilBin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DevilBin/sophon","description":"Simple IT automation web service based on Ansible","fork":true,"url":"https://api.github.com/repos/DevilBin/sophon","forks_url":"https://api.github.com/repos/DevilBin/sophon/forks","keys_url":"https://api.github.com/repos/DevilBin/sophon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DevilBin/sophon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DevilBin/sophon/teams","hooks_url":"https://api.github.com/repos/DevilBin/sophon/hooks","issue_events_url":"https://api.github.com/repos/DevilBin/sophon/issues/events{/number}","events_url":"https://api.github.com/repos/DevilBin/sophon/events","assignees_url":"https://api.github.com/repos/DevilBin/sophon/assignees{/user}","branches_url":"https://api.github.com/repos/DevilBin/sophon/branches{/branch}","tags_url":"https://api.github.com/repos/DevilBin/sophon/tags","blobs_url":"https://api.github.com/repos/DevilBin/sophon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DevilBin/sophon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DevilBin/sophon/git/refs{/sha}","trees_url":"https://api.github.com/repos/DevilBin/sophon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DevilBin/sophon/statuses/{sha}","languages_url":"https://api.github.com/repos/DevilBin/sophon/languages","stargazers_url":"https://api.github.com/repos/DevilBin/sophon/stargazers","contributors_url":"https://api.github.com/repos/DevilBin/sophon/contributors","subscribers_url":"https://api.github.com/repos/DevilBin/sophon/subscribers","subscription_url":"https://api.github.com/repos/DevilBin/sophon/subscription","commits_url":"https://api.github.com/repos/DevilBin/sophon/commits{/sha}","git_commits_url":"https://api.github.com/repos/DevilBin/sophon/git/commits{/sha}","comments_url":"https://api.github.com/repos/DevilBin/sophon/comments{/number}","issue_comment_url":"https://api.github.com/repos/DevilBin/sophon/issues/comments{/number}","contents_url":"https://api.github.com/repos/DevilBin/sophon/contents/{+path}","compare_url":"https://api.github.com/repos/DevilBin/sophon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DevilBin/sophon/merges","archive_url":"https://api.github.com/repos/DevilBin/sophon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DevilBin/sophon/downloads","issues_url":"https://api.github.com/repos/DevilBin/sophon/issues{/number}","pulls_url":"https://api.github.com/repos/DevilBin/sophon/pulls{/number}","milestones_url":"https://api.github.com/repos/DevilBin/sophon/milestones{/number}","notifications_url":"https://api.github.com/repos/DevilBin/sophon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DevilBin/sophon/labels{/name}","releases_url":"https://api.github.com/repos/DevilBin/sophon/releases{/id}","deployments_url":"https://api.github.com/repos/DevilBin/sophon/deployments","created_at":"2015-12-22T11:47:18Z","updated_at":"2016-02-26T13:05:16Z","pushed_at":"2016-02-26T13:06:59Z","git_url":"git://github.com/DevilBin/sophon.git","ssh_url":"git@github.com:DevilBin/sophon.git","clone_url":"https://github.com/DevilBin/sophon.git","svn_url":"https://github.com/DevilBin/sophon","homepage":null,"size":63,"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":"TheSophon:master","ref":"master","sha":"130f1f8107d8a89808949eb163c6e29e1bdd7b31","user":{"login":"TheSophon","id":15784622,"avatar_url":"https://avatars.githubusercontent.com/u/15784622?v=3","gravatar_id":"","url":"https://api.github.com/users/TheSophon","html_url":"https://github.com/TheSophon","followers_url":"https://api.github.com/users/TheSophon/followers","following_url":"https://api.github.com/users/TheSophon/following{/other_user}","gists_url":"https://api.github.com/users/TheSophon/gists{/gist_id}","starred_url":"https://api.github.com/users/TheSophon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheSophon/subscriptions","organizations_url":"https://api.github.com/users/TheSophon/orgs","repos_url":"https://api.github.com/users/TheSophon/repos","events_url":"https://api.github.com/users/TheSophon/events{/privacy}","received_events_url":"https://api.github.com/users/TheSophon/received_events","type":"Organization","site_admin":false},"repo":{"id":45927420,"name":"sophon","full_name":"TheSophon/sophon","owner":{"login":"TheSophon","id":15784622,"avatar_url":"https://avatars.githubusercontent.com/u/15784622?v=3","gravatar_id":"","url":"https://api.github.com/users/TheSophon","html_url":"https://github.com/TheSophon","followers_url":"https://api.github.com/users/TheSophon/followers","following_url":"https://api.github.com/users/TheSophon/following{/other_user}","gists_url":"https://api.github.com/users/TheSophon/gists{/gist_id}","starred_url":"https://api.github.com/users/TheSophon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheSophon/subscriptions","organizations_url":"https://api.github.com/users/TheSophon/orgs","repos_url":"https://api.github.com/users/TheSophon/repos","events_url":"https://api.github.com/users/TheSophon/events{/privacy}","received_events_url":"https://api.github.com/users/TheSophon/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TheSophon/sophon","description":"Simple IT automation web service based on Ansible","fork":false,"url":"https://api.github.com/repos/TheSophon/sophon","forks_url":"https://api.github.com/repos/TheSophon/sophon/forks","keys_url":"https://api.github.com/repos/TheSophon/sophon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheSophon/sophon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheSophon/sophon/teams","hooks_url":"https://api.github.com/repos/TheSophon/sophon/hooks","issue_events_url":"https://api.github.com/repos/TheSophon/sophon/issues/events{/number}","events_url":"https://api.github.com/repos/TheSophon/sophon/events","assignees_url":"https://api.github.com/repos/TheSophon/sophon/assignees{/user}","branches_url":"https://api.github.com/repos/TheSophon/sophon/branches{/branch}","tags_url":"https://api.github.com/repos/TheSophon/sophon/tags","blobs_url":"https://api.github.com/repos/TheSophon/sophon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheSophon/sophon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheSophon/sophon/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheSophon/sophon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheSophon/sophon/statuses/{sha}","languages_url":"https://api.github.com/repos/TheSophon/sophon/languages","stargazers_url":"https://api.github.com/repos/TheSophon/sophon/stargazers","contributors_url":"https://api.github.com/repos/TheSophon/sophon/contributors","subscribers_url":"https://api.github.com/repos/TheSophon/sophon/subscribers","subscription_url":"https://api.github.com/repos/TheSophon/sophon/subscription","commits_url":"https://api.github.com/repos/TheSophon/sophon/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheSophon/sophon/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheSophon/sophon/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheSophon/sophon/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheSophon/sophon/contents/{+path}","compare_url":"https://api.github.com/repos/TheSophon/sophon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheSophon/sophon/merges","archive_url":"https://api.github.com/repos/TheSophon/sophon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheSophon/sophon/downloads","issues_url":"https://api.github.com/repos/TheSophon/sophon/issues{/number}","pulls_url":"https://api.github.com/repos/TheSophon/sophon/pulls{/number}","milestones_url":"https://api.github.com/repos/TheSophon/sophon/milestones{/number}","notifications_url":"https://api.github.com/repos/TheSophon/sophon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheSophon/sophon/labels{/name}","releases_url":"https://api.github.com/repos/TheSophon/sophon/releases{/id}","deployments_url":"https://api.github.com/repos/TheSophon/sophon/deployments","created_at":"2015-11-10T17:11:21Z","updated_at":"2016-01-25T15:31:04Z","pushed_at":"2016-02-26T13:07:24Z","git_url":"git://github.com/TheSophon/sophon.git","ssh_url":"git@github.com:TheSophon/sophon.git","clone_url":"https://github.com/TheSophon/sophon.git","svn_url":"https://github.com/TheSophon/sophon","homepage":null,"size":66,"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":6,"forks":3,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TheSophon/sophon/pulls/28"},"html":{"href":"https://github.com/TheSophon/sophon/pull/28"},"issue":{"href":"https://api.github.com/repos/TheSophon/sophon/issues/28"},"comments":{"href":"https://api.github.com/repos/TheSophon/sophon/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/TheSophon/sophon/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/TheSophon/sophon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TheSophon/sophon/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/TheSophon/sophon/statuses/4a4977560ffb125b0ba98ce7a5a1deed7f9e20a7"}}}}