You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
669 B

import os
from pathlib import Path
import slack
slack_token = os.environ.get("SLACK_BOT_TOKEN")
client = slack.WebClient(token=os.environ['SLACK_BOT_TOKEN'])
def post_to_slack(message_list):
if message_list:
client.chat_postMessage(
channel = "#bots-like-gaston",
text = message_list
)
def react_to_monitoring():
results_file = Path("/shared/alerts.log")
if results_file.is_file():
open_file = open("/shared/alerts.log", "r")
for line in open_file:
post_to_slack(line)
os.remove("/shared/alerts.log")
if __name__ == '__main__':
while True:
react_to_monitoring()