{"action":"created","comment":{"url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/comments/87354615","pull_request_review_id":7969169,"id":87354615,"diff_hunk":"@@ -400,6 +402,145 @@ def check_alba(logger):\n                            'arakoon_connected')\n \n     @staticmethod\n+    @ExposeToCli('alba', 'disk-safety')\n+    def get_disk_safety(logger):\n+        \"\"\"\n+        Send disk safety for each vpool and the amount of namespaces with the lowest disk safety to DB\n+        \"\"\"\n+        points = []\n+        abms = []\n+\n+        test_name = 'disk-safety'\n+        result = {\n+                \"repair_percentage\": None,\n+                \"lost_disks\": None\n+            }\n+        for service in ServiceHelper.get_services():\n+            if service.type.name == ServiceType.SERVICE_TYPES.ALBA_MGR:\n+                abms.append(service.name)\n+\n+        abms = list(set(abms))\n+        abl = BackendHelper.get_albabackends()\n+        for ab in abl:\n+            # Determine if services are from ab instance\n+            service_name = ServiceHelper.get_service(ab.abm_services[0].service_guid).name\n+            if service_name not in abms:\n+                continue\n+\n+            config = \"arakoon://config/ovs/arakoon/{0}/config?ini=%2Fopt%2FOpenvStorage%2Fconfig%2Farakoon_cacc.ini\".format(service_name)\n+\n+            # Fetch alba info\n+            try:\n+                namespaces = AlbaCLI.run('show-namespaces', config=config, to_json=True)[1]\n+            except Exception as ex:\n+                raise RuntimeError(\"Could not execute 'alba show-namespaces'. Got {0}\".format(ex.message))\n+\n+            try:\n+                presets = AlbaCLI.run('list-presets', config=config, to_json=True)\n+            except Exception as ex:\n+                raise RuntimeError(\"Could not execute 'list-presets'. Got {0}\".format(ex.message))\n+\n+            # Maximum amount of disks that may be lost - preset will determine this\n+            max_lost_disks = 0\n+            for preset_name in presets:\n+                for policy in preset_name['policies']:\n+                    if policy[1] > max_lost_disks:\n+                        max_lost_disks = policy[1]\n+\n+            disk_lost_overview = {}\n+            disk_safety_overview = {}\n+            bucket_overview = {}\n+            max_disk_safety = 0\n+            total_objects = 0\n+\n+            for namespace in namespaces:\n+                statistics = namespace['statistics']\n+                bucket_counts = statistics['bucket_count']\n+                preset_name = namespace['namespace']['preset_name']\n+                for bucket_count in bucket_counts:\n+                    bucket, objects = bucket_count\n+                    total_objects += objects\n+                    # Amount of lost disks at this point\n+                    disk_lost = bucket[0] + bucket[1] - bucket[2]\n+                    disk_safety = bucket[1] - disk_lost\n+                    if disk_safety > max_disk_safety:\n+                        max_disk_safety = disk_safety\n+\n+                    if preset_name not in bucket_overview:\n+                        bucket_overview[preset_name] = {}\n+\n+                    if str(bucket) not in bucket_overview[preset_name]:\n+                        bucket_overview[preset_name][str(bucket)] = {'objects': 0, 'disk_safety': 0}\n+                    if disk_lost not in disk_lost_overview:\n+                        disk_lost_overview[disk_lost] = 0\n+                    if disk_safety not in disk_safety_overview:\n+                        disk_safety_overview[disk_safety] = 0\n+                    disk_lost_overview[disk_lost] += objects\n+                    disk_safety_overview[disk_safety] += objects\n+                    bucket_overview[preset_name][str(bucket)]['objects'] += objects\n+                    bucket_overview[preset_name][str(bucket)]['disk_safety'] = disk_safety\n+\n+            for disk_lost, objects in disk_lost_overview.iteritems():\n+                lost = {\n+                    'measurement': 'disk_lost',\n+                    'tags': {\n+                        'backend_name': ab.name,\n+                        'disk_lost': disk_lost\n+                    },\n+                    'fields': {\n+                        'total_objects': total_objects,\n+                        'objects': objects\n+                    }\n+                }\n+\n+                points.append(lost)\n+\n+        if len(points) == 0:\n+            logger.skip('Found no objects present of the system.', test_name)\n+        else:\n+            total_objects = 0\n+            object_to_be_repaired = 0\n+            current_disks_lost = 0\n+            for result in points:\n+                total_objects = result[\"fields\"][\"total_objects\"]\n+                # Ignore fully healthy ones\n+                if result[\"tags\"][\"disk_lost\"] != 0:\n+                    current_disks_lost = result[\"tags\"][\"disk_lost\"]\n+                    object_to_be_repaired = result[\"fields\"][\"objects\"]\n+            repair_percentage = object_to_be_repaired / total_objects\n+            if current_disks_lost == 0:\n+                logger.success(\"Found no losts disks. All data is safe.\")\n+            else:\n+                logger.failure(\"Currently found {0} disks that are lost. Alba might or might not repair these disks.\".format(current_disks_lost))","path":"ovs/extensions/healthcheck/alba/alba_health_check.py","position":133,"original_position":133,"commit_id":"3b0e275ad215fc74113a385caac765a9e8a2223f","original_commit_id":"3b0e275ad215fc74113a385caac765a9e8a2223f","user":{"login":"kinvaris","id":4190375,"avatar_url":"https://avatars.githubusercontent.com/u/4190375?v=3","gravatar_id":"","url":"https://api.github.com/users/kinvaris","html_url":"https://github.com/kinvaris","followers_url":"https://api.github.com/users/kinvaris/followers","following_url":"https://api.github.com/users/kinvaris/following{/other_user}","gists_url":"https://api.github.com/users/kinvaris/gists{/gist_id}","starred_url":"https://api.github.com/users/kinvaris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinvaris/subscriptions","organizations_url":"https://api.github.com/users/kinvaris/orgs","repos_url":"https://api.github.com/users/kinvaris/repos","events_url":"https://api.github.com/users/kinvaris/events{/privacy}","received_events_url":"https://api.github.com/users/kinvaris/received_events","type":"User","site_admin":false},"body":"Alba might or might not repair these disks? Alba will repair you data ;)!","created_at":"2016-11-10T09:17:22Z","updated_at":"2016-11-10T09:17:22Z","html_url":"https://github.com/openvstorage/openvstorage-health-check/pull/133#discussion_r87354615","pull_request_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/133","_links":{"self":{"href":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/comments/87354615"},"html":{"href":"https://github.com/openvstorage/openvstorage-health-check/pull/133#discussion_r87354615"},"pull_request":{"href":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/133"}}},"pull_request":{"url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/133","id":92989149,"html_url":"https://github.com/openvstorage/openvstorage-health-check/pull/133","diff_url":"https://github.com/openvstorage/openvstorage-health-check/pull/133.diff","patch_url":"https://github.com/openvstorage/openvstorage-health-check/pull/133.patch","issue_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/issues/133","number":133,"state":"open","locked":false,"title":"Monitor repairing threshhold","user":{"login":"JeffreyDevloo","id":17570109,"avatar_url":"https://avatars.githubusercontent.com/u/17570109?v=3","gravatar_id":"","url":"https://api.github.com/users/JeffreyDevloo","html_url":"https://github.com/JeffreyDevloo","followers_url":"https://api.github.com/users/JeffreyDevloo/followers","following_url":"https://api.github.com/users/JeffreyDevloo/following{/other_user}","gists_url":"https://api.github.com/users/JeffreyDevloo/gists{/gist_id}","starred_url":"https://api.github.com/users/JeffreyDevloo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeffreyDevloo/subscriptions","organizations_url":"https://api.github.com/users/JeffreyDevloo/orgs","repos_url":"https://api.github.com/users/JeffreyDevloo/repos","events_url":"https://api.github.com/users/JeffreyDevloo/events{/privacy}","received_events_url":"https://api.github.com/users/JeffreyDevloo/received_events","type":"User","site_admin":false},"body":" #127 - object repair test\r\nAdded service helper method\r\nRemoved unused code in logger\r\nAdded custom value logging\r\nAdded a primitive caching system\r\nFixed KeyError issue: thrown keyerrors were caught by the run method and returned the wrong output","created_at":"2016-11-09T16:00:02Z","updated_at":"2016-11-10T09:17:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bded1034ad3743df64c2ba18967af4b7b8bd6dd","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/133/commits","review_comments_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/133/comments","review_comment_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/issues/133/comments","statuses_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/statuses/3b0e275ad215fc74113a385caac765a9e8a2223f","head":{"label":"openvstorage:monitor-repairing-threshhold","ref":"monitor-repairing-threshhold","sha":"3b0e275ad215fc74113a385caac765a9e8a2223f","user":{"login":"openvstorage","id":12763393,"avatar_url":"https://avatars.githubusercontent.com/u/12763393?v=3","gravatar_id":"","url":"https://api.github.com/users/openvstorage","html_url":"https://github.com/openvstorage","followers_url":"https://api.github.com/users/openvstorage/followers","following_url":"https://api.github.com/users/openvstorage/following{/other_user}","gists_url":"https://api.github.com/users/openvstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/openvstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openvstorage/subscriptions","organizations_url":"https://api.github.com/users/openvstorage/orgs","repos_url":"https://api.github.com/users/openvstorage/repos","events_url":"https://api.github.com/users/openvstorage/events{/privacy}","received_events_url":"https://api.github.com/users/openvstorage/received_events","type":"Organization","site_admin":false},"repo":{"id":52349527,"name":"openvstorage-health-check","full_name":"openvstorage/openvstorage-health-check","owner":{"login":"openvstorage","id":12763393,"avatar_url":"https://avatars.githubusercontent.com/u/12763393?v=3","gravatar_id":"","url":"https://api.github.com/users/openvstorage","html_url":"https://github.com/openvstorage","followers_url":"https://api.github.com/users/openvstorage/followers","following_url":"https://api.github.com/users/openvstorage/following{/other_user}","gists_url":"https://api.github.com/users/openvstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/openvstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openvstorage/subscriptions","organizations_url":"https://api.github.com/users/openvstorage/orgs","repos_url":"https://api.github.com/users/openvstorage/repos","events_url":"https://api.github.com/users/openvstorage/events{/privacy}","received_events_url":"https://api.github.com/users/openvstorage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openvstorage/openvstorage-health-check","description":"The health check is classified as a monitoring, detection and healing tool for Open vStorage.","fork":false,"url":"https://api.github.com/repos/openvstorage/openvstorage-health-check","forks_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/forks","keys_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/teams","hooks_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/hooks","issue_events_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/issues/events{/number}","events_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/events","assignees_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/assignees{/user}","branches_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/branches{/branch}","tags_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/tags","blobs_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/git/refs{/sha}","trees_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/statuses/{sha}","languages_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/languages","stargazers_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/stargazers","contributors_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/contributors","subscribers_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/subscribers","subscription_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/subscription","commits_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/commits{/sha}","git_commits_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/git/commits{/sha}","comments_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/comments{/number}","issue_comment_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/issues/comments{/number}","contents_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/contents/{+path}","compare_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/merges","archive_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/downloads","issues_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/issues{/number}","pulls_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls{/number}","milestones_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/milestones{/number}","notifications_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/labels{/name}","releases_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/releases{/id}","deployments_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/deployments","created_at":"2016-02-23T10:05:01Z","updated_at":"2016-10-24T12:09:03Z","pushed_at":"2016-11-10T08:54:06Z","git_url":"git://github.com/openvstorage/openvstorage-health-check.git","ssh_url":"git@github.com:openvstorage/openvstorage-health-check.git","clone_url":"https://github.com/openvstorage/openvstorage-health-check.git","svn_url":"https://github.com/openvstorage/openvstorage-health-check","homepage":"","size":490,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":20,"forks":4,"open_issues":20,"watchers":2,"default_branch":"master"}},"base":{"label":"openvstorage:master","ref":"master","sha":"101c789cc75d0cb026e3bd4a87f18b0d88453ae4","user":{"login":"openvstorage","id":12763393,"avatar_url":"https://avatars.githubusercontent.com/u/12763393?v=3","gravatar_id":"","url":"https://api.github.com/users/openvstorage","html_url":"https://github.com/openvstorage","followers_url":"https://api.github.com/users/openvstorage/followers","following_url":"https://api.github.com/users/openvstorage/following{/other_user}","gists_url":"https://api.github.com/users/openvstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/openvstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openvstorage/subscriptions","organizations_url":"https://api.github.com/users/openvstorage/orgs","repos_url":"https://api.github.com/users/openvstorage/repos","events_url":"https://api.github.com/users/openvstorage/events{/privacy}","received_events_url":"https://api.github.com/users/openvstorage/received_events","type":"Organization","site_admin":false},"repo":{"id":52349527,"name":"openvstorage-health-check","full_name":"openvstorage/openvstorage-health-check","owner":{"login":"openvstorage","id":12763393,"avatar_url":"https://avatars.githubusercontent.com/u/12763393?v=3","gravatar_id":"","url":"https://api.github.com/users/openvstorage","html_url":"https://github.com/openvstorage","followers_url":"https://api.github.com/users/openvstorage/followers","following_url":"https://api.github.com/users/openvstorage/following{/other_user}","gists_url":"https://api.github.com/users/openvstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/openvstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openvstorage/subscriptions","organizations_url":"https://api.github.com/users/openvstorage/orgs","repos_url":"https://api.github.com/users/openvstorage/repos","events_url":"https://api.github.com/users/openvstorage/events{/privacy}","received_events_url":"https://api.github.com/users/openvstorage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openvstorage/openvstorage-health-check","description":"The health check is classified as a monitoring, detection and healing tool for Open vStorage.","fork":false,"url":"https://api.github.com/repos/openvstorage/openvstorage-health-check","forks_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/forks","keys_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/teams","hooks_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/hooks","issue_events_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/issues/events{/number}","events_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/events","assignees_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/assignees{/user}","branches_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/branches{/branch}","tags_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/tags","blobs_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/git/refs{/sha}","trees_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/statuses/{sha}","languages_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/languages","stargazers_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/stargazers","contributors_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/contributors","subscribers_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/subscribers","subscription_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/subscription","commits_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/commits{/sha}","git_commits_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/git/commits{/sha}","comments_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/comments{/number}","issue_comment_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/issues/comments{/number}","contents_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/contents/{+path}","compare_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/merges","archive_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/downloads","issues_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/issues{/number}","pulls_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls{/number}","milestones_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/milestones{/number}","notifications_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/labels{/name}","releases_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/releases{/id}","deployments_url":"https://api.github.com/repos/openvstorage/openvstorage-health-check/deployments","created_at":"2016-02-23T10:05:01Z","updated_at":"2016-10-24T12:09:03Z","pushed_at":"2016-11-10T08:54:06Z","git_url":"git://github.com/openvstorage/openvstorage-health-check.git","ssh_url":"git@github.com:openvstorage/openvstorage-health-check.git","clone_url":"https://github.com/openvstorage/openvstorage-health-check.git","svn_url":"https://github.com/openvstorage/openvstorage-health-check","homepage":"","size":490,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":20,"forks":4,"open_issues":20,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/133"},"html":{"href":"https://github.com/openvstorage/openvstorage-health-check/pull/133"},"issue":{"href":"https://api.github.com/repos/openvstorage/openvstorage-health-check/issues/133"},"comments":{"href":"https://api.github.com/repos/openvstorage/openvstorage-health-check/issues/133/comments"},"review_comments":{"href":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/133/comments"},"review_comment":{"href":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openvstorage/openvstorage-health-check/pulls/133/commits"},"statuses":{"href":"https://api.github.com/repos/openvstorage/openvstorage-health-check/statuses/3b0e275ad215fc74113a385caac765a9e8a2223f"}}}}
{"actor":{"display_login":"kinvaris"}}