pcp
[Top] [All Lists]

pmrep: prepare for future enhancements

To: pcp developers <pcp@xxxxxxxxxxx>
Subject: pmrep: prepare for future enhancements
From: Marko Myllynen <myllynen@xxxxxxxxxx>
Date: Sun, 13 Dec 2015 17:48:33 +0200
Delivered-to: pcp@xxxxxxxxxxx
Organization: Red Hat
Reply-to: myllynen@xxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
Hi,

this is coming in somewhat late in the release cycle but given that
this is mostly man page tweaking and the code change is well contained
and it gives us lots of flexibility in the future to do changes without
breaking the user interface I think it's worth the risk.

E.g. with PMFG we might be able to easily request rates also for
non-counter metrics. But currently in pmrep the metrics are either raw
or non-raw, no other forms exist. Generalize the metric presentation
type by changing the "raw" keyword to "type" instead and use "raw"
instead of "yes" to denote raw metric type. We can add alternatives
like "rate" in later releases, now it's too late for that.

This also means that the earlier mentioned idea of combining the
current unit/scale and raw fields is forgotten as that would
again be a restriction in this area and the benefit of that was
rather small in the first place.

---
 src/pmrep/pmrep.1      |  4 ++--
 src/pmrep/pmrep.conf   | 12 ++++++------
 src/pmrep/pmrep.conf.5 | 14 +++++++-------
 src/pmrep/pmrep.py     | 18 +++++++++++-------
 4 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/src/pmrep/pmrep.1 b/src/pmrep/pmrep.1
index 31ac117..eb98d94 100644
--- a/src/pmrep/pmrep.1
+++ b/src/pmrep/pmrep.1
@@ -130,7 +130,7 @@ of a metricspec is defined as follows:
 .in 1.5i
 .ft CW
 .nf
-metric[,label[,instance[,unit/scale[,raw[,width]]]]]
+metric[,label[,instance[,unit/scale[,type[,width]]]]]
 .fi
 .ft R
 .in
@@ -157,7 +157,7 @@ non-raw metrics.
 specifications.)
 By default, cumulative counter metrics are converted to rates.
 If the optional
-.I raw
+.I type
 field is set to
 .B raw
 then this rate conversion is disabled, unit/scale specification is
diff --git a/src/pmrep/pmrep.conf b/src/pmrep/pmrep.conf
index 6103475..ccd2a42 100644
--- a/src/pmrep/pmrep.conf
+++ b/src/pmrep/pmrep.conf
@@ -16,7 +16,7 @@
 #interval = 1s
 #runtime =
 #delay = no
-#raw = no
+#type = default
 #width =
 #precision = 3
 #delimiter =
@@ -30,7 +30,7 @@
 ##includedir =
 
 # Compact metric specifications are of form:
-#pcp.metric.name = label,instance(s),unit/scale,raw,column-width
+#pcp.metric.name = label,instance(s),unit/scale,type,column-width
 
 # Global metrics are displayed as part of any set (unless disabled with -G)
 [global]
@@ -44,7 +44,7 @@ unitinfo = no
 globals = no
 timestamp = yes
 interval = 1s
-raw = no
+type = default
 precision = 2
 sysfork = kernel.all.sysfork
 sysfork.label = proc/s
@@ -60,7 +60,7 @@ unitinfo = no
 globals = no
 timestamp = yes
 interval = 1s
-raw = no
+type = default
 precision = 2
 time_scale = s
 pswpin = mem.vmstat.pswpin
@@ -77,7 +77,7 @@ unitinfo = no
 globals = no
 timestamp = no
 interval = 1s
-raw = no
+type = default
 precision = 0
 repeat_header = 22
 proc.runq.runnable = r,,,,
@@ -115,7 +115,7 @@ steal.formula = 100 * kernel.all.cpu.steal / hinv.ncpu
 [example-1]
 timestamp = yes
 interval = 2s
-raw = no
+type = default
 space_scale = MB
 read = disk.all.read_bytes
 read.width = 6
diff --git a/src/pmrep/pmrep.conf.5 b/src/pmrep/pmrep.conf.5
index 9b8dce4..ce2a20f 100644
--- a/src/pmrep/pmrep.conf.5
+++ b/src/pmrep/pmrep.conf.5
@@ -187,11 +187,12 @@ archive rather than replaying at full speed. 
Corresponding command line
 parameter is \fB-d\fR. Defaults to \fBno\fR.
 .RE
 .P
-raw (bool)
+type (string)
 .RS 4
 Indicates whether to output raw metric values by disabling all rate
-conversions. Corresponding command line parameter is \fB-r\fR. Defaults
-to \fBno\fR.
+conversions or convert cumulative counters to rates (default).
+Corresponding command line parameter is \fB-r\fR. Allowed values are
+\fBdefault\fR or \fBraw\fR.
 .RE
 .P
 width (integer)
@@ -387,12 +388,11 @@ This specifier is currently recognized but not 
implemented.
 .I unit
 Defines the unit/scale conversion for the metric. Needs to be
 dimension-comptatible and is used with non-string and (currently)
-non-raw metrics.
-For allowed values, see
+non-raw metrics. For allowed values, see
 .BR pmrep (3).
 .TP 2
-.I raw
-If set to \fByes\fR rate conversion for the metric will be disabled.
+.I type
+If set to \fBraw\fR rate conversion for the metric will be disabled.
 .TP 2
 .I width
 Defines the width of the output column for the metric.
diff --git a/src/pmrep/pmrep.py b/src/pmrep/pmrep.py
index f60ef6c..c10f405 100644
--- a/src/pmrep/pmrep.py
+++ b/src/pmrep/pmrep.py
@@ -169,7 +169,7 @@ class PMReporter(object):
         # Configuration directives
         self.keys = ('source', 'output', 'derived', 'header', 'unitinfo',
                      'globals', 'timestamp', 'samples', 'interval', 'runtime',
-                     'delay', 'raw', 'width', 'precision', 'delimiter',
+                     'delay', 'type', 'width', 'precision', 'delimiter',
                      'extheader', 'repeat_header', 'timefmt', 'interpol',
                      'count_scale', 'space_scale', 'time_scale', 'version',
                      'zabbix_server', 'zabbix_port', 'zabbix_host', 
'zabbix_interval')
@@ -197,7 +197,7 @@ class PMReporter(object):
         self.opts.pmSetOptionInterval(str(1))
         self.runtime = -1
         self.delay = 0
-        self.raw = 0
+        self.type = 0
         self.width = 0
         self.precision = 3 # .3f
         self.delimiter = None
@@ -212,11 +212,11 @@ class PMReporter(object):
 
         # Performance metrics store
         # key - metric name
-        # values - 0:label, 1:instance(s), 2:unit/scale, 3:rawness, 4:width
+        # values - 0:label, 1:instance(s), 2:unit/scale, 3:type, 4:width
         self.metrics = OrderedDict()
 
         # Corresponding config file metric specifiers
-        self.metricspec = ('label', 'instance', 'unit', 'raw', 'width', 
'formula')
+        self.metricspec = ('label', 'instance', 'unit', 'type', 'width', 
'formula')
 
         self.prevvals = None
         self.currvals = None
@@ -274,6 +274,11 @@ class PMReporter(object):
         elif name == 'interval':
             self.opts.pmSetOptionInterval(value)
             self.interval = self.opts.pmGetOptionInterval()
+        elif name == 'type':
+            if value == 'raw':
+                self.type = 1
+            else:
+                self.type = 0
         else:
             try:
                 setattr(self, name, int(value))
@@ -391,7 +396,7 @@ class PMReporter(object):
         elif opt == 'd':
             self.delay = 1
         elif opt == 'r':
-            self.raw = 1
+            self.type = 1
         elif opt == 'w':
             self.width = int(optarg)
         elif opt == 'P':
@@ -670,8 +675,7 @@ class PMReporter(object):
                 self.metrics[metric][0] = name[:-2] + m
 
             # Rawness
-            if self.metrics[metric][3] == 'raw' or \
-               self.metrics[metric][3] == 'yes' or self.raw == 1:
+            if self.metrics[metric][3] == 'raw' or self.type == 1:
                 self.metrics[metric][3] = 1
             else:
                 self.metrics[metric][3] = 0

Thanks,

-- 
Marko Myllynen

<Prev in Thread] Current Thread [Next in Thread>
  • pmrep: prepare for future enhancements, Marko Myllynen <=