[root@mysql-m-201 ~]# cat feishu.py
#!/usr/bin/python3
import requests
import json
import sys
import os
import datetime
from datetime import datetime
# 你复制的webhook地址粘贴进url内
url = "https://open.feishu.cn/open-apis/bot/v2/hook/530dffcf-09e9-48ae-9748-7ffccb0fd641"
def send_message(message):
payload_message = {
"msg_type": "text",
"content": {
"text": message
}
}
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload_message))
return response
if __name__ == '__main__':
dt = datetime.now()
text = """
标题: jia 服务异常
"""
result = text + dt.strftime('故障时间:%Y年%m月%d日 %H:%M:%S')
send_message(result)
[root@mysql-m-201 ~]# cat test.sh
#!/bin/bash
jia=`curl -X HEAD -I -s http://192.168.17:8081/login.jsp | grep "HTTP/1.1 200"| wc -l`
if [ $jia != 1 ];then
echo "jia 服务异常"
python3 /root/feishu.py
fi
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)