From beefff27c5d9f1d892a5db2f0d1e0e60a3e603ae Mon Sep 17 00:00:00 2001 From: Aaron Moate Date: Thu, 14 Jun 2018 17:35:51 -0500 Subject: [PATCH] Added user_fahrenheit parameter to impi gmond python module --- ipmi/python_modules/ipmi.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ipmi/python_modules/ipmi.py b/ipmi/python_modules/ipmi.py index 1995bff5..2d97e74b 100644 --- a/ipmi/python_modules/ipmi.py +++ b/ipmi/python_modules/ipmi.py @@ -101,6 +101,9 @@ def metric_description(metric_name): else: return metric_name.strip() +def c_to_f(temp): + return (temp * 9.0/5.0) + 32.0 + def get_metrics(): """Return all metrics""" @@ -167,9 +170,16 @@ def get_metrics(): if not vmatch: continue metric_value = float(vmatch.group(1)) + if data[2].strip() == "degrees C": + if 'use_fahrenheit' in params.keys() and params['use_fahrenheit']: + metric_value = c_to_f(metric_value) + units[metric_name] = "F" + else: + units[metric_name] = "C" + else: + units[metric_name] = data[2].strip() new_metrics[metric_name] = metric_value - units[metric_name] = data[2].strip().replace("degrees C", "C") descr[metric_name] = description except ValueError: @@ -253,6 +263,7 @@ def metric_cleanup(): params = { "use_sudo" : False, + "use_fahrenheit" : False, "metric_prefix" : "ipmi", #"ipmi_ip" : "10.1.2.3", #"username" : "ADMIN",