- [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
————————————————
版权声明:本文为CSDN博主「xiangzilong」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_36270681/article/details/124382853