-
Notifications
You must be signed in to change notification settings - Fork 0
/
alerta_generic_plugin.py
36 lines (32 loc) · 1.84 KB
/
alerta_generic_plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from alerta.plugins import PluginBase
import os.path
class AlertaGenericPlugin(PluginBase):
def __init__(self, name=None):
self.changed = []
super(AlertaGenericPlugin, self).__init__(name)
def pre_receive(self, alert):
if os.path.isfile('/etc/alerta/pre_receive'):
os.system('/etc/alerta/pre_receive %s %s %s %s %s' % (alert.id,
alert.environment,
alert.resource,
alert.event,
alert.severity))
return alert
def post_receive(self, alert):
if alert.id in self.changed and os.path.isfile('/etc/alerta/status_change'):
os.system('/etc/alerta/status_change %s %s %s %s %s' % (alert.id,
alert.environment,
alert.resource,
alert.event,
alert.severity))
self.changed.remove(alert.id)
if os.path.isfile('/etc/alerta/post_receive'):
os.system('/etc/alerta/post_receive %s %s %s %s %s' % (alert.id,
alert.environment,
alert.resource,
alert.event,
alert.severity))
return
def status_change(self, alert, status, text):
self.changed.append(alert.id)
return