2017-09-17 14:56:55 +00:00
|
|
|
|
2016-09-15 09:16:11 +00:00
|
|
|
import logging
|
2016-09-05 20:34:36 +00:00
|
|
|
|
|
|
|
from alerta.plugins import PluginBase
|
|
|
|
|
2016-09-15 09:16:11 +00:00
|
|
|
LOG = logging.getLogger('alerta.plugins.normalise')
|
|
|
|
|
2016-09-05 20:34:36 +00:00
|
|
|
|
|
|
|
class NormaliseAlert(PluginBase):
|
|
|
|
|
|
|
|
def pre_receive(self, alert):
|
2016-09-15 09:16:11 +00:00
|
|
|
|
|
|
|
LOG.info("Normalising alert...")
|
|
|
|
|
2016-11-21 22:09:22 +00:00
|
|
|
# prepend severity to alert text
|
2016-09-05 20:34:36 +00:00
|
|
|
alert.text = '%s: %s' % (alert.severity.upper(), alert.text)
|
2016-09-15 09:16:11 +00:00
|
|
|
|
2016-11-21 22:09:22 +00:00
|
|
|
# supply different default values if missing
|
|
|
|
if not alert.group or alert.group == 'Misc':
|
|
|
|
alert.group = 'Unknown'
|
|
|
|
if not alert.value or alert.value == 'n/a':
|
|
|
|
alert.value = '--'
|
|
|
|
|
2016-09-05 20:34:36 +00:00
|
|
|
return alert
|
|
|
|
|
|
|
|
def post_receive(self, alert):
|
|
|
|
return
|
|
|
|
|
|
|
|
def status_change(self, alert, status, text):
|
|
|
|
return
|