fix mapping to create an alarm on a resource other then host
e.g a network interface attached to a host Implements: blueprint collectd-datasource Change-Id: Ib9133fb4b9738daeb49fd86085d63a76a26b0b65
This commit is contained in:
parent
5237b7193a
commit
fdb88a550d
22
etc/vitrage/datasources_values/network.interface.yaml
Normal file
22
etc/vitrage/datasources_values/network.interface.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
category: RESOURCE
|
||||
values:
|
||||
- aggregated values:
|
||||
priority: 40
|
||||
original values:
|
||||
- name: DELETED
|
||||
operational_value: DELETED
|
||||
- aggregated values:
|
||||
priority: 30
|
||||
original values:
|
||||
- name: ERROR
|
||||
operational_value: ERROR
|
||||
- aggregated values:
|
||||
priority: 20
|
||||
original values:
|
||||
- name: SUBOPTIMAL
|
||||
operational_value: SUBOPTIMAL
|
||||
- aggregated values:
|
||||
priority: 10
|
||||
original values:
|
||||
- name: available
|
||||
operational_value: OK
|
@ -53,7 +53,7 @@ class TemplateApis(object):
|
||||
|
||||
def show_template(self, ctx, template_uuid):
|
||||
|
||||
LOG.debug("Show template with uuid: $s", str(template_uuid))
|
||||
LOG.debug("Show template with uuid: %s", str(template_uuid))
|
||||
|
||||
template = self.templates[template_uuid]
|
||||
|
||||
|
@ -85,7 +85,7 @@ class VitrageNotifier(CollectDPlugin):
|
||||
payload = {
|
||||
'host': notification.host,
|
||||
'plugin': notification.plugin,
|
||||
'type': notification.type,
|
||||
'collectd_type': notification.type,
|
||||
'message': notification.message,
|
||||
'severity': severity,
|
||||
'time': notification.time,
|
||||
|
@ -79,8 +79,12 @@ class CollectdDriver(AlarmDriverBase):
|
||||
event[DSProps.EVENT_TYPE] = event_type
|
||||
|
||||
if CollectdDriver.conf_map:
|
||||
collectd_host = event[CProps.HOST]
|
||||
v_resource = CollectdDriver.conf_map[collectd_host]
|
||||
# PLUGIN_INSTANCE is optional
|
||||
resources = [event[CProps.HOST], event[CProps.PLUGIN],
|
||||
event.get(CProps.PLUGIN_INSTANCE)]
|
||||
resource = '/'.join([resource for resource in resources if
|
||||
resource])
|
||||
v_resource = CollectdDriver.conf_map[resource]
|
||||
event[CProps.RESOURCE_NAME] = v_resource[CProps.RESOURCE_NAME]
|
||||
event[CProps.RESOURCE_TYPE] = v_resource[CProps.RESOURCE_TYPE]
|
||||
|
||||
|
@ -20,4 +20,7 @@ class CollectdProperties(object):
|
||||
TIME = 'time'
|
||||
MESSAGE = 'message'
|
||||
HOST = 'host'
|
||||
PLUGIN = 'plugin'
|
||||
PLUGIN_INSTANCE = 'plugin_instance'
|
||||
TYPE_INSTANCE = 'type_instance'
|
||||
ID = 'id'
|
||||
|
@ -57,6 +57,7 @@ class CollectdTransformer(AlarmTransformerBase):
|
||||
metadata = {
|
||||
VProps.NAME: entity_event[CProps.MESSAGE],
|
||||
VProps.SEVERITY: entity_event[CProps.SEVERITY],
|
||||
VProps.RAWTEXT: self.generate_raw_text(entity_event)
|
||||
}
|
||||
|
||||
return graph_utils.create_vertex(
|
||||
@ -101,3 +102,10 @@ class CollectdTransformer(AlarmTransformerBase):
|
||||
|
||||
def get_type(self):
|
||||
return COLLECTD_DATASOURCE
|
||||
|
||||
@staticmethod
|
||||
def generate_raw_text(entity_event):
|
||||
resources = [entity_event.get(CProps.TYPE_INSTANCE),
|
||||
entity_event[CProps.PLUGIN],
|
||||
entity_event.get(CProps.PLUGIN_INSTANCE)]
|
||||
return '-'.join([resource for resource in resources if resource])
|
||||
|
Loading…
Reference in New Issue
Block a user