Last active
March 23, 2019 03:27
-
-
Save agramajo/68b68f96a6188ff68867a4b746a78685 to your computer and use it in GitHub Desktop.
Xymon slack integration
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
import os | |
import json | |
import urllib2 | |
url = 'https://hooks.slack.com/services/COMPLETE_ENDPOINT_HERE' | |
channel = '#servers' | |
server = os.environ.get('BBHOSTNAME') | |
color = os.environ.get('BBCOLORLEVEL') | |
msg = os.environ.get('BBALPHAMSG') | |
if color == 'red': | |
emoji = ':broken_heart:' | |
elif color == 'yellow': | |
emoji = ':yellow_heart:' | |
elif color == 'purple': | |
emoji = ':purple_heart:' | |
elif color == 'green': | |
emoji = ':green_heart:' | |
else: | |
emoji = ':ghost:' | |
msg = server + ' ' + color + '\n' + msg | |
data = { | |
'channel': channel, | |
'username': 'webhookbot', | |
'text': msg, | |
'icon_emoji': emoji | |
} | |
req = urllib2.Request(url) | |
response = urllib2.urlopen(req,'payload='+json.dumps(data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alerts file config