mirror of
https://github.com/m1ngsama/tracker.git
synced 2025-12-24 10:51:43 +00:00
feat: Complete main application and documentation
- Implement main.rs with clap CLI argument parsing - Add --continuous flag for continuous monitoring mode - Add --interval flag for configurable update intervals - Add --config flag for custom config file paths - Initialize env_logger for debug logging - Create comprehensive .gitignore for Rust and Python - Write README-rust.md with usage instructions - Handle config loading with fallback to defaults - Support graceful Ctrl+C interruption in continuous mode
This commit is contained in:
parent
c6ffadc724
commit
8b68b1ba9b
3 changed files with 112 additions and 6 deletions
27
.gitignore
vendored
27
.gitignore
vendored
|
|
@ -1,3 +1,9 @@
|
|||
# Rust
|
||||
/target
|
||||
Cargo.lock
|
||||
**/*.rs.bk
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
|
@ -18,11 +24,24 @@ wheels/
|
|||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
.DS_Store
|
||||
ENV/
|
||||
env/
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
*.log
|
||||
|
||||
# Export data
|
||||
exports/
|
||||
|
||||
# IDEs
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
|
|
|||
37
README-rust.md
Normal file
37
README-rust.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# Tracker (Rust)
|
||||
|
||||
A high-performance system monitoring tool written in Rust.
|
||||
|
||||
## Features
|
||||
|
||||
- CPU, memory, disk, and network monitoring
|
||||
- Process tracking with top CPU consumers
|
||||
- Temperature sensor support (platform-dependent)
|
||||
- Configurable alert thresholds
|
||||
- Automatic logging to daily log files
|
||||
- Data export to JSON/CSV formats
|
||||
- Cross-platform compatibility
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Single run
|
||||
cargo run
|
||||
|
||||
# Continuous monitoring
|
||||
cargo run -- --continuous --interval 5
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Edit `config.json` to customize monitoring behavior and alert thresholds.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
54
src/main.rs
54
src/main.rs
|
|
@ -1,3 +1,53 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use clap::Parser;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
mod config;
|
||||
mod monitor;
|
||||
mod process;
|
||||
mod temperature;
|
||||
mod alert;
|
||||
mod logger;
|
||||
mod exporter;
|
||||
|
||||
use config::Config;
|
||||
use monitor::SystemMonitor;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "tracker-rs")]
|
||||
#[command(about = "System Tracker - Monitor machine health and performance", long_about = None)]
|
||||
struct Args {
|
||||
/// Run in continuous monitoring mode
|
||||
#[arg(short, long)]
|
||||
continuous: bool,
|
||||
|
||||
/// Update interval in seconds
|
||||
#[arg(short, long, default_value_t = 5)]
|
||||
interval: u64,
|
||||
|
||||
/// Path to config file
|
||||
#[arg(long, default_value = "config.json")]
|
||||
config: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
let args = Args::parse();
|
||||
|
||||
let config = Config::load(&args.config).unwrap_or_else(|_| {
|
||||
log::warn!("Failed to load config, using defaults");
|
||||
Config::default()
|
||||
});
|
||||
|
||||
let mut monitor = SystemMonitor::new(config);
|
||||
|
||||
if args.continuous {
|
||||
log::info!("Starting continuous monitoring mode with {}s interval", args.interval);
|
||||
loop {
|
||||
monitor.display_stats();
|
||||
thread::sleep(Duration::from_secs(args.interval));
|
||||
}
|
||||
} else {
|
||||
monitor.display_stats();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue