6 个版本
0.3.0 | 2024年6月24日 |
---|---|
0.2.0 | 2024年6月20日 |
0.1.3 | 2024年6月4日 |
0.1.2 | 2024年3月11日 |
0.1.1 | 2024年2月16日 |
292 在 网络编程
每月 332 次下载
52KB
468 行
远程系统监控器
这是一个小型命令行工具,它会在远程服务器上执行一些检查,并将结果发布到 Slack 频道。
请访问 项目网站 以获取可用的完整 检查列表 及其配置方法。
TL;DR
安装
确保您已安装 Rust 和 Cargo,如果没有,请按照 此处 的说明进行操作。
cargo install remotesysmonitor
执行
查看 remotesysmonitor --help
命令的输出,以获取可用选项列表。
$ remotesysmonitor -h
Usage: remotesysmonitor [OPTIONS] <CONFIG>
Arguments:
<CONFIG>
Options:
-f, --full Post a check to Slack even if there is no ❌ in the checks
-p, --print Print the output of the checks in stdout
-h, --help Print help
-V, --version Print version
您需要将 SLACK_HOOK_URL
定义为环境变量,包含您要使用的 Slack webhook 的 URL 和配置文件的路径。
SLACK_HOOK_URL=<your-slack-hook-url> remotesysmonitor configuration.yaml
配置文件应如下所示
servers:
- name: name-of-your-server
host: myserver.nl
port: 22
user: rodrigo
private_key: /home/rodrigo/.ssh/id_ed25519
checks:
ping:
url:
- /
load:
interval: 15
number_of_subfolders:
path:
- /path/full/of/subfolders
custom_command:
command: cd /some/path && ./some_script.sh
list_old_directories:
loc: /path/full/of/old/directories
cutoff: 2 # days
- name: raspberryPi
host: ip.of.your.raspberry.pi
port: 22
user: rodrigo
private_key: /home/rodrigo/.ssh/id_ed25519
checks:
temperature:
sensor: /sys/bus/w1/devices/28-00000b694311/w1_slave
可能需要配置 cron 作业定期运行此命令。
# Run every 10 minutes, it will only post to Slack if one of the checks has ❌
*/10 * * * * SLACK_HOOK_URL=<your-slack-hook-url> remotesysmonitor configuration.yaml
# Post a full report to Slack at 8, 12, 16 and 20 hours
## Running with -f will post to Slack even if there is no ❌ in the checks
0 8,12,16,20 * * * SLACK_HOOK_URL=<your-slack-hook-url> remotesysmonitor -f configuration.yaml
开发
有一个 VSCode 的 .devcontainer
配置,您可以使用它来开发项目。它将设置一个开发环境,并配置一个 SSH 服务器来测试需要远程服务器的检查。
一旦进入 dev-container,您可以根据需要调整 conf/conf.dev.yaml
文件,并通过以下方式运行项目:
SLACK_HOOK_URL="" cargo run -- -p conf/conf.dev.yaml
依赖项
~27–41MB
~748K SLoC