Created
September 27, 2015 17:49
-
-
Save martinrusev/63b0860865e49ed97d2f to your computer and use it in GitHub Desktop.
Amon Notifications Sender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from amon.apps.notifications.generator import generate_notifications | |
from amon.apps.notifications.generator import generate_message | |
from amon.apps.notifications.mail.sender import send_notification_email | |
from amon.apps.notifications.webhooks.sender import send_webhook_notification | |
from amon.apps.notifications.pushover.sender import send_pushover_notification | |
from amon.apps.notifications.victorops.sender import send_victorops_notification | |
from amon.apps.notifications.pagerduty.sender import send_pagerduty_notification | |
from amon.apps.notifications.opsgenie.sender import send_opsgenie_notification | |
from amon.apps.notifications.slack.sender import send_slack_notification | |
from amon.apps.notifications.hipchat.sender import send_hipchat_notification | |
from amon.apps.alerts.models import alerts_history_model | |
def send_notifications(): | |
notifications_to_send = generate_notifications() | |
for n in notifications_to_send: | |
if n.mute != True and n.global_mute != True: | |
send_notification_email(notification=n) | |
send_webhook_notification(notification=n) | |
message = generate_message(notification=n) | |
for thirdparty_noti in n.thirdparty: | |
if thirdparty_noti == 'pushover': | |
send_pushover_notification(message=message) | |
if thirdparty_noti == 'opsgenie': | |
send_opsgenie_notification(message=message) | |
if thirdparty_noti == 'pagerduty': | |
send_pagerduty_notification(notification=n) | |
if thirdparty_noti == 'victorops': | |
send_victorops_notification(notification=n) | |
if thirdparty_noti == 'slack': | |
send_slack_notification(message=message) | |
if thirdparty_noti == 'hipchat': | |
send_hipchat_notification(message=message) | |
alerts_history_model.mark_as_sent(n.trigger['_id']) | |
return notifications_to_send # For the remote command execute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very interesting - based on your taxonomy creating an additional
send_systemhook_notification(message=message)
would fit best - if the user is able to define the name/path of the called endpoint this might be an overall improvement.