← 返回题库
中级

实现告警通知渠道路由

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    alerts_csv = open_url(____).read()
    alerts = pd.read_csv(StringIO(____))
    ROUTING = {'____':'____', '____':'____', '____':'____'}
    def route_alert(____):
        return ROUTING.get(____)
    print(____)
    for _, row in alerts.iterrows():
        channel = route_alert(____)
        print("____"+str(____)+"____"+row['____']+"____"+row['____']+"____"+row['____']+"____"+channel)
    print(____)
    for level, channel in ROUTING.items():
        count = len(____)
        print("____"+channel+"____"+str(____)+"____")

示例

输入
solve()
期望输出
Alert notification routing:
  id=1 [critical] ESP-001/vibration_rms -> sms_queue
  id=2 [critical] ESP-002/pressure -> sms_queue
  id=3 [warning] RPI-001/cpu_temp -> email_queue
  id=4 [warning] ARD-001/temperature -> email_queue
  id=5 [warning] ESP-001/vibration_rms -> email_queue
Channel summary:
  email_queue: 3 alerts
  sms_queue: 2 alerts
  phone_queue: 0 alerts
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码