Created
December 22, 2020 13:51
-
-
Save wh13371/3f54db2931470247aeeef7f063656ffd to your computer and use it in GitHub Desktop.
send scs alarm data to Mattermost
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
def send_to_mattermost(mm_url, mm_channel, mm_username, redis_id, redis_data): | |
_text = {'@timestamp': get_now_iso(), | |
'epoch': int(get_epoch()), | |
"condid": int(redis_data.get(b'condid').decode()), | |
"condname": redis_data.get(b'condname').decode(), | |
"conddesc": redis_data.get(b'conddesc').decode(), | |
"msgid": int(redis_data.get(b'msgid').decode()), | |
"msgtext": redis_data.get(b'msgtext').decode(), | |
"appid": int(redis_data.get(b'appid').decode()), | |
"appname": redis_data.get(b'appname').decode(), | |
"hostname": redis_data.get(b'hostname').decode(), | |
"ts": int(redis_data.get(b'epoch').decode()), | |
"redisid": redis_id.decode() | |
} | |
_data = { "channel": mm_channel, | |
"username": mm_username, | |
"text": json.dumps(_text) } | |
headers = {'Content-type': 'application/json'} | |
r = requests.post(mm_url, json=_data, headers=headers) | |
dd("send_to_mattermost", "DEBUG", status=r.status_code, mmdata=_data) | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment