Hi,
On 2016-06-16 04:45, Nathan Scott wrote:
> ----- Original Message -----
>> [...]
>>
>> Ok, let's switch to the compact form, the change is trivial and it
>> covers all the existing metrics (in fact the millisec case is only
>> needed for a metric from the sample PMDA). Change to this direction
>> doesn't require QA updates.
>
> Hmm, there's several other possible strings there - src/libpcp/src/units.c
> has the full list - need to deal with those too? (microsec, nanosec, etc)
Ok, let's do this properly, patch below:
---
src/pmrep/pmrep.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/pmrep/pmrep.py b/src/pmrep/pmrep.py
index b330ca6..4a74eb3 100755
--- a/src/pmrep/pmrep.py
+++ b/src/pmrep/pmrep.py
@@ -623,6 +623,14 @@ class PMReporter(object):
else:
self.zabbix_interval = int(self.interval)
+ def format_metric_label(self, label):
+ """ Format a metric label """
+ # See src/libpcp/src/units.c
+ label = label.replace(" / nanosec", "/ns").replace(" / microsec",
"/Âs")
+ label = label.replace(" / millisec", "/ms").replace(" / sec", "/s")
+ label = label.replace(" / min", "/min").replace(" / hour", "/h")
+ return label
+
def validate_metrics(self):
""" Validate the metrics set """
# Check the metrics against PMNS, resolve non-leaf metrics
@@ -737,9 +745,11 @@ class PMReporter(object):
label += "/s"
if self.descs[i].contents.units.dimTime == 1:
label = "util"
+ label = self.format_metric_label(label)
self.metrics[metric][2] = (label, unitstr, mult)
else:
- self.metrics[metric][2] = (unitstr, unitstr, 1)
+ label = self.format_metric_label(unitstr)
+ self.metrics[metric][2] = (label, unitstr, 1)
except pmapi.pmErr as error:
sys.stderr.write("%s: %s.\n" % (str(error),
self.metrics[metric][2]))
sys.exit(1)
Thanks,
--
Marko Myllynen
|