Comprehensive system monitoring with 5 anomaly detectors
Project description
๐ NetSnoop Enhanced System Monitor
A comprehensive, production-grade system monitoring application with real-time anomaly detection and professional dashboard visualization.
๐ฏ Overview
NetSnoop is an advanced system monitoring tool that detects 5 types of anomalies in real-time:
- ๐ง Memory Anomalies - Detect memory leaks and excessive RAM usage
- ๐บ CPU Anomalies - Identify CPU-intensive processes and infinite loops
- โ ๏ธ Process Burst Anomalies - Catch malware, ransomware, and fork bombs (Security)
- ๐ Network Anomalies - Detect data exfiltration and botnet activity (Security)
- ๐งต Thread Anomalies - Find thread leaks and poorly designed applications
Key Features:
- 42+ classes demonstrating comprehensive OOP design
- 10+ design patterns (Observer, Strategy, Singleton, Factory, Builder, Template Method, Chain of Responsibility, Command, Facade, Repository)
- Cross-platform support (Windows & Linux)
- CSV-based storage (no database required)
- Professional Streamlit dashboard
- Real-time monitoring with configurable thresholds
- Parent process tracking for burst detection
๐ Quick Start
Installation
# Install dependencies
pip install psutil streamlit plotly pandas
# Clone the repository
git clone https://github.com/yourusername/netsnoop-monitor.git
cd netsnoop-monitor
Run the Monitor
# Start monitoring in background
python simple_monitor.py
Open the Dashboard
# Launch the web dashboard (opens at http://localhost:8501)
streamlit run simple_dashboard.py
Test Anomaly Detection
# Test memory anomaly (allocates 600 MB)
python test_memory.py
# Test CPU anomaly (runs infinite loop)
python test_cpu.py
# Test burst anomaly (spawns 15 processes)
python test_burst.py
# Test network anomaly (opens 35 connections)
python test_network.py
# Test thread anomaly (creates 60 threads)
python test_thread.py
๐ Screenshots
Dashboard Overview
The dashboard provides real-time visualization of all system anomalies with interactive charts and detailed alert tables.
Console Monitoring
====================================================================
๐ NetSnoop Enhanced System Monitor
NOW WITH 5 ANOMALY DETECTORS!
====================================================================
โ
Started MemoryMonitor
โ
Started CPUMonitor
โ
Started ProcessBurstMonitor
โ
Started NetworkMonitor
โ
Started ThreadMonitor
[19:00:00] ๐ง CRITICAL MEMORY Process (Python: test_memory.py) PID 1234: 1209.8 MB
[19:01:00] ๐บ HIGH CPU Process (Python: test_cpu.py) PID 5678: 95.2%
[19:02:00] ๐ฅ CRITICAL BURST Process (Python: test_burst.py) PID 9012: 15.0 processes
๐๏ธ Architecture
System Layers
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PRESENTATION LAYER โ
โ (Streamlit Dashboard) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DATA PERSISTENCE LAYER โ
โ (CSV File Manager) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MONITORING ENGINE LAYER โ
โ (5 Specialized Monitors) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PLATFORM ABSTRACTION LAYER โ
โ (Windows/Linux Implementations) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Design Patterns
NetSnoop implements 10+ design patterns:
| Pattern | Usage | Benefit |
|---|---|---|
| Singleton | ConfigManager, CSVManager | Single source of truth |
| Factory | MonitorFactory | Platform-specific creation |
| Observer | Alert notifications | Loose coupling, multi-channel alerts |
| Strategy | PlatformMonitor | Cross-platform compatibility |
| Builder | AlertBuilder | Fluent alert construction |
| Template Method | Monitor base class | Code reuse, consistent structure |
| Chain of Responsibility | AlertFilter | Flexible filtering pipeline |
| Command | Monitor control | Undo/redo support |
| Facade | MonitoringSystem | Simplified interface |
| Repository | Data access | Storage abstraction |
๐ Anomaly Detection
1. Memory Monitoring ๐ง
What it detects: Processes using excessive memory
Thresholds:
- HIGH: โฅ 500 MB
- CRITICAL: โฅ 1000 MB
- EXTREME: โฅ 2000 MB
Use cases:
- Memory leaks detection
- Resource-hungry applications
- System crash prevention
Test: python test_memory.py (allocates 600 MB)
2. CPU Monitoring ๐บ
What it detects: Processes consuming excessive CPU
Thresholds:
- HIGH: โฅ 90%
- CRITICAL: โฅ 95%
- EXTREME: โฅ 98%
Use cases:
- Infinite loop detection
- Performance optimization
- Runaway process identification
Test: python test_cpu.py (runs infinite loop)
3. Process Burst Detection โ ๏ธ (Security)
What it detects: Sudden mass process creation
Thresholds:
- HIGH: โฅ 10 processes in 10 seconds
- CRITICAL: โฅ 15 processes in 10 seconds
- EXTREME: โฅ 20 processes in 10 seconds
Use cases:
- Malware detection
- Ransomware detection
- Fork bomb prevention
Special feature: Shows parent process that spawned the burst!
Test: python test_burst.py (spawns 15 processes)
4. Network Monitoring ๐ (Security)
What it detects: Processes with excessive network connections
Thresholds:
- HIGH: โฅ 30 connections
- CRITICAL: โฅ 50 connections
- EXTREME: โฅ 100 connections
Use cases:
- Data exfiltration detection
- Botnet activity detection
- Unusual network behavior
Test: python test_network.py (opens 35 connections)
5. Thread Monitoring ๐งต
What it detects: Processes with excessive threads
Thresholds:
- HIGH: โฅ 50 threads
- CRITICAL: โฅ 100 threads
- EXTREME: โฅ 200 threads
Use cases:
- Thread leak detection
- Poorly designed application identification
- System instability prevention
Test: python test_thread.py (creates 60 threads)
๐ Project Structure
netsnoop-monitor/
โโโ simple_monitor.py # Main monitoring engine (47KB, 42+ classes)
โโโ simple_dashboard.py # Streamlit dashboard (19KB)
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โ
โโโ Test Scripts/
โ โโโ test_memory.py # Memory anomaly test
โ โโโ test_cpu.py # CPU anomaly test
โ โโโ test_burst.py # Burst anomaly test
โ โโโ test_network.py # Network anomaly test
โ โโโ test_thread.py # Thread anomaly test
โ
โโโ Generated Files/
โ โโโ alerts.csv # Alert storage (CSV format)
โ โโโ alerts.log # Alert logging
โ
โโโ Documentation/
โโโ CODE_SUMMARY.md # Complete code explanation
โโโ COMPLETE_UML_DIAGRAMS.md # UML diagrams
โโโ FINAL_PROJECT_REPORT.md # Academic report
โโโ ... (15+ more guides)
๐จ Dashboard Features
Real-time Metrics
- Total alerts count
- Alert severity distribution
- Most affected processes
- Alert trends over time
Interactive Visualizations
- Timeline Chart - Alert distribution over time
- Severity Pie Chart - Alert severity breakdown
- Monitor Type Bar Chart - Alerts by monitor type
- Alert Table - Detailed alert information with filters
Filters & Controls
- Filter by severity (HIGH, CRITICAL, EXTREME)
- Filter by monitor type
- Auto-refresh interval (10-60 seconds)
- Search by process name
โ๏ธ Configuration
Customizable Thresholds
Edit ConfigManager class in simple_monitor.py:
# Memory thresholds (MB)
MEMORY_HIGH = 500
MEMORY_CRITICAL = 1000
MEMORY_EXTREME = 2000
# CPU thresholds (%)
CPU_HIGH = 90
CPU_CRITICAL = 95
CPU_EXTREME = 98
# Process burst thresholds (processes in 10s window)
BURST_HIGH = 10
BURST_CRITICAL = 15
BURST_EXTREME = 20
# Network thresholds (connections)
NETWORK_CONNECTIONS_HIGH = 30
NETWORK_CONNECTIONS_CRITICAL = 50
NETWORK_CONNECTIONS_EXTREME = 100
# Thread thresholds (threads)
THREAD_COUNT_HIGH = 50
THREAD_COUNT_CRITICAL = 100
THREAD_COUNT_EXTREME = 200
Excluded Processes
By default, 50 system processes are excluded to reduce noise:
- Windows system processes (dwm.exe, svchost.exe, etc.)
- Browsers (Chrome, Edge)
- Development tools (VS Code)
- Antivirus software (McAfee, Windows Defender)
- And more...
To customize, edit the EXCLUDED_PROCESSES set in ConfigManager.
๐ง Advanced Usage
Import as Library
from simple_monitor import MonitoringSystem, ConfigManager, Severity
# Start monitoring
system = MonitoringSystem()
system.start()
# Stop monitoring
system.stop()
Custom Alert Handling
from simple_monitor import Observer, Alert
class CustomObserver(Observer):
def update(self, alert: Alert):
# Your custom logic
if alert.severity == Severity.CRITICAL:
send_email(alert)
# Attach to system
system = MonitoringSystem()
system._subject.attach(CustomObserver())
Access Alert Data
import pandas as pd
# Read alerts from CSV
df = pd.read_csv('alerts.csv')
# Filter high severity alerts
high_alerts = df[df['severity'] == 'HIGH']
# Get alerts for specific process
process_alerts = df[df['process_name'].str.contains('chrome')]
๐ Educational Value
OOP Principles Demonstrated
โ
Encapsulation - Data hiding with properties
โ
Abstraction - Abstract base classes (Monitor, Observer, Repository)
โ
Inheritance - Monitor hierarchy, Observer hierarchy
โ
Polymorphism - Platform-specific implementations
SOLID Principles
โ
Single Responsibility - Each class has one job
โ
Open/Closed - Easy to extend without modification
โ
Liskov Substitution - Subclasses can replace parents
โ
Interface Segregation - Focused interfaces
โ
Dependency Inversion - Depend on abstractions
Statistics
- 42+ classes - Comprehensive OOP structure
- 10+ design patterns - Real-world pattern usage
- ~2,800 lines of code - Production-quality implementation
- 5 anomaly types - All testable with provided scripts
- Cross-platform - Works on Windows and Linux
- Zero database knowledge required - Uses simple CSV files
๐งช Testing
Unit Tests
All 5 anomaly types have dedicated test scripts:
# Run all tests sequentially
python test_memory.py # ~10 seconds
python test_cpu.py # ~5 seconds (stop with Ctrl+C)
python test_burst.py # ~10 seconds
python test_network.py # ~30 seconds (stop with Ctrl+C)
python test_thread.py # ~30 seconds (stop with Ctrl+C)
Expected Results
Each test should trigger an alert within 5-15 seconds:
| Test | Triggers | Severity | Time |
|---|---|---|---|
| test_memory.py | Memory alert | HIGH | ~10s |
| test_cpu.py | CPU alert | CRITICAL | ~5s |
| test_burst.py | Burst alert | CRITICAL | immediate |
| test_network.py | Network alert | HIGH | ~10s |
| test_thread.py | Thread alert | HIGH | ~15s |
๐ ๏ธ System Requirements
Minimum Requirements
- OS: Windows 10/11, Linux (Ubuntu 20.04+)
- Python: 3.8 or higher
- RAM: 2 GB
- Disk: 100 MB
Recommended Requirements
- OS: Windows 11, Ubuntu 22.04+
- Python: 3.10+
- RAM: 4 GB
- Disk: 500 MB
Dependencies
psutil>=5.9.0 # System monitoring
streamlit>=1.20.0 # Dashboard framework
plotly>=5.13.0 # Interactive charts
pandas>=1.5.0 # Data manipulation
๐ Performance
System Overhead
| Metric | Value |
|---|---|
| CPU Usage | ~1% |
| Memory Usage | ~50 MB |
| Disk I/O | Minimal (CSV writes) |
| Network | None (local only) |
Response Times
| Operation | Time |
|---|---|
| Alert Detection | <100ms |
| Alert Storage | <50ms |
| Dashboard Load | <2s |
| Dashboard Refresh | <500ms |
๐ Security Features
Built-in Security Monitoring
- Process Burst Detection - Catches ransomware and malware spreading
- Network Monitoring - Detects data exfiltration attempts
- Parent Process Tracking - Identifies which process spawned malicious children
Privacy
- No data collection - All data stays local
- No network communication - Except monitored processes
- CSV storage - Human-readable, auditable
๐ง Limitations
- Historical Data - Limited by CSV file size (recommend periodic rotation)
- Real-time Dashboard - Requires manual refresh (configurable 10-60s)
- No Email Alerts - Console, CSV, and log file only (easily extensible)
- Single Machine - Not designed for distributed monitoring
๐ฎ Future Enhancements
- Email/SMS alert notifications
- Machine learning-based anomaly detection
- Database support (PostgreSQL, MongoDB)
- Multi-machine monitoring
- REST API for integrations
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Your Name
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...
๐ฅ Authors
Your Name
- Email: chitvijoshi2646@gmail.com
- GitHub: @ChitviJoshi
- LinkedIn: Chitvi Joshi
๐ฌ Support
- Documentation: See
docs/folder - Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: chitvijoshi2646@gmail.com
Made with โค๏ธ using Python
NetSnoop - Comprehensive System Monitoring Made Simple
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netsnoop_monitor-0.2.1.tar.gz.
File metadata
- Download URL: netsnoop_monitor-0.2.1.tar.gz
- Upload date:
- Size: 15.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22cf8862817b4608295aa28a8381ac2755f0071ffe26dc8f00140e06c359e27d
|
|
| MD5 |
c7907bc4386178e7379f25d743f52d76
|
|
| BLAKE2b-256 |
58b11d20264aadd86f2ee241f4f4c1d76c6856a21923070a5a39408ffd46a0a9
|
File details
Details for the file netsnoop_monitor-0.2.1-py3-none-any.whl.
File metadata
- Download URL: netsnoop_monitor-0.2.1-py3-none-any.whl
- Upload date:
- Size: 20.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdf0ff88cc85c8b54adc3bb4e7446af844c0c9fbbd8174795a06a1e2c4710f98
|
|
| MD5 |
973b52323350f2934e140f25d78bef47
|
|
| BLAKE2b-256 |
2a3a5d1c4dae7d7447825ae87f45748fba66881ad41d743b97deb1b221d179b3
|