From f6876810d319c0a8aa483147c53c8362082d3dcd Mon Sep 17 00:00:00 2001 From: Paul Cuzner Date: Fri, 28 Jul 2017 20:02:45 +1200 Subject: [PATCH] osd: add % used to each OSD 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/collectors/osd.py b/collectors/osd.py index 79ed656..152e7b0 100644 --- a/collectors/osd.py +++ b/collectors/osd.py @@ -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): -- 2.47.3