]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
osd: add % used to each OSD 87/head
authorPaul Cuzner <pcuzner@redhat.com>
Fri, 28 Jul 2017 08:02:45 +0000 (20:02 +1200)
committerPaul Cuzner <pcuzner@redhat.com>
Fri, 28 Jul 2017 08:02:45 +0000 (20:02 +1200)
percent used was not available within the osd metric tree only the
physical disk. With the inclusion under the osd, the percent_used can
reference the osd_id directly easier in any queries

collectors/osd.py

index 79ed6567041bb6140b5207b0a7b721146c5f0517..152e7b0230012f5e834974115adb6a0e3dbaf713 100644 (file)
@@ -2,6 +2,7 @@
 
 import os
 import time
+import math
 
 from collectors.base import BaseCollector
 from collectors.common import (todict, fread, freadlines, merge_dicts,
@@ -29,7 +30,7 @@ class OSDstats(object):
         self._current = {}
         self._previous = {}
         self._osd_type = osd_type
-
+        self.osd_percent_used = 0
 
     def update(self, stats):
         """
@@ -66,6 +67,8 @@ class OSDstats(object):
         for attr in stats['osd']:
             setattr(self, attr, stats['osd'].get(attr))
 
+        self.osd_percent_used = math.ceil((float(self.stat_bytes_used) /
+                                           self.stat_bytes) * 100)
 
 class OSDs(BaseCollector):