A genuinely AI-powered, Linux-based system resource monitor implemented in C that uses machine learning techniques for intelligent predictions and anomaly detection.
This project implements real machine learning algorithms:
| Feature | Algorithm | Description |
|---|---|---|
| EWMA Prediction | Exponentially Weighted Moving Average | Gives more weight to recent data for smooth predictions |
| Anomaly Detection | Gaussian Model (Unsupervised Learning) | Learns "normal" behavior and detects unusual patterns |
| Pattern Learning | Time-of-Day Profiling | Learns typical usage for each hour of the day |
| Adaptive Thresholds | Percentile-Based Learning | Thresholds that adapt to your system's actual workload |
| Model Persistence | Binary Serialization | AI model saved/loaded across restarts |
The system learns from your usage patterns and improves predictions over time.
- Real-time Monitoring: CPU, Memory, and Disk usage from
/procfilesystem - Proactive Alerts: Warns based on predicted (not current) usage
- CSV Logging: Historical data saved for analysis
- Learning Progress: Visual indicator showing AI training status
- Configurable: Adjust thresholds, intervals, and paths
AI Powered Resource Monitor/
├── include/
│ ├── ai_engine.h # 🧠 AI/ML algorithms
│ ├── alerter.h # Alert system
│ ├── config.h # Configuration
│ ├── cpu_monitor.h # CPU monitoring
│ ├── data_logger.h # CSV logging
│ ├── disk_monitor.h # Disk monitoring
│ ├── mem_monitor.h # Memory monitoring
│ └── predictor.h # Basic predictions
├── src/
│ ├── ai_engine.c # 🧠 EWMA, Anomaly Detection, Pattern Learning
│ ├── alerter.c # Alert implementation
│ ├── config.c # Config loading
│ ├── cpu_monitor.c # /proc/stat reader
│ ├── data_logger.c # CSV writer
│ ├── disk_monitor.c # statvfs implementation
│ ├── main.c # Main loop with AI integration
│ ├── mem_monitor.c # /proc/meminfo reader
│ └── predictor.c # Moving average, linear trend
├── logs/
│ ├── resource_history.csv # Data log
│ ├── alerts.log # Alert history
│ └── ai_model.dat # 🧠 Saved AI model
├── config.txt
├── Makefile
├── DESIGN.md
└── README.md
# 1. Install WSL (PowerShell as Admin)
wsl --install
# 2. After restart, open WSL
wsl
# 3. Install build tools
sudo apt update && sudo apt install build-essential
# 4. Navigate to project
cd /mnt/d/Downloads/AI\ Powered\ Resource\ Monitor
# 5. Build and run
make clean && make
./resource_monitor╔══════════════════════════════════════════════════════════════════════╗
║ 🧠 AI-Powered System Resource Monitor 🧠 ║
╠══════════════════════════════════════════════════════════════════════╣
║ ✓ EWMA Prediction ✓ Anomaly Detection ✓ Pattern Learning ║
║ ✓ Adaptive Thresholds ✓ Model Persistence ✓ Proactive Alerts ║
╚══════════════════════════════════════════════════════════════════════╝
📅 2025-12-28 23:00:45 🧠 Learning: [████████████░░░░░░░░] 60% 🎯 Confidence: 75%
┌─────────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
│ METRIC │ CURRENT │ EWMA │ EXPECTED │THRESHOLD │ STATUS │
├─────────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
│ 🔲 CPU │ 45.2% │ 48.1% │ 52.3% │ 80.0% │ OK │
│ 💾 Memory │ 68.5% │ 69.2% │ 67.0% │ 75.0% │ WARNING │
│ 💿 Disk │ 34.8% │ 34.8% │ 34.5% │ 90.0% │ OK │
└─────────────┴──────────┴──────────┴──────────┴──────────┴──────────┘
🔍 Anomaly Detection
┌─────────────┬─────────┬──────────┬──────────┬────────────────────────┐
│ METRIC │ Z-SCORE │ EXPECTED │ ACTUAL │ REASON │
├─────────────┼─────────┼──────────┼──────────┼────────────────────────┤
│ CPU │ +0.32 │ 45.0% │ 45.2% │ Normal │
│ Memory │ +1.85 │ 65.0% │ 68.5% │ Normal │
│ Disk │ +0.02 │ 34.7% │ 34.8% │ Normal │
└─────────────┴─────────┴──────────┴──────────┴────────────────────────┘
S_t = α * X_t + (1 - α) * S_{t-1}
α = 0.3(smoothing factor)- More weight on recent values for responsive predictions
z_score = (value - mean) / std_dev
is_anomaly = |z_score| > 2.5
- Uses Welford's algorithm for online mean/variance
- Detects values >2.5 standard deviations from normal
- Maintains 24 statistical buckets (one per hour)
- Learns "normal" usage patterns for each hour
- Detects anomalies specific to time of day
warning_threshold = 90th_percentile * 1.1
critical_threshold = 99th_percentile * 1.05
- Learns from actual usage instead of fixed values
# Generate CPU load
stress --cpu 4 --timeout 60
# Generate memory load
stress --vm 2 --vm-bytes 1G --timeout 60Watch the AI detect these as anomalies!
| Concept | Implementation |
|---|---|
/proc filesystem |
CPU & memory stats from kernel |
| System calls | statvfs() for disk stats |
| Signal handling | Graceful shutdown, model saving |
| File I/O | CSV logging, model persistence |
| Online algorithms | Welford's algorithm for streaming stats |
MIT License - Free for educational use.