Closed lls275 closed 2 years ago
用下面命令测试一下,貌似 chat_id
一般为负数
export RUST_LOG=trace
export RUST_BACKTRACE=1
# 根据配置发送测试消息,验证通知是否生效
./stat_server -c config.toml --notify-test
用下面命令测试一下,貌似
chat_id
一般为负数export RUST_LOG=trace export RUST_BACKTRACE=1 # 根据配置发送测试消息,验证通知是否生效 ./stat_server -c config.toml --notify-test
❗ServerStatus test msg
按照您所说,可以看到一条消息,不过主机下线就没法警告了
用下面命令测试一下,貌似
chat_id
一般为负数export RUST_LOG=trace export RUST_BACKTRACE=1 # 根据配置发送测试消息,验证通知是否生效 ./stat_server -c config.toml --notify-test
按照您这些命令测试,是可以收到一条 ❗ServerStatus test msg的消息的。不过当主机下线时,面板可以看到主机是红色的,但是就是没法推送到tg上。
我晚点瞧瞧
我晚点瞧瞧
好的,我是根据源码进行编译的。不知是不是源码有问题。我拉取的是最新的源码来编译的
跑一下 systemctl status stat_server -l
帮忙把输出日志贴一下
systemctl status stat_server -l
● stat_server.service - ServerStatus-Rust Server Loaded: loaded (/etc/systemd/system/stat_server.service; disabled; vendor preset: enabled) Active: active (running) since Fri 2022-07-01 03:20:21 UTC; 56s ago Main PID: 1265376 (stat_server) Tasks: 5 (limit: 1066) Memory: 2.3M CGroup: /system.slice/stat_server.service └─1265376 /opt/ServerStatus/stat_server -c /opt/ServerStatus/config.toml
Jul 01 03:20:21 vultr systemd[1]: Started ServerStatus-Rust Server. Jul 01 03:20:21 vultr stat_server[1265376]: ✨ stat_server v1.5.2 GIT:a6aa0f3, BUILD:2022-07-01 02:38:03 UTC Jul 01 03:20:21 vultr stat_server[1265376]: ✨ run in normal mode, load conf from local file `/opt/ServerStatus/config.toml Jul 01 03:20:21 vultr stat_server[1265376]: ✨ admin_user: admin Jul 01 03:20:21 vultr stat_server[1265376]: ✨ admin_pass: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx Jul 01 03:20:21 vultr stat_server[1265376]: 🚀 listening on http://0.0.0.0:8080 Jul 01 03:20:21 vultr stat_server[1265376]: 🚀 listening on grpc://0.0.0.0:9394
试试 https://github.com/zdz/ServerStatus-Rust/releases/tag/v1.5.3
非常棒!c彻底解决了。
不过我想请教一个问题,如果将url指向 /admin/status 代码怎么修改? 我似乎修改了/root/ServerStatus-Rust/server/src/main.rs的req_path,但是前端的css、js跟随者/admin/status一起加上,导致无法加载,这个该怎么修改?
async fn main_service_func(req: Request<Body>) -> Result<Response<Body>> {
let req_path = req.uri().path();
match (req.method(), req_path) {
(&Method::POST, "/report") => stats_report(req).await,
(&Method::GET, "/json/stats.json") => get_stats_json(req).await,
(&Method::GET, "/detail") => http::get_detail(req).await,
(&Method::GET, "/detail_ht") => http::render_jinja_ht_tpl("detail_ht", req).await,
(&Method::GET, "/map") => http::render_jinja_ht_tpl("map", req).await,
(&Method::GET, "/i") => http::init_client(req).await,
(&Method::GET, "/admin/status") | (&Method::GET, "/index.html") => { << == 修改了req_path
if !http::is_admin(&req) {
return Ok(Response::builder()
.header(header::WWW_AUTHENTICATE, "Basic realm=\"Restricted\"")
.status(StatusCode::UNAUTHORIZED)
.body(UNAUTHORIZED.into())?);
}
let body = Body::from(Asset::get("/index.html").unwrap().data);
Ok(Response::builder()
.header(header::CONTENT_TYPE, "text/html; charset=utf-8")
.body(body)?)
}
_ => {
if req.method() == Method::GET
&& (req_path.starts_with("/js/")
|| req_path.starts_with("/css/")
|| req_path.starts_with("/img/")
|| req_path.eq("/config.js")
|| req_path.eq("/favicon.ico"))
{
if let Some(data) = Asset::get(req_path) {
let ct = mime_guess::from_path(req_path);
return Ok(Response::builder()
.header(header::CONTENT_TYPE, ct.first_raw().unwrap())
.body(Body::from(data.data))?);
} else {
error!("can't get => {:?}", req_path);
}
}
// Return 404 not found response.
Ok(Response::builder()
.status(StatusCode::NOT_FOUND)
.body(NOTFOUND.into())?)
}
前端的css请求地址却变成了:https://www.xxx.com/admin/css/semantic.min.css,导致无法获取到css。 我对rust不熟悉,不知怎么修改
不用修改源码,用 nginx 配置重写一下 route 指向就行,或者 参考 https://github.com/zdz/ServerStatus-Rust/discussions/37
不用修改源码,用 nginx 配置重写一下 route 指向就行,或者 参考 #37
好的,已经配置好了。感谢作者
我的配置文件上,配置了tg的信息,并开启了推送功能,但无法推送!
但我通过 curl 方式区测试是正常的,能否告知我出了什么问题?