Files
pt-disk-report/README.md
2026-02-22 20:55:05 +08:00

147 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PT System Checking - 磁盘状态监控服务
一个轻量级的系统磁盘监控服务,定期检查磁盘可用空间并上报到指定服务器。
## 功能特性
- 自动检测所有非可移动磁盘的可用空间
- 定期上报磁盘状态到远程服务器
- 支持通过环境变量或命令行参数配置
- 支持 amd64 和 arm64 架构(适用于香橙派 Zero3
- 一键部署脚本,自动配置 systemd 服务
## 快速开始
### 一键部署(推荐)
在目标设备上运行以下命令:
```bash
curl -fsSL https://gitea.service.jazzwhom.top/Passthem/pt-disk-report/raw/branch/main/install.sh | sudo bash
```
或者下载后运行:
```bash
wget https://gitea.service.jazzwhom.top/Passthem/pt-disk-report/raw/branch/main/install.sh
sudo bash install.sh
```
安装脚本会:
1. 自动检测系统架构amd64/arm64
2. 从 Gitea Releases 下载对应的二进制文件
3. 交互式配置服务参数(服务器 URL、检查间隔、日志级别
4. 安装并启动 systemd 服务
### 更新服务
```bash
curl -fsSL https://gitea.service.jazzwhom.top/Passthem/pt-disk-report/raw/branch/main/update.sh | sudo bash
```
或者下载后运行:
```bash
wget https://gitea.service.jazzwhom.top/Passthem/pt-disk-report/raw/branch/main/update.sh
sudo bash update.sh
```
更新脚本会:
1. 检查当前安装的版本
2. 获取最新版本信息
3. 自动备份当前版本
4. 下载并替换新版本
5. 重启服务(如果更新失败会自动恢复备份)
### 卸载服务
```bash
sudo bash install.sh uninstall
```
## 本地构建
### 安装交叉编译工具链
```bash
make install-targets
```
### 构建所有架构
```bash
make release
```
### 准备发布文件
```bash
make prepare-release
```
这会在 `release/` 目录生成:
- `pt_system_checking-amd64` - x86_64 架构二进制文件
- `pt_system_checking-arm64` - ARM64 架构二进制文件(适用于香橙派 Zero3
- `install.sh` - 一键部署脚本
- `update.sh` - 一键更新脚本
## 配置说明
服务支持以下配置项(通过环境变量):
- `PT__SERVER_URL` - 服务器 URL用于上报磁盘状态
- `PT__INTERVAL` - 检查间隔(秒,默认 300
- `PT__LOG_LEVEL` - 日志级别trace/debug/info/warn/error默认 info
## 服务管理
安装后可使用以下命令管理服务:
```bash
# 查看服务状态
systemctl status pt_system_checking
# 查看实时日志
journalctl -u pt_system_checking -f
# 停止服务
systemctl stop pt_system_checking
# 启动服务
systemctl start pt_system_checking
# 重启服务
systemctl restart pt_system_checking
# 禁用开机自启
systemctl disable pt_system_checking
```
## 手动安装
如果不使用一键脚本,可以手动安装:
1. 下载对应架构的二进制文件
2. 复制到 `/opt/pt_system_checking/`
3. 创建 systemd 服务文件 `/etc/systemd/system/pt_system_checking.service`
4. 配置环境变量
5. 启动服务:`systemctl enable --now pt_system_checking`
## 开发
### 运行测试
```bash
make test
```
### 清理构建文件
```bash
make clean
```
## 许可证
根据项目需要添加许可证信息。