中级
实现单指标阈值告警触发
未完成
中级参考
代码结构已给出,请填写 ____ 处
def solve():
from pyodide.http import open_url
from io import StringIO
import pandas as pd
st_csv = open_url(____).read()
alerts_csv = open_url(____).read()
st = pd.read_csv(StringIO(____))
alerts = pd.read_csv(StringIO(____))
ranges = {r['____']:(____) for _,r in st.iterrows()}
def check_threshold(____):
if metric not in ranges: return None
lo, hi = ranges[metric]
if value > hi: return {'____':'____','____':device_id,'____':metric,'____':value,'____':hi}
if value < lo: return {'____':'____','____':device_id,'____':metric,'____':value,'____':lo}
return None
test_readings = [
(____),(____),(____),
(____),(____),
]
print(____)
for did, metric, value in test_readings:
alert = check_threshold(____)
if alert:
print("____"+did+"____"+metric+"____"+str(____)+"____"+str(____))
else:
print("____"+did+"____"+metric+"____"+str(____))
print("____"+str(len(____)))
示例
输入
solve()
期望输出
Threshold alerts: OK ESP-001/vibration_rms=18.7 ALERT ESP-002/pressure=1210.0 threshold=1200.0 OK RPI-001/cpu_temp=88.0 OK ARD-001/temperature=25.0 OK RPI-003/cpu_temp=55.0 Existing alerts: 5
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199