Skip to content

动态注册无法触发TG上下线告警吗 #128

@zxczaq001

Description

@zxczaq001
[tgbot]
# 开关 true 打开
enabled = true
bot_token = "5688616854:AAHd-dbjLc3Ff3F4ErSYk92SdMqwFPh0ob8"
chat_id = "1342176258"
# host 可用字段参见 payload.rs 文件 HostStat 结构, {{host.xxx}} 为占位变量
# 例如 host.name 可替换为 host.alias,大家根据自己的喜好来编写通知消息
# {{ip_info.query}} 主机 ip,  {{sys_info.host_name}} 主机 hostname
title = "❗<b>Server Status</b>"
online_tpl =  "{{config.title}} \n😆 {{host.location}} {{host.name}} 主机恢复上线啦"
offline_tpl = "{{config.title}} \n😱 {{host.location}} {{host.name}} 主机已经掉线啦"
# custom 模板置空则停用自定义告警,只保留上下线通知
custom_tpl = """
{% if host.memory_used / host.memory_total > 0.5  %}
<pre>😲 {{host.name}} 主机内存使用率超50%, 当前{{ (100 * host.memory_used / host.memory_total) | round }}%  </pre>
{% endif %}

{% if host.hdd_used / host.hdd_total  > 0.5  %}
<pre>😲 {{host.name}} 主机硬盘使用率超50%, 当前{{ (100 * host.hdd_used / host.hdd_total) | round }}% </pre>
{% endif %}
"""

Dec 21 17:33:58 GreenCloud.1665472394 systemd[1]: Started ServerStatus-Rust Server.
Dec 21 17:33:58 GreenCloud.1665472394 stat_server[1442]: ✨ stat_server v1.6.1 (, 2022-12-21 09:32:12 UTC, rustc 1.66.0)
Dec 21 17:33:58 GreenCloud.1665472394 stat_server[1442]: ✨ run in normal mode, load conf from local file `/usr/local/ServerSt>
Dec 21 17:33:58 GreenCloud.1665472394 stat_server[1442]: ✨ admin_user: admin
Dec 21 17:33:58 GreenCloud.1665472394 stat_server[1442]: ✨ admin_pass: xxxxxx
Dec 21 17:33:58 GreenCloud.1665472394 stat_server[1442]: 🚀 listening on http://127.0.0.1:8080
Dec 21 17:33:58 GreenCloud.1665472394 stat_server[1442]: 🚀 listening on grpc://0.0.0.0:9394

我用 #60 里面的测试代码会有一条❗️ServerStatus test msg信息 但是服务器上下线没有

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions