From 03bb7c7962ed641fa3214744dd2679c20e8574e0 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 26 Feb 2018 21:43:00 -0800 Subject: [PATCH] Higher precision percents --- pymonitor/__init__.py | 2 +- pymonitor/monitors/diskspace.py | 8 ++++---- pymonitor/monitors/meminfo.py | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pymonitor/__init__.py b/pymonitor/__init__.py index bbab024..1276d02 100644 --- a/pymonitor/__init__.py +++ b/pymonitor/__init__.py @@ -1 +1 @@ -__version__ = "0.1.4" +__version__ = "0.1.5" diff --git a/pymonitor/monitors/diskspace.py b/pymonitor/monitors/diskspace.py index 604efa5..3b60cfa 100644 --- a/pymonitor/monitors/diskspace.py +++ b/pymonitor/monitors/diskspace.py @@ -40,11 +40,11 @@ def diskspace(filesystems=[], discover=True, omit=[]): "inodesused": stats.f_files - stats.f_favail } - info["diskpctused"] = round(info["diskused"] / info["disksize"] if info["disksize"] > 0 else 0, 2) - info["diskpctfree"] = round(info["diskfree"] / info["disksize"] if info["disksize"] > 0 else 0, 2) + info["diskpctused"] = round(info["diskused"] / info["disksize"] if info["disksize"] > 0 else 0, 5) + info["diskpctfree"] = round(info["diskfree"] / info["disksize"] if info["disksize"] > 0 else 0, 5) - info["inodesused_pct"] = round(info["inodesused"] / info["inodesmax"] if info["inodesmax"] > 0 else 0, 2) - info["inodesfree_pct"] = round(info["inodesfree"] / info["inodesmax"] if info["inodesmax"] > 0 else 0, 2) + info["inodesused_pct"] = round(info["inodesused"] / info["inodesmax"] if info["inodesmax"] > 0 else 0, 5) + info["inodesfree_pct"] = round(info["inodesfree"] / info["inodesmax"] if info["inodesmax"] > 0 else 0, 5) yield info diff --git a/pymonitor/monitors/meminfo.py b/pymonitor/monitors/meminfo.py index a4cb204..9ab25fd 100644 --- a/pymonitor/monitors/meminfo.py +++ b/pymonitor/monitors/meminfo.py @@ -3,16 +3,16 @@ import re memline_pattern = re.compile(r'^(?P[^\\:]+)\:\s+(?P[0-9]+)(\s(?P[a-zA-Z]+))?') computed_fields = { - "mempctused": lambda items: round((items["memtotal"] - items["memfree"]) / items["memtotal"], 2), - "mempctfree": lambda items: 1 - round((items["memtotal"] - items["memfree"]) / items["memtotal"], 2), + "mempctused": lambda items: round((items["memtotal"] - items["memfree"]) / items["memtotal"], 5), + "mempctfree": lambda items: 1 - round((items["memtotal"] - items["memfree"]) / items["memtotal"], 5), "mempctused_nocache": lambda items: round((items["memtotal"] - items["memfree"] - items["cached"]) / - items["memtotal"], 2), + items["memtotal"], 5), "mempctfree_nocache": lambda items: 1 - round((items["memtotal"] - items["memfree"] - items["cached"]) / - items["memtotal"], 2), + items["memtotal"], 5), "swappctused": lambda items: round((items["swaptotal"] - items["swapfree"]) / - items["swaptotal"] if items["swaptotal"] > 0 else 0, 2), + items["swaptotal"] if items["swaptotal"] > 0 else 0, 5), "swappctfree": lambda items: 1 - round((items["swaptotal"] - items["swapfree"]) / - items["swaptotal"] if items["swaptotal"] > 0 else 0, 2) + items["swaptotal"] if items["swaptotal"] > 0 else 0, 5) }