update README

This commit is contained in:
lollipopkit 2023-07-17 14:48:46 +08:00
parent 4940976a5f
commit 4c2d565aa9
5 changed files with 2 additions and 346 deletions

View File

@ -33,30 +33,7 @@ It is a part of [ServerBox](https://github.com/lollipopkit/flutter_server_box) p
</table>
## 📖 Usage
1. There are serveral ways to install it.
- `Docker`:
- (Recommonded) [Docker compose](docker-compose.yaml)
- Or `docker run -d --name srvbox -v ./config:/root/.config/server_box lollipopkit/srvbox_monitor:latest`
- (Optional) If you need to update it, `docker rm srvbox -f && docker rmi lollipopkit/srvbox_monitor:latest` to delete old image. And then run the command above.
- Use binary.
- If you have `go` installed, you can run `go install github.com/lollipopkit/server_box_monitor@latest`
- If you don't have `go` installed, you can download the binary from [release page](https://github.com/lollipopkit/server_box_monitor/releases)
- (Recommended) Config `systemd` to run the app.
- Example service file [here](doc/srvbox.service)
- Rootless
- Copy file to `~/.config/systemd/user/srvbox.service`
- Run `systemctl --user enable --now srvbox`
- You can run `sudo loginctl enable-linger $USER` to make the servicerun after logout
- Rootful
- Copy file to `/etc/systemd/system/srvbox.service`
- Uncomment `User` in the file
- Run `systemctl enable --now srvbox`
2. Edit the config file.
- The config file is located at
- binary: `~/.config/server_box/config.json`
- docker: `./config/config.json`
- Fully example is [here](doc/CONFIG.jsonc)
Please goto [Wiki](https://github.com/lollipopkit/server_box_monitor/wiki) for more information.
## 🔖 License
`GPL v3. lollipopkit 2023`

View File

@ -32,29 +32,7 @@
</table>
## 📖 使用方法
1. 这里有多种方式安装.
- `Docker`:
- (推荐) [Docker compose](docker-compose.yaml)
- 或者 `docker run -d --name srvbox -v ./config:/root/.config/server_box lollipopkit/srvbox_monitor:latest`
- 如果要更新, 先执行 `docker rm srvbox -f && docker rmi lollipopkit/srvbox_monitor:latest` 来删除旧的镜像.
- 可执行文件.
- 如果你有安装 `go`, `go install github.com/lollipopkit/server_box_monitor@latest`
- 或者从 [发布](https://github.com/lollipopkit/server_box_monitor/releases) 下载
- (推荐) 使用 `systemd` 来运行.
- 示例文件在 [这里](doc/srvbox.service),请阅读文件中的注释!
- 非 root
- 复制示例文件到 `~/.config/systemd/user/srvbox.service`
- `systemctl --user enable --now srvbox`
- `sudo loginctl enable-linger $USER` 让服务在注销后继续运行.
- root
- 复制示例文件到 `/etc/systemd/system/srvbox.service`
- 取消 `User` 行注释
- `systemctl enable --now srvbox`
2. 修改配置.
- 配置文件在
- 二进制: `~/.config/server_box/config.json`
- docker: `./config/config.json`
- 完整配置模版在 [这里](doc/CONFIG.jsonc)
请前往 [Wiki](https://github.com/lollipopkit/server_box_monitor/wiki/%E4%B8%BB%E9%A1%B5) 获取更多信息.
## 🔖 许可证
`GPL v3. lollipopkit 2023`

View File

@ -1,143 +0,0 @@
{
"version": 2,
// Interval of checking
// Valid formats: 1s 1m 1h
// Default: 30s
// Values less than 10s will be ignored
"interval": "1m",
// Rate limiter for msg push
// eg: 3/1m (3 times every minute), 1/10s (1 time every 10 seconds)
"rate": "1/10s",
// Name of this host
"name": "Server 1",
// Check rules
//
// Type:
// cpu, mem, net, disk, temp (temperature), swap
//
// Threshold:
// format: COMPARE_OPERATOR VALUE UNIT
// COMPARE_OPERATOR: >, >=, <, <=, =
// VALUE: int/float: 0.1 1 1.1
// UNIT: % (percent), m/s (speed), m (size), c (celsius)
// Speed only valid in per second: b/s k/s, m/s, g/s ...
//
// Matcher:
// cpu: cpu, cpu0, 1, 2, 3, ...
// mem: free, used, avail
// net: eth0, eth1-in, docker-out, ...
// disk: /, /home, /dev/sda1, ...
// temp: x86_pkg_temp, x86_core_temp, ...
// swap: free, used
"rules": [
{
"type": "cpu",
"threshold": ">=77.7%",
// "" / "cpu" -> all cpus, in this case, you can omit attribute "matcher"
// "X" / "cpuX" -> NO.X cpu
"matcher": "0"
},
{
"type": "net",
// speed only support per second
"threshold": ">=7.7m/s",
// network interface name
"matcher": "eth0"
},
{
"type": "temp",
// temperature only support celsius
"threshold": ">=37.7c",
// you can run `cat /sys/class/thermal/thermal_zone*/type` to get all thermal types
"matcher": "x86_pkg_temp"
},
{
"type": "disk",
"threshold": ">=77.7%",
// mount point or filesystem
// you can use `df -h` to get all valid matchers
"matcher": "/dev/sda1"
},
{
"type": "mem",
// support: size, percent
"threshold": "<=17.7%",
// support: free, used, avail
"matcher": "free"
},
{
"type": "swap",
// support: size, percent
"threshold": ">=37.7%",
// support: free, used
"matcher": "used"
}
],
// Push rules
//
// type: webhook, ios, serverchan (more to come)
// iface: interface for the push type
// body_regex: regex to match the response body
// code: response code to match
//
// Format args:
// "{{msg}}" will be replaced with the message of the check result
"pushes": [
{
// This is a example for QQ Group message
"type": "webhook",
"iface": {
"name": "QQ Group",
// Webhook url
"url": "http://localhost:5700",
// Headers for the request
"headers": {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
// UPPERCASED HTTP method
"method": "POST",
// Body for the request
// {{key}} and {{value}} will be replaced with the key and value of the check result
"body": {
"action": "send_group_msg",
"params": {
"group_id": 123456789,
"message": "Server name\n{{msg}}"
}
},
// Check push is successful or not:
// Will skip if not set or empty
//
// If the response body matches the regex, the push is considered successful
"body_regex": ".*",
// If the response code equals, the push is considered successful
"code": 200
}
},
{
"type": "ios",
"iface": {
"name": "ServerBox iOS App",
// You can get it from settings page of ServerBox iOS app
"token": "YOUR_TOKEN",
"title": "Server name",
"content": "{{msg}}",
"body_regex": ".*",
"code": 200
}
},
{
"type": "server_chan",
"iface": {
"name": "ServerChan",
// Details please refer to https://sct.ftqq.com/
"sckey": "YOUR_SCKEY",
"title": "Server Notification",
"desp": "{{msg}}",
"body_regex": ".*",
"code": 200
}
}
]
}

View File

@ -1,141 +0,0 @@
{
"version": 2,
// 时间间隔,用于推送
// 有效格式: 1s 1m 1h
// 默认: 30s
// 小于 10s 的值将被忽略
"interval": "30s",
// 推送速率限制
// 示例: 3/1m (每分钟三次), 1/10s (10秒一次)
"rate": "1/10s",
// 本机名称
"name": "Server 1",
// 监测规则
// 可用类型(type): cpu, mem, net, disk, temp (温度), swap
//
// 阈值(Threshold)
// 格式: 比较符号 值 单位
// 比较符号: >, >=, <, <=, =
// 值: int/float: 0.1 1 1.1
// 单位: % (百分比), m/s (速度), m (大小), c (摄氏度)
// 速度仅支持以秒为单位: b/s k/s, m/s, g/s ...
//
// 匹配器:
// cpu: cpu, cpu0, 1, 2, 3, ...
// mem: free, used, avail
// net: eth0, eth1-in, docker-out, ...
// disk: /, /home, /dev/sda1, ...
// temp: x86_pkg_temp, x86_core_temp, ...
// swap: free, used
"rules": [
{
"type": "cpu",
"threshold": ">=77.7%",
// "" / "cpu" -> 所有CPU, 这种情况下, 你可以省略该规则的 "matcher" 属性
// "X" / "cpuX" -> 第X个CPU
"matcher": "0"
},
{
"type": "net",
// 速度仅支持以秒为单位
"threshold": ">=7.7m/s",
// 网络接口名
"matcher": "eth0"
},
{
"type": "temp",
// 温度仅支持摄氏度
"threshold": ">=37.7c",
// 你可以运行 `cat /sys/class/thermal/thermal_zone*/type` 来获取所有的温度类型
"matcher": "x86_pkg_temp"
},
{
"type": "disk",
"threshold": ">=77.7%",
// 挂载点或文件系统
// 你可以使用 `df -h` 来获取所有有效的匹配器
"matcher": "/dev/sda1"
},
{
"type": "mem",
// 支持: 大小, 百分比
"threshold": "<=17.7%",
// 支持: free, used, avail
"matcher": "free"
},
{
"type": "swap",
// 支持: 大小, 百分比
"threshold": ">=37.7%",
// 支持: free, used
"matcher": "used"
}
],
// 推送规则
//
// 类型 type: webhook, ios, server酱 (以后有更多)
// 接口 iface: 推送类型的接口
// body_regex: 正则表达式匹配响应体
// code: 响应码匹配
//
// 格式化参数:
// "{{msg}}" 将被替换为监测结果的消息
"pushes": [
{
// 这是一个推送到QQ群的例子
"type": "webhook",
"iface": {
"name": "QQ Group",
// web钩子链接
"url": "http://localhost:5700",
// 请求头
"headers": {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
// 大写的HTTP方法
"method": "POST",
// 请求体
// {{key}} 和 {{value}} 将被替换为监测结果的key和value
"body": {
"action": "send_group_msg",
"params": {
"group_id": 123456789,
"message": "服务器1 提示\n{{msg}}"
}
},
// 推送校验:
// 如果 regex 和 code 未空,将不会检查响应体和响应码
//
// 如果响应体匹配,推送将被认为成功
"body_regex": ".*",
// 如果响应码匹配,推送将被认为成功
"code": 200
}
},
{
"type": "ios",
"iface": {
"name": "ServerBox iOS App",
// 你可以从 ServerBox iOS app 的 设置 中获取 token
"token": "YOUR_TOKEN",
"title": "服务器1 提示",
"content": "{{msg}}",
"body_regex": ".*",
"code": 200
}
},
{
"type": "server_chan",
"iface": {
"name": "Server酱",
// 具体配置请参考 https://sct.ftqq.com/
"sckey": "YOUR_SCKEY",
"title": "服务器1 提示",
"desp": "{{msg}}",
"body_regex": ".*",
"code": 200
}
}
]
}

View File

@ -1,15 +0,0 @@
[Unit]
Description=ServerBox Monitor Service
After=network.target
[Service]
Type=simple
# Uncomment the following line to run as a specific user
# User=root
Restart=on-failure
RestartSec=5s
ExecStart=/usr/bin/server_box_monitor
WorkingDirectory=/home/xxx/.config/server_box
[Install]
WantedBy=default.target