pcp
[Top] [All Lists]

[performancecopilot/pcp] dmcache cannot handle situation where lvmcache

To: performancecopilot/pcp <pcp@xxxxxxxxxxxxxxxxxx>
Subject: [performancecopilot/pcp] dmcache cannot handle situation where lvmcache is not configured (#115)
From: MiloÅ PrchlÃk <notifications@xxxxxxxxxx>
Date: Wed, 21 Sep 2016 06:39:46 -0700
Delivered-to: pcp@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=github.com; h=from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:list-id:list-archive:list-post:list-unsubscribe; s=s20150108; bh=AhzVrHHwLPTEW+0pZQdRgasbpDg=; b=L2ZTjscFe5eWQSyk RJQf5jf4naNcB6EFPm+fuoFNyCwtFOVI4rOfF9tKt+cr8iNVD17xebkctciwDQ9G GIj0Vf2KLxSw6QwPXs+qi2uZwTGBtzw+/j1o7yoZotvCzKrKPu5n/PjEq8V2RhHP Rn1B8TOmb3+QRf57yhRuE6cTCS4=
List-archive: https://github.com/performancecopilot/pcp
List-id: performancecopilot/pcp <pcp.performancecopilot.github.com>
List-post: <mailto:reply+00bd08b6aa3359df35aa6c0ed995720c6cd0de0b0bd3a6ce92cf0000000113fa4fa292a169ce0aa166c6@reply.github.com>
List-unsubscribe: <mailto:unsub+00bd08b6aa3359df35aa6c0ed995720c6cd0de0b0bd3a6ce92cf0000000113fa4fa292a169ce0aa166c6@reply.github.com>, <https://github.com/notifications/unsubscribe/AL0IthDEw-B1DJM16iUHMnypGou1hkvQks5qsTOigaJpZM4KCz6_>
Reply-to: performancecopilot/pcp <reply+00bd08b6aa3359df35aa6c0ed995720c6cd0de0b0bd3a6ce92cf0000000113fa4fa292a169ce0aa166c6@xxxxxxxxxxxxxxxx>

Without having any LVM cache set up command pcp dmcache leads to a traceback:

[root@foo ~]# pcp dmcache
Traceback (most recent call last):
  File "/usr/libexec/pcp/bin/pcp-dmcache", line 166, in <module>
    manager.run()
  File "/usr/lib64/python2.7/site-packages/pcp/pmcc.py", line 639, in run
    self._printer.report(self)
  File "/usr/libexec/pcp/bin/pcp-dmcache", line 137, in report
    max_lv = max_lv_length(group)
  File "/usr/libexec/pcp/bin/pcp-dmcache", line 82, in max_lv_length
    return len(max(lv_names, key=len))
ValueError: max() arg is an empty sequence
[root@foo ~]# 

Running pminfo -f dmcache reports (correctly) no values for dmcache metrics. The issue lies in formatting code, method max_lv_length expects there are always some data for dmcache available, and does not handle situation there are no data for key dmcache.cache.used. Very direct patch leads to a correct output (header + repeating lines of "No values available") but maybe a more sophisticated patch would be more appropriate.

diff --git a/src/pcp/dmcache/pcp-dmcache.py b/src/pcp/dmcache/pcp-dmcache.py
index a606eb1..ac243ca 100755
--- a/src/pcp/dmcache/pcp-dmcache.py
+++ b/src/pcp/dmcache/pcp-dmcache.py
@@ -78,6 +78,8 @@ def cache_dict(group, metric):
 def max_lv_length(group):
     """ look at the observation group and return the max length of all the lvnames """
     cache_used = cache_dict(group, 'dmcache.cache.used')
+    if not cache_used:
+        return 0
     lv_names = cache_used.keys()
     return len(max(lv_names, key=len))


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

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