CPU and memory anomaly detection for local workloads using the Qwen3:8b LLM.
- Python 3.8+
- Ollama (installed and running)
- Qwen3:8b model available in Ollama
curl https://ollama.ai/install.sh | shollama pull qwen3:8bThe start.sh script automatically:
- Verifies prerequisites
- Creates a virtual environment (venv)
- Installs Python dependencies
- Launches the app
./start.sh./start.shThe script will:
- Validate requirements
- Create the venv if needed
- Install dependencies
- Show the launcher menu
# Activate the venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Launch
python quick_analysis.py./start.sh
# Choose option 1./start.sh
# Choose option 2- Metric collection – Gather CPU, memory, and process info via
psutil. - Anomaly detection – Flag readings when CPU > 80% or memory > 85%.
- LLM analysis – Send metrics to the Qwen3:8b model for context.
- Explanation – The model describes causes and recommended actions.
analyzer.monitor_continuous(duration_seconds=120, interval_seconds=5)
# and
analyzer.is_anomaly(metrics, cpu_threshold=90, mem_threshold=90)analyzer = AnomalyAnalyzer(model="mistral") # or another Ollama modelaiops/
├── anomaly_analyzer.py # Continuous monitoring script
├── quick_analysis.py # Single-measurement analysis
├── requirements.txt # Python dependencies
└── README.md # This file
ollama run qwen3:8bollama pull qwen3:8b
ollama list- Lower
duration_secondsor increaseinterval_seconds. - Qwen3:8b should run smoothly on most modern machines.
curl http://localhost:11434/api/generate -d '{
"model": "qwen3:8b",
"prompt": "What is a CPU anomaly?"
}'- Qwen3:8b offers improved language understanding and reasoning.
- Everything runs locally; nothing is sent outside your environment.
- Useful for AIOps and DevOps teams needing quick diagnostics.