[performancecopilot/pcp] dmcache cannot handle situation where lvmcache is not configured (#115)
Miloš Prchlík <[email protected]>
| Newsgroups | gmane.comp.sysutils.pcp |
|---|---|
| Message-ID | <performancecopilot/pcp/issues/[email protected]> |
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 or view it on GitHub:
https://github.com/performancecopilot/pcp/issues/115
_______________________________________________
pcp mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/pcp