pcp
[Top] [All Lists]

pmrep: fix reporting of the first sample

To: pcp developers <pcp@xxxxxxxxxxx>
Subject: pmrep: fix reporting of the first sample
From: Marko Myllynen <myllynen@xxxxxxxxxx>
Date: Mon, 18 Jan 2016 11:27:11 +0200
Delivered-to: pcp@xxxxxxxxxxx
Organization: Red Hat
Reply-to: Marko Myllynen <myllynen@xxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0
Not sure what happened here, I guess I was much too focused on
cumulative counters and those earlier seen archive issues that
I became blind to this.

When reporting rate, the first output is N/A as rate can't be
calculated yet. But for everything else the value should be
printed already for the first sample.

(I didn't adjust QA yet, getting QA going on here is pretty
much next on my todo list.)

---
 src/pmrep/pmrep.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/pmrep/pmrep.py b/src/pmrep/pmrep.py
index a885e2d..e04e23a 100644
--- a/src/pmrep/pmrep.py
+++ b/src/pmrep/pmrep.py
@@ -1231,15 +1231,15 @@ class PMReporter(object):
                 k += 1
 
                 # Raw or rate
-                if not self.metrics[metric][3] and \
-                  (self.prevvals == None or list(self.prevvals[i])[j][2] == 
NO_VAL):
-                    # Rate not yet possible
-                    value = NO_VAL
-                elif self.metrics[metric][3] or \
+                if self.metrics[metric][3] or \
                   self.descs[i].sem != PM_SEM_COUNTER or \
                   list(values[i])[j][2] == NO_VAL:
                     # Raw
                     value = list(values[i])[j][2]
+                elif not self.metrics[metric][3] and \
+                  (self.prevvals == None or list(self.prevvals[i])[j][2] == 
NO_VAL):
+                    # Rate not yet possible
+                    value = NO_VAL
                 else:
                     # Rate
                     scale = 1

Thanks,

-- 
Marko Myllynen

<Prev in Thread] Current Thread [Next in Thread>