enh: add dotenv

This commit is contained in:
jiajingbin 2025-01-22 19:18:39 +08:00
parent 98144cee08
commit 79099ffd0e
5 changed files with 38 additions and 18 deletions

View File

@ -0,0 +1,6 @@
EXCLUDE_IP="192.168.1.10"
SERVER_IP="192.168.1.11"
HTTP_SERV_IP="192.168.1.12"
HTTP_SERV_PORT=8080
FEISHU_MSG_URL="https://open.feishu.cn/open-apis/bot/v2/hook/*******"
OWNER="Jayden Jia"

View File

@ -3,14 +3,21 @@ from datetime import timedelta
import os
import re
import requests
from dotenv import load_dotenv
# load .env
load_dotenv()
# define version
version = "3.3.*"
ip = "103.229.218.146"
ip = os.getenv("EXCLUDE_IP")
server_ip = os.getenv("SERVER_IP")
owner = os.getenv("OWNER")
# feishu-msg url
#group_url = 'https://open.feishu.cn/open-apis/bot/v2/hook/56c333b5-eae9-4c18-b0b6-7e4b7174f5c9'
group_url = 'https://open.feishu.cn/open-apis/bot/v2/hook/11e9e452-34a0-4c88-b014-10e21cb521dd'
feishu_msg_url = os.getenv("FEISHU_MSG_URL")
today = date.today()
#today = date(2023,8,7)
path="/data/telemetry/crash-report/"
@ -106,14 +113,14 @@ def print_result():
def send_report():
content = f'''
test scope: Telemetry Statistics
owner: Jayden Jia
ip: 20.124.239.6
owner: {owner}
ip: {server_ip}
from: {get_files().split(" ")[6].split("/")[4].split(".")[0]}
to: {get_files().split(" ")[0].split("/")[4].split(".")[0]}
filter1 result: {get_output(filter1_cmd)}
filter2 result: {get_output(filter2_cmd)}
total crashes: {print_result()}
'''
'''
#send_msg(get_msg(content))
print(content)

View File

@ -5,6 +5,12 @@ import json
import re
import requests
import subprocess
from dotenv import load_dotenv
# load .env
# You should have a .env file in the same directory as this script
# You can exec: cp .env.example .env
load_dotenv()
# define version
version = "3.3.2.*"
@ -13,14 +19,15 @@ version_pattern = re.compile(rf'^{version_pattern_str}$')
version_stack_list = list()
# define ip
ip = "103.229.218.146"
server_ip = "20.124.239.6"
http_ip = "192.168.2.92"
owner = "Jayden Jia"
ip = os.getenv("EXCLUDE_IP")
server_ip = os.getenv("SERVER_IP")
http_serv_ip = os.getenv("HTTP_SERV_IP")
http_serv_port = os.getenv("HTTP_SERV_PORT")
owner = os.getenv("OWNER")
# feishu-msg url
group_url = 'https://open.feishu.cn/open-apis/bot/v2/hook/56c333b5-eae9-4c18-b0b6-7e4b7174f5c9'
# group_url = 'https://open.feishu.cn/open-apis/bot/v2/hook/11e9e452-34a0-4c88-b014-10e21cb521dd'
feishu_msg_url = os.getenv("FEISHU_MSG_URL")
# get today
today = date.today()
@ -221,7 +228,7 @@ def send_msg(json):
'Content-Type': 'application/json'
}
req = requests.post(url=group_url, headers=headers, json=json)
req = requests.post(url=feishu_msg_url, headers=headers, json=json)
inf = req.json()
if "StatusCode" in inf and inf["StatusCode"] == 0:
pass
@ -270,7 +277,7 @@ def send_report(res, sum, html_report_file):
owner: {owner}
result: \n{format_results(res)}\n
total crashes: {sum}\n
details: http://{http_ip}:8000/{html_report_file}
details: http://{http_serv_ip}:{http_serv_port}/{html_report_file}
'''
print(get_msg(content))
send_msg(get_msg(content))

View File

@ -1,8 +1,8 @@
#!/bin/bash
source .env
filesPath="/data/telemetry/crash-report"
version="3.0.4.1"
taosdataIp="103.229.218.146"
taosdataIp=$EXCLUDE_IP
grep "\"version\":\"${version}\"" ${filesPath}/*.txt \
| grep "taosd(" \
| awk -F "stackInfo" '{print $2}' \

View File

@ -1,8 +1,8 @@
#!/bin/bash
source .env
filesPath="/data/telemetry/crash-report"
version="3.0.4.1"
taosdataIp="103.229.218.146"
taosdataIp=$EXCLUDE_IP
grep "\"version\":\"${version}\"" ${filesPath}/*.txt \
| grep "taosd(" \
| awk -F "stackInfo" '{print $2}' \