pcp
[Top] [All Lists]

pmrep: handle multiple instances with pmi

To: pcp developers <pcp@xxxxxxxxxxx>
Subject: pmrep: handle multiple instances with pmi
From: Marko Myllynen <myllynen@xxxxxxxxxx>
Date: Tue, 15 Dec 2015 16:11: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
I don't see PMI_ERR_DUPINSTNAME being available on the Python side
(like it is on the Perl side) so use the hard coded number for now
and switch to PMI_ERR_DUPINSTNAME once there.

This is a must-have in order to deal with metrics sharing indom.

---
 src/pmrep/pmrep.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/pmrep/pmrep.py b/src/pmrep/pmrep.py
index ca696ff..588386b 100644
--- a/src/pmrep/pmrep.py
+++ b/src/pmrep/pmrep.py
@@ -1178,8 +1178,12 @@ class PMReporter(object):
                                       self.descs[i].contents.sem,
                                       self.descs[i].contents.units)
                 ins = 0 if self.insts[i][0][0] == PM_IN_NULL else 
len(self.insts[i][0])
-                for j in range(ins):
-                    self.log.pmiAddInstance(self.descs[i].contents.indom, 
self.insts[i][1][j], self.insts[i][0][j])
+                try:
+                    for j in range(ins):
+                        self.log.pmiAddInstance(self.descs[i].contents.indom, 
self.insts[i][1][j], self.insts[i][0][j])
+                except pmi.pmiErr as error:
+                    if error.args[0] == -20003: # PMI_ERR_DUPINSTNAME
+                        continue
 
         # Add current values
         data = 0

Thanks,

-- 
Marko Myllynen

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