def create_notifier_proxy(): STORAGE = RedisStorage(redis, os.getenv('REDISTOGO_URL')) pg_key = os.getenv('PAGERDUTY_KEY') pagerduty_client = PagerDuty(pg_key) notifier_proxy = NotifierProxy() notifier_proxy.add_notifier( PagerdutyNotifier(pagerduty_client, STORAGE)) if 'HIPCHAT_KEY' in os.environ: hipchat = HipchatNotifier(HipChat(os.getenv('HIPCHAT_KEY')), STORAGE) hipchat.add_room(os.getenv('HIPCHAT_ROOM')) notifier_proxy.add_notifier(hipchat) return notifier_proxy
STORAGE = RedisStorage(redis, os.getenv('REDISTOGO_URL')) pg_key = os.getenv('PAGERDUTY_KEY') pagerduty_client = PagerDuty(pg_key) GRAPHITE_URL = os.getenv('GRAPHITE_URL') notifier_proxy = NotifierProxy() notifier_proxy.add_notifier( PagerdutyNotifier(pagerduty_client, STORAGE)) if 'HIPCHAT_KEY' in os.environ: hipchat = HipchatNotifier(HipChat(os.getenv('HIPCHAT_KEY')), STORAGE) hipchat.add_room(os.getenv('HIPCHAT_ROOM')) notifier_proxy.add_notifier(hipchat) ALERT_TEMPLATE = r"""{{level}} alert for {{alert.name}} {{record.target}}. The current value is {{current_value}} which passes the {{threshold_level|lower}} value of {{threshold_value}}. Go to {{graph_url}}. {% if docs_url %}Documentation: {{docs_url}}{% endif %}. """ HTML_ALERT_TEMPLATE = r"""{{level}} alert for {{alert.name}} {{record.target}}. The current value is {{current_value}} which passes the {{threshold_level|lower}} value of {{threshold_value}}. Go to <a href="{{graph_url}}">the graph</a>. {% if docs_url %}<a href="{{docs_url}}">Documentation</a>{% endif %}. """ def description_for_alert(template, alert, record, level, current_value): context = dict(locals())
from pagerduty_notifier import PagerdutyNotifier from redis_storage import RedisStorage STORAGE = RedisStorage(redis, os.getenv('REDISTOGO_URL')) pg_key = os.getenv('PAGERDUTY_KEY') pagerduty_client = PagerDuty(pg_key) GRAPHITE_URL = os.getenv('GRAPHITE_URL') notifier_proxy = NotifierProxy() notifier_proxy.add_notifier(PagerdutyNotifier(pagerduty_client, STORAGE)) if 'HIPCHAT_KEY' in os.environ: hipchat = HipchatNotifier(HipChat(os.getenv('HIPCHAT_KEY')), STORAGE) hipchat.add_room(os.getenv('HIPCHAT_ROOM')) notifier_proxy.add_notifier(hipchat) ALERT_TEMPLATE = r"""{{level}} alert for {{alert.name}} {{record.target}}. The current value is {{current_value}} which passes the {{threshold_level|lower}} value of {{threshold_value}}. Go to {{graph_url}}. {% if docs_url %}Documentation: {{docs_url}}{% endif %}. """ HTML_ALERT_TEMPLATE = r"""{{level}} alert for {{alert.name}} {{record.target}}. The current value is {{current_value}} which passes the {{threshold_level|lower}} value of {{threshold_value}}. Go to <a href="{{graph_url}}">the graph</a>. {% if docs_url %}<a href="{{docs_url}}">Documentation</a>{% endif %}. """ def description_for_alert(template, alert, record, level, current_value):