为嵌入式设备高并发监控场景设计的极简网页资源占用显示系统 https://crates.io/crates/swb-sys-monitor
|
|
преди 2 месеца | |
|---|---|---|
| .github | преди 2 месеца | |
| assets | преди 1 година | |
| benches | преди 1 година | |
| docs | преди 2 месеца | |
| scripts | преди 1 година | |
| src | преди 2 месеца | |
| templates | преди 1 година | |
| .dockerignore | преди 1 година | |
| .gitignore | преди 1 година | |
| CONTRIBUTING.md | преди 1 година | |
| Cargo.lock | преди 2 месеца | |
| Cargo.toml | преди 2 месеца | |
| Dockerfile | преди 1 година | |
| LICENSE | преди 1 година | |
| README.en.md | преди 3 месеца | |
| README.md | преди 3 месеца | |
| docker-compose.yml | преди 1 година |
English | 简体中文
A minimal resource usage monitoring system designed specifically for embedded device high-concurrency monitoring scenarios. Supports 200+ high-concurrency client connections with lock-free algorithms for high performance.
cargo install swb-sys-monitor
# Clone repository
git clone https://github.com/swaybien/swb-sys-monitor.git
cd swb-sys-monitor
# Build release version
cargo build --release
# Or run directly
cargo run -- --help
# Start with default configuration (listen on [::]:8080, cache TTL 10 seconds)
./target/release/swb-sys-monitor
# Custom configuration
./target/release/swb-sys-monitor --address 127.0.0.1 --port 3000 --ttl 5
# Set log level
./target/release/swb-sys-monitor --log-level debug
After starting, visit http://localhost:8080 in your browser to view system resource usage.
The page automatically refreshes every 10 seconds and displays the following information:
The system provides a health check endpoint at http://localhost:8080/health for monitoring service status:
curl http://localhost:8080/health
# Returns: OK
| Parameter | Short Parameter | Default | Description |
|---|---|---|---|
--address |
-a |
:: |
Server binding address (supports IPv4 and IPv6) |
--port |
-p |
8080 |
Server port |
--ttl |
-t |
10 |
Cache TTL in seconds |
--log-level |
-l |
info |
Log level (trace, debug, info, warn, error) |
--help |
-h |
- | Show help information |
/proc/stat and /proc/meminfo to obtain system informationarc-swap (ArcSwap) and AtomicU64 to implement thread-safe cachingString::with_capacity to pre-allocate capacity, reducing reallocation#[inline] attribute for performance optimization# Compile check
cargo check --all-targets
# Code style check
cargo clippy
# Run tests
cargo test
# Run benchmark tests
cargo bench
# Build release version
cargo build --release
The project includes comprehensive test coverage:
Use the provided installation script for automatic deployment to systemd systems:
# Clone repository
git clone https://github.com/swaybien/swb-sys-monitor.git
cd swb-sys-monitor
# Run installation script
sudo ./scripts/install.sh
# To uninstall
sudo ./scripts/uninstall.sh
For detailed deployment script usage instructions, please refer to Deployment Guide.
Create a systemd service file /etc/systemd/system/swb-sys-monitor.service:
[Unit]
Description=Resource Status Monitor
After=network.target
[Service]
Type=simple
User=nobody
ExecStart=/usr/local/bin/swb-sys-monitor
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl enable swb-sys-monitor
sudo systemctl start swb-sys-monitor
# Clone repository
git clone https://github.com/swaybien/swb-sys-monitor.git
cd swb-sys-monitor
# Start service
docker-compose up -d
# View logs
docker-compose logs -f swb-sys-monitor
# Stop service
docker-compose down
Access URL: http://localhost:18273
# Build image
docker build -t swb-sys-monitor .
# Run container
docker run -d \
--name swb-sys-monitor \
--restart unless-stopped \
-p 18273:8080 \
--read-only \
--tmpfs /tmp \
--cap-drop ALL \
--cap-add DAC_OVERRIDE \
--security-opt no-new-privileges:true \
swb-sys-monitor
# View logs
docker logs -f swb-sys-monitor
# Stop container
docker stop swb-sys-monitor
docker rm swb-sys-monitor
Docker deployment includes the following security features:
no-new-privileges to prevent privilege escalationYou can customize configuration through environment variables:
# docker-compose.yml
services:
swb-sys-monitor:
build: .
environment:
- RUST_LOG=debug
command:
[
"./swb-sys-monitor",
"--address",
"0.0.0.0",
"--port",
"8080",
"--ttl",
"5",
]
This project is licensed under the MIT License. See the LICENSE file for details.
Issues and Pull Requests are welcome! Please read the Contributing Guide.