feat: init pc-monitor project

- Client: Go-based Windows hardware monitoring (CPU, GPU, memory, disk, network, power)
- Server: Go + Gin + SQLite backend with REST API
- Frontend: Vue 3 + Element Plus dashboard
- Docker deployment support
- Windows service installation script
This commit is contained in:
672
2026-05-17 01:29:44 +08:00
commit 0e8c9f7bff
49 changed files with 3291 additions and 0 deletions

122
README.md Normal file
View File

@@ -0,0 +1,122 @@
# PC Monitor
A monitoring system for Windows PCs that tracks CPU, GPU, memory, network, disk, and power status.
## Architecture
- **Client**: Windows executable (.exe) that collects hardware metrics
- **Server**: Go backend with SQLite database
- **Frontend**: Vue 3 + Element Plus web dashboard
- **Deployment**: Docker support for server
## Quick Start
### Server (Docker)
1. Build and start the server:
```bash
docker-compose up -d
```
2. Access the web dashboard at http://localhost:8080
### Client (Windows)
1. Download the client executable
2. Edit `config.yaml` to set your server URL
3. Run the client:
```powershell
.\pc-monitor-client.exe
```
Or install as a Windows service:
```powershell
.\install\install.ps1 -ServerUrl "http://your-server:8080"
```
## Development
### Prerequisites
- Go 1.21+
- Node.js 18+
- Docker (optional)
### Build Server
```bash
cd server
go mod tidy
go build -o server .
```
### Build Client
```bash
cd client
go mod tidy
go build -o pc-monitor-client.exe .
```
### Build Frontend
```bash
cd web
npm install
npm run build
```
## API Endpoints
### Device Management
- `POST /api/v1/register` - Register a new device
- `GET /api/v1/devices` - List all devices
- `GET /api/v1/devices/:id` - Get device details
- `DELETE /api/v1/devices/:id` - Delete a device
- `POST /api/v1/devices/:id/heartbeat` - Send heartbeat
### Metrics
- `POST /api/v1/report` - Report metrics
- `GET /api/v1/devices/:id/metrics/latest` - Get latest metrics
- `GET /api/v1/devices/:id/metrics/history` - Get metrics history
### Alerts
- `GET /api/v1/alerts` - List active alerts
- `POST /api/v1/alerts/rules` - Create alert rule
- `GET /api/v1/devices/:id/alerts/rules` - Get device alert rules
- `DELETE /api/v1/alerts/rules/:id` - Delete alert rule
- `POST /api/v1/alerts/:id/resolve` - Resolve alert
## Configuration
### Server Configuration (config.yaml)
```yaml
server:
addr: ":8080"
database:
path: "./data/monitor.db"
retention_days: 30
auth:
admin_password: "admin123"
```
### Client Configuration (config.yaml)
```yaml
server:
url: "http://your-server:8080"
token: ""
collect:
interval: 30s
report:
interval: 60s
```
## License
MIT License