diff options
author | Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com> | 2017-11-17 17:49:05 +0100 |
---|---|---|
committer | Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com> | 2017-11-17 17:49:05 +0100 |
commit | d9a6714a3acfcc133936eb1933b83c4fcc828ca6 (patch) | |
tree | 1310765c047ac9dc780b8c053c7e27417ff6c27f /3rd_party/collectd-ves-app/ves_app/normalizer.py | |
parent | 8e44b29f6eca84e41aa8a5f3be5d006340d66d89 (diff) |
VES YAML: Add node VES message definition
Added new YAML configuration, which allows the VES app
to generate the VES messages for guest,host and hypervisor
separately.
- Fix bug in `INDEX-KEY` definition
- Verbose error messages
Change-Id: I1dddcfc79b27dc68249465f287be34519096c546
Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
Diffstat (limited to '3rd_party/collectd-ves-app/ves_app/normalizer.py')
-rw-r--r-- | 3rd_party/collectd-ves-app/ves_app/normalizer.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/3rd_party/collectd-ves-app/ves_app/normalizer.py b/3rd_party/collectd-ves-app/ves_app/normalizer.py index 84de5e33..dcb02f27 100644 --- a/3rd_party/collectd-ves-app/ves_app/normalizer.py +++ b/3rd_party/collectd-ves-app/ves_app/normalizer.py @@ -241,7 +241,7 @@ class CollectdNotification(CollectdData): self.message = message def __repr__(self): - return '{}(host={}, plugin={}, plugin_instance={}, type={},' \ + return '{}(host={}, plugin={}, plugin_instance={}, type={}, ' \ 'type_instance={}, severity={}, message={}, time={})'.format( self.__class__.__name__, self.host, self.plugin, self.plugin_instance, self.type, self.type_instance, @@ -274,7 +274,7 @@ class CollectdValue(CollectdData): self.type, self.type_instance, self.ds_name) def __repr__(self): - return '{}(host={}, plugin={}, plugin_instance={}, type={},' \ + return '{}(host={}, plugin={}, plugin_instance={}, type={}, ' \ 'type_instance={}, ds_name={}, value={}, time={})'.format( self.__class__.__name__, self.host, self.plugin, self.plugin_instance, self.type, self.type_instance, @@ -347,14 +347,15 @@ class ValueItem(Item): # select collectd metric based on SELECT condition metrics = loader.collector.items(select) assert len(metrics) < 2, \ - 'Wrong SELECT condition, selected {} metrics'.format(len(metrics)) + 'Wrong SELECT condition {}, selected {} metrics'.format( + select, len(metrics)) if len(metrics) > 0: item = cls.format_node(value_desc, {'vl': metrics[0], 'system': loader.system}) return loader.construct_object(item) # nothing has been found by SELECT condition, set to DEFAULT value. - assert default is not None, \ - "No metrics selected by SELECT condition and DEFAULT key isn't set" + assert default is not None, "No metrics selected by SELECT condition" \ + " {} and DEFAULT key isn't set".format(select) return default @@ -398,10 +399,10 @@ class ArrayItem(Item): if len(index_keys) > 0: metric_set = set() for metric in metrics: - value_params = {} + value = CollectdValue() for key in index_keys: - value_params[key] = getattr(metric, key) - metric_set.add(CollectdValue(**value_params)) + setattr(value, key, getattr(metric, key)) + metric_set.add(value) metrics = list(metric_set) # build items based on SELECT and/or INDEX-KEY criteria for metric in metrics: @@ -465,7 +466,7 @@ class StripExtraDash(yaml.YAMLObject): @classmethod def from_yaml(cls, loader, node): - return '-'.join([ x for x in node.value.split('-') if len(x) > 0]) + return '-'.join([x for x in node.value.split('-') if len(x) > 0]) class MapValue(yaml.YAMLObject): |