Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zxczaq001 opened this issue Dec 21, 2022 · 9 comments
Closed

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

zxczaq001 opened this issue Dec 21, 2022 · 9 comments

Comments

@zxczaq001
Copy link

zxczaq001 commented Dec 21, 2022

[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信息 但是服务器上下线没有

@zdz
Copy link
Owner

zdz commented Dec 21, 2022

这个值要改大一些,至少比 notify_interval 大,可以改成 604800 秒 (7 天)

# 动态注册模式下,无效数据清理间隔,默认 30s
group_gc = 30

@zxczaq001
Copy link
Author

修改了之后 下线等了一段时间好像还没有通知 网页还是可以看到下线后的服务器信息 我用的1.57的web和main.rs覆盖后编译的这个是否有影响

@zdz
Copy link
Owner

zdz commented Dec 21, 2022

应该没有,有空我看看

@zxczaq001
Copy link
Author

image
这值设置大后 windows的重开一次不会在原有的上线是重新开一个 linux没试不知道会不会这样

@zdz
Copy link
Owner

zdz commented Dec 21, 2022

逻辑就是这个,动态注册每次启动当一个新主机
#66
简单处理 systemctl restart stat_server 或 调低 group_gc 时间自动清理掉

@zxczaq001
Copy link
Author

好 那只能设置低点了 我还以为能原地上线 告警不生效起码看一眼就知道

@zdz
Copy link
Owner

zdz commented Jan 5, 2023

测试了,下线是有告警的,但是由于 #66 使用启动时间来生成 系统 id,导致主机如果宕机重启后会生成一个新的 id,前后 id 对不上,无法发送恢复上线的通知,需要更换一种稳定生成系统 id 方法

@zxczaq001
Copy link
Author

我的锅 没设置好 可以收到下线通知了 现在就你说的重启后无法收到上线问题而已了

@zdz
Copy link
Owner

zdz commented Jan 28, 2023

可以试试 v1.6.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants