Skip to content

DevWatchMan is a comprehensive real-time system monitoring application built with FastAPI and modern web technologies. It provides live insights into your system's performance including CPU, memory, disk usage, network statistics, port monitoring, and intelligent alertingβ€”all through a beautiful, responsive web dashboard.

Notifications You must be signed in to change notification settings

Sakilalakmal/DevWatchMan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” DevWatchMan

Python FastAPI SQLite WebSocket JavaScript HTML5 CSS3 TailwindCSS Chart.js Tauri TypeScript Rust Docker

A comprehensive real-time system monitoring application built with FastAPI and modern web technologies

Features β€’ Installation β€’ Quick Start β€’ API Documentation β€’ Configuration β€’ Tech Stack


πŸ“‹ Overview

DevWatchMan is a powerful, production-ready system monitoring solution that provides real-time insights into your system's performance. Built with FastAPI for high-performance backend operations and vanilla JavaScript for a lightweight frontend, it offers comprehensive monitoring capabilities through both a modern web dashboard and a cross-platform desktop application.

🎯 Key Highlights

  • πŸ”„ Real-time WebSocket Updates - Instant metric visualization with 3-second refresh intervals
  • πŸ“Š Interactive Charts - Powered by Chart.js with historical data up to 30 days
  • 🚨 Smart Alert System - Configurable thresholds with cooldown periods and severity levels
  • 🌐 Network Quality Monitoring - Latency tracking and connectivity status
  • πŸ”Œ Port Monitoring - Track critical development and production ports
  • 🐳 Docker Integration - Monitor container status and resource usage
  • πŸ’Ύ SQLite Database - Persistent historical data storage with automatic retention
  • ⚑ FastAPI Backend - High-performance async API endpoints
  • 🎨 Modern UI - Beautiful dark/light mode with TailwindCSS
  • πŸ–₯️ Desktop Application - Cross-platform Tauri-based desktop app
  • πŸ“± Responsive Design - Works seamlessly on desktop and mobile devices
  • πŸ” Profile Management - Multiple monitoring profiles for different environments

✨ Features

πŸ“ˆ System Monitoring

  • CPU Usage - Real-time CPU percentage tracking across all cores
  • Memory Monitoring - RAM usage with detailed bytes-level information and swap memory
  • Disk Usage - Track disk space utilization across all mounted drives
  • Network Statistics - Upload/download speeds in real-time with historical graphs
  • Process Monitoring - Top processes by CPU and memory consumption
  • Network Quality - Ping-based latency monitoring with quality classification

🚨 Advanced Features

  • WebSocket Live Updates - Get instant updates without page refresh (3-second intervals)
  • Historical Data - View performance trends over time (up to 720 hours / 30 days)
  • Port Status Monitoring - Track critical ports (3000, 5173, 8000, 1433, 5672, 15672)
  • Network Quality Checks - Ping-based latency monitoring (default: 1.1.1.1)
  • Docker Container Monitoring - Real-time status and resource usage of Docker containers
  • Profile System - Switch between monitoring profiles (default, frontend-dev, microservices)
  • Alert System with:
    • CPU threshold alerts (default: 85%)
    • RAM threshold alerts (default: 90%)
    • Required port monitoring with cooldown (60 seconds)
    • Severity levels: critical, warning, info
    • Alert muting and acknowledgment
    • Event timeline tracking

🎨 Dashboard Features

  • Real-time KPIs - CPU, RAM, Disk, Network metrics updated live
  • Historical Charts - Interactive time-series visualizations
  • Port Status Grid - Visual status of monitored ports with process information
  • Alert Panel - Recent alerts with severity indicators
  • Timeline View - System events and alert history
  • Docker Dashboard - Container status and resource graphs
  • Profile Switcher - Quick switching between monitoring profiles
  • Dark/Light Mode - Automatic theme switching
  • Responsive Layout - Optimized for all screen sizes

πŸ› οΈ Tech Stack

Backend Technologies

Technology Version Purpose
Python 3.10+ Core programming language
FastAPI Latest Modern, high-performance web framework
Uvicorn Latest Lightning-fast ASGI server
Pydantic Latest Data validation using Python type annotations
psutil Latest Cross-platform library for system monitoring
SQLite 3.x Lightweight embedded database
Jinja2 Latest Server-side template rendering
Python-multipart Latest Form data handling
Docker SDK Latest Docker container monitoring

Frontend Technologies

Technology Purpose
HTML5/CSS3 Semantic markup and modern styling
JavaScript (Vanilla) No framework dependencies, pure performance
TailwindCSS Utility-first CSS framework (via CDN)
Chart.js Beautiful, responsive charts and graphs
WebSocket API Real-time bidirectional communication

Desktop Application

| Technology | Version | Purpose | |-----------|---------| | Tauri | v2 | Cross-platform desktop framework | | TypeScript | ~5.6.2 | Type-safe desktop app development | | Vite | ^6.0.3 | Fast build tool and dev server | | Rust | Latest | Backend runtime for Tauri |

Development Tools

  • Git - Version control
  • PyInstaller - Python application bundling (desktop version)
  • Virtual Environment - Isolated Python dependencies

System Requirements

Component Requirement
Python 3.10 or higher
Operating System Windows, macOS, Linux
Browser Modern browser with WebSocket support (Chrome, Firefox, Safari, Edge)
RAM Minimum 2GB (4GB+ recommended)
Disk Space 100MB for application + database growth
Network Required for network quality monitoring

πŸ“Š Architecture

System Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         DevWatchMan                              β”‚
β”‚                    System Monitor Platform                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Web Dashboard      │◄───────►│  Desktop App (Tauri) β”‚
β”‚   (Browser-based)    β”‚  HTTP   β”‚  (Cross-platform)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚                                 β”‚
           β”‚ WebSocket / REST API            β”‚
           β”‚                                 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              FastAPI Backend Server                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚           API Routes Layer                       β”‚  β”‚
β”‚  β”‚  /api/health  /api/summary  /api/history        β”‚  β”‚
β”‚  β”‚  /api/ports   /api/alerts   /api/docker         β”‚  β”‚
β”‚  β”‚  /ws/live (WebSocket)                           β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚         Core Services Layer                      β”‚  β”‚
β”‚  β”‚  β€’ Snapshot Scheduler (3s interval)             β”‚  β”‚
β”‚  β”‚  β€’ WebSocket Manager                            β”‚  β”‚
β”‚  β”‚  β€’ Alert State Manager                          β”‚  β”‚
β”‚  β”‚  β€’ Profile State Manager                        β”‚  β”‚
β”‚  β”‚  β€’ Retention Service                            β”‚  β”‚
β”‚  β”‚  β€’ Docker Monitor                               β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚         Data Collectors Layer                    β”‚  β”‚
β”‚  β”‚  β€’ CPU Collector      β€’ Network Collector       β”‚  β”‚
β”‚  β”‚  β€’ Memory Collector   β€’ Port Scanner            β”‚  β”‚
β”‚  β”‚  β€’ Disk Collector     β€’ Process Monitor         β”‚  β”‚
β”‚  β”‚  β€’ Network Quality    β€’ Docker Collector        β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚         Storage Layer                            β”‚  β”‚
β”‚  β”‚  β€’ SQLite Database                              β”‚  β”‚
β”‚  β”‚    - snapshots table (metrics history)          β”‚  β”‚
β”‚  β”‚    - alerts table (alert history)               β”‚  β”‚
β”‚  β”‚    - events table (timeline events)             β”‚  β”‚
β”‚  β”‚    - app_state table (configuration)            β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                         β–Ό
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚      System Resources          β”‚
         β”‚  β€’ psutil (CPU, RAM, Disk)    β”‚
         β”‚  β€’ Network Interfaces          β”‚
         β”‚  β€’ Running Processes           β”‚
         β”‚  β€’ Docker Daemon               β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Data Collection Flow                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     Every 3 seconds     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Snapshot   │────────────────────────►│   System     β”‚
β”‚   Scheduler  β”‚                         β”‚  Collectors  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                                β”‚
                                                β–Ό
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚  Collect Metrics  β”‚
                                    β”‚  β€’ CPU %          β”‚
                                    β”‚  β€’ Memory %       β”‚
                                    β”‚  β€’ Disk %         β”‚
                                    β”‚  β€’ Network I/O    β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                              β–Ό
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚  Alert Engine     β”‚
                                    β”‚  β€’ Check CPU      β”‚
                                    β”‚  β€’ Check RAM      β”‚
                                    β”‚  β€’ Check Ports    β”‚
                                    β”‚  β€’ Check Network  β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                              β–Ό
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚  Store in SQLite  β”‚
                                    β”‚  β€’ snapshots      β”‚
                                    β”‚  β€’ alerts         β”‚
                                    β”‚  β€’ events         β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                              β–Ό
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚ Broadcast via WS  β”‚
                                    β”‚ to all clients    β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

WebSocket Communication

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client     β”‚                           β”‚   Server     β”‚
β”‚  (Browser)   β”‚                           β”‚  (FastAPI)   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                           β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                                          β”‚
       β”‚  1. Connect: ws://host/ws/live          β”‚
       │─────────────────────────────────────────►│
       β”‚                                          β”‚
       β”‚  2. Connection Established               β”‚
       │◄─────────────────────────────────────────│
       β”‚                                          β”‚
       β”‚  3. Snapshot Update (every 3s)           β”‚
       │◄─────────────────────────────────────────│
       β”‚  {                                       β”‚
       β”‚    "type": "snapshot",                   β”‚
       β”‚    "v": 1,                               β”‚
       β”‚    "data": {                             β”‚
       β”‚      "cpu_percent": 45.2,                β”‚
       β”‚      "mem_percent": 62.8,                β”‚
       β”‚      ...                                  β”‚
       β”‚    }                                     β”‚
       β”‚  }                                       β”‚
       β”‚                                          β”‚
       β”‚  4. Alert Update                         β”‚
       │◄─────────────────────────────────────────│
       β”‚  {                                       β”‚
       β”‚    "type": "timeline_event",             β”‚
       β”‚    "v": 1,                               β”‚
       β”‚    "data": {...}                         β”‚
       β”‚  }                                       β”‚
       β”‚                                          β”‚
       β”‚  5. Heartbeat / Keep-alive               β”‚
       │◄────────────────────────────────────────►│
       β”‚                                          β”‚

πŸš€ Installation

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.10 or higher (Download)
  • pip (Python package installer - usually comes with Python)
  • Git (Download)
  • Virtual environment (recommended for isolation)

Step 1: Clone the Repository

git clone https://github.com/Sakilalakmal/DevWatchMan.git
cd DevWatchMan

Step 2: Create Virtual Environment (Recommended)

Windows

python -m venv venv
venv\Scripts\activate

macOS/Linux

python3 -m venv venv
source venv/bin/activate

Step 3: Install Dependencies

# Install all required Python packages
pip install -r requirements.txt

Required Python packages:

fastapi          # Modern web framework
uvicorn          # ASGI server
psutil           # System and process utilities
pydantic         # Data validation
jinja2           # Template engine
python-multipart # For form data handling
docker           # Docker container monitoring

Alternatively, install packages individually:

pip install fastapi uvicorn psutil pydantic jinja2 python-multipart docker

Step 4: Verify Installation

python -c "import fastapi, uvicorn, psutil; print('All dependencies installed successfully!')"

🎯 Quick Start

Running the Web Application

Development Mode (with auto-reload)

# Navigate to the application directory
cd devwatchman

# Start the server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Production Mode

# Navigate to the application directory
cd devwatchman

# Start with multiple workers
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4

Accessing the Dashboard

Once the server is running, access the application:

Running the Desktop Application

Prerequisites for Desktop App

# Install Node.js dependencies
cd devwatchman-desktop
npm install

# Install Rust (required for Tauri)
# Visit: https://www.rust-lang.org/tools/install

Development Mode

cd devwatchman-desktop
npm run tauri dev

Build Desktop App

cd devwatchman-desktop
npm run tauri build

πŸ“– Usage

Starting the Server

# Development mode with auto-reload
uvicorn app.main:app --reload

# Production mode
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4

# Custom port
uvicorn app.main:app --port 8001

# With SSL (HTTPS)
uvicorn app.main:app --ssl-keyfile=key.pem --ssl-certfile=cert.pem

Monitoring Your System

  1. Dashboard - Navigate to http://localhost:8000 for the main monitoring interface
  2. Real-time Updates - The dashboard automatically connects via WebSocket for live data
  3. Historical View - Charts display configurable time ranges (1-720 hours)
  4. Alerts - Check the alerts panel for system warnings and critical notifications
  5. Docker Monitoring - View container status and resource usage in the Docker panel
  6. Profile Switching - Select different monitoring profiles for various environments

Monitoring Profiles

DevWatchMan supports multiple monitoring profiles:

  • default - General system monitoring (ports: 3000, 5173, 8000, 1433, 5672, 15672)
  • frontend-dev - Frontend development (ports: 3000, 5173, 8000)
  • microservices - Microservices environment (custom port configuration)

Switch profiles via the dashboard or API:

curl -X POST "http://localhost:8000/api/profiles/select?name=frontend-dev"

πŸ”Œ API Endpoints

Health Check

GET /api/health

Returns the API health status.

Response:

{
  "ok": true,
  "data": {"status": "ok"},
  "meta": {}
}

Latest System Snapshot

GET /api/summary

Returns the most recent system metrics.

Response:

{
  "ok": true,
  "data": {
    "id": 1234,
    "ts_utc": "2026-01-15T15:30:00.000Z",
    "cpu_percent": 45.2,
    "mem_percent": 62.8,
    "mem_used_bytes": 8589934592,
    "mem_total_bytes": 17179869184,
    "disk_percent": 55.3,
    "disk_used_bytes": 268435456000,
    "disk_total_bytes": 512000000000,
    "net_sent_bps": 1048576.5,
    "net_recv_bps": 2097152.8
  },
  "meta": {}
}

Historical Data

GET /api/history?hours=24

Returns historical snapshots for time-series analysis.

Query Parameters:

  • hours (optional): Number of hours to retrieve (1-720, default: 24)

Response:

{
  "ok": true,
  "data": {
    "snapshots": [
      {
        "id": 1,
        "ts_utc": "2026-01-15T15:00:00.000Z",
        "cpu_percent": 42.1,
        "mem_percent": 60.5,
        ...
      }
    ]
  },
  "meta": {"hours": 24, "count": 288}
}

Port Status

GET /api/ports

Returns the status of monitored ports.

Response:

{
  "ok": true,
  "data": [
    {
      "port": 3000,
      "listening": true,
      "pid": 1234,
      "process_name": "node"
    },
    {
      "port": 8000,
      "listening": true,
      "pid": 5678,
      "process_name": "python"
    }
  ],
  "meta": {"watch_ports": [3000, 5173, 8000, 1433, 5672, 15672]}
}

All Listening Ports

GET /api/ports/listening?limit=500

Returns all ports currently listening on the system.

Query Parameters:

  • limit (optional): Maximum number of ports to return (1-2000, default: 500)

Network Quality

GET /api/network

Returns network latency and quality status.

Response:

{
  "ok": true,
  "data": {
    "host": "1.1.1.1",
    "timeout_ms": 800,
    "latency_ms": 45.2,
    "status": "good"
  },
  "meta": {}
}

Status Values:

  • excellent - Latency < 30ms
  • good - Latency 30-100ms
  • fair - Latency 100-200ms
  • poor - Latency > 200ms
  • offline - No connectivity

Alerts

GET /api/alerts?limit=50&include_ack=false

Returns recent system alerts.

Query Parameters:

  • limit (optional): Number of alerts to retrieve (1-200, default: 50)
  • include_ack (optional): Include acknowledged alerts (default: false)

Response:

{
  "ok": true,
  "data": [
    {
      "id": 1,
      "ts_utc": "2026-01-15T15:30:00.000Z",
      "severity": "warning",
      "message": "CPU usage high: 87.3%",
      "acknowledged": false
    }
  ],
  "meta": {"limit": 50}
}

Acknowledge Alert

POST /api/alerts/{alert_id}/ack

Acknowledges a specific alert.


Mute Alerts

POST /api/alerts/mute?minutes=30

Mutes all alerts for a specified duration.

Query Parameters:

  • minutes (required): Duration to mute (0-1440 minutes)

Timeline Events

GET /api/timeline?hours=24&limit=200

Returns system events and alert history.

Query Parameters:

  • hours (optional): Time range in hours (1-168, default: 24)
  • limit (optional): Maximum events to return (1-500, default: 200)

Top Processes

GET /api/processes

Returns top processes by CPU and memory usage.

Response:

{
  "ok": true,
  "data": {
    "by_cpu": [
      {"pid": 1234, "name": "chrome", "cpu_percent": 15.2, "mem_percent": 5.3}
    ],
    "by_mem": [
      {"pid": 5678, "name": "node", "cpu_percent": 2.1, "mem_percent": 12.8}
    ]
  },
  "meta": {}
}

Docker Status

GET /api/docker/status

Returns Docker daemon availability status.


Docker Containers

GET /api/docker/containers?include_stopped=true&limit=50

Returns Docker container information with resource usage.

Query Parameters:

  • include_stopped (optional): Include stopped containers (default: true)
  • limit (optional): Maximum containers to return (1-200, default: 50)

Monitoring Profiles

GET /api/profiles

Returns available monitoring profiles and the active profile.


Select Profile

POST /api/profiles/select?name=frontend-dev

Switches to a different monitoring profile.

Query Parameters:

  • name (required): Profile name to activate

WebSocket Endpoint

WS /ws/live

Real-time system updates via WebSocket connection.

Message Format:

{
  "type": "snapshot",
  "v": 1,
  "data": {
    "cpu_percent": 45.2,
    "mem_percent": 62.8,
    "disk_percent": 55.3,
    "net_sent_bps": 1048576.5,
    "net_recv_bps": 2097152.8
  }
}

Message Types:

  • snapshot - System metrics update
  • timeline_event - New alert or event
  • alert - Critical alert notification

βš™οΈ Configuration

All configuration settings are located in devwatchman/app/core/config.py

Key Settings

# Application Settings
APP_NAME: str = "DevWatchMan"
DB_PATH: Path = Path(__file__).resolve().parents[2] / "devwatchman.db"

# Monitoring Intervals
SNAPSHOT_INTERVAL_SECONDS: int = 3  # Data collection frequency
HISTORY_DEFAULT_HOURS: int = 24     # Default history timeframe

# Port Monitoring
WATCH_PORTS: list[int] = [3000, 5173, 8000, 1433, 5672, 15672]

# Alert Thresholds
ALERT_CPU_PERCENT: int = 85         # CPU usage alert threshold
ALERT_RAM_PERCENT: int = 90         # Memory usage alert threshold
ALERT_PORTS_REQUIRED: list[int] = [3000, 1433, 5672]  # Critical ports
ALERT_COOLDOWN_SECONDS: int = 60    # Minimum time between alerts

# Alert Duration Thresholds
ALERT_CPU_DURATION_SECONDS: int = 30    # CPU must be high for 30s
ALERT_RAM_DURATION_SECONDS: int = 30    # RAM must be high for 30s
ALERT_NET_OFFLINE_SECONDS: int = 10     # Network offline threshold

# Flapping Detection
FLAP_THRESHOLD: int = 6              # Number of state changes
FLAP_WINDOW_SECONDS: int = 120       # Time window for flap detection

# Network Monitoring
NETWORK_PING_HOST: str = "1.1.1.1"  # Ping target for network quality
NETWORK_PING_TIMEOUT_MS: int = 800  # Ping timeout in milliseconds

Customizing Monitored Ports

Edit the WATCH_PORTS list in config.py to monitor your specific ports:

WATCH_PORTS = [3000, 5000, 8080, 9000]  # Your custom ports

Adjusting Alert Thresholds

Modify alert sensitivity:

ALERT_CPU_PERCENT = 70   # Alert when CPU > 70%
ALERT_RAM_PERCENT = 85   # Alert when RAM > 85%

Changing Snapshot Interval

Adjust data collection frequency:

SNAPSHOT_INTERVAL_SECONDS = 5  # Collect every 5 seconds (default: 3)

πŸ“ Project Structure

DevWatchMan/
β”œβ”€β”€ devwatchman/                      # Main web application
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py                   # FastAPI application entry point
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ routes.py             # API endpoint definitions
β”‚   β”‚   β”‚   └── schemas.py            # Pydantic models
β”‚   β”‚   β”œβ”€β”€ collectors/
β”‚   β”‚   β”‚   β”œβ”€β”€ cpu.py                # CPU metrics collector
β”‚   β”‚   β”‚   β”œβ”€β”€ disk.py               # Disk metrics collector
β”‚   β”‚   β”‚   β”œβ”€β”€ memory.py             # Memory metrics collector
β”‚   β”‚   β”‚   β”œβ”€β”€ network.py            # Network metrics collector
β”‚   β”‚   β”‚   β”œβ”€β”€ network_quality.py    # Network ping/latency
β”‚   β”‚   β”‚   β”œβ”€β”€ ports.py              # Port status checker
β”‚   β”‚   β”‚   β”œβ”€β”€ listening_ports.py    # All listening ports scanner
β”‚   β”‚   β”‚   └── processes.py          # Process monitoring
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py             # Application configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ logging.py            # Logging setup
β”‚   β”‚   β”‚   └── profiles.py           # Monitoring profile management
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ scheduler.py          # Background snapshot scheduler
β”‚   β”‚   β”‚   β”œβ”€β”€ ws_manager.py         # WebSocket connection manager
β”‚   β”‚   β”‚   β”œβ”€β”€ alert_state.py        # Alert state management
β”‚   β”‚   β”‚   β”œβ”€β”€ profile_state.py      # Profile state management
β”‚   β”‚   β”‚   β”œβ”€β”€ retention.py          # Data retention service
β”‚   β”‚   β”‚   └── docker_monitor.py     # Docker container monitoring
β”‚   β”‚   β”œβ”€β”€ storage/
β”‚   β”‚   β”‚   β”œβ”€β”€ db.py                 # Database initialization
β”‚   β”‚   β”‚   β”œβ”€β”€ snapshots.py          # Snapshot data operations
β”‚   β”‚   β”‚   β”œβ”€β”€ alerts.py             # Alert storage operations
β”‚   β”‚   β”‚   └── events.py             # Event timeline storage
β”‚   β”‚   └── web/
β”‚   β”‚       β”œβ”€β”€ static/
β”‚   β”‚       β”‚   β”œβ”€β”€ app.js            # Frontend JavaScript
β”‚   β”‚       β”‚   └── app.css           # Custom styles
β”‚   β”‚       └── templates/
β”‚   β”‚           └── dashboard.html    # Main dashboard template
β”‚   └── devwatchman.db                # SQLite database (auto-created)
β”‚
β”œβ”€β”€ devwatchman-desktop/              # Desktop application (Tauri)
β”‚   β”œβ”€β”€ backend/
β”‚   β”‚   β”œβ”€β”€ devwatchman/              # Same as web app backend
β”‚   β”‚   β”œβ”€β”€ run_devwatchman.py        # Desktop backend launcher
β”‚   β”‚   └── requirements.txt          # Python dependencies
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.ts                   # Tauri frontend entry
β”‚   β”‚   └── styles.css                # Desktop app styles
β”‚   β”œβ”€β”€ src-tauri/                    # Rust/Tauri configuration
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   └── main.rs               # Rust main file
β”‚   β”‚   β”œβ”€β”€ Cargo.toml                # Rust dependencies
β”‚   β”‚   └── tauri.conf.json           # Tauri configuration
β”‚   β”œβ”€β”€ index.html                    # Desktop app HTML
β”‚   β”œβ”€β”€ package.json                  # Node.js dependencies
β”‚   └── vite.config.ts                # Vite configuration
β”‚
β”œβ”€β”€ requirements.txt                  # Python dependencies (web app)
β”œβ”€β”€ .gitignore                        # Git ignore rules
└── README.md                         # This file

🎯 Use Cases

Development Environment Monitoring

  • Track resource usage during development
  • Monitor development server ports (3000, 5173, 8000)
  • Detect memory leaks in development
  • Network quality monitoring for remote development

Server Performance

  • Monitor production server health
  • Track system resource utilization
  • Historical performance analysis
  • Alert on critical resource thresholds

Network Diagnostics

  • Identify network quality issues
  • Monitor latency to external services
  • Detect connectivity problems
  • Track network bandwidth usage

Port Management

  • Ensure critical services are running
  • Monitor development tools (Vite, Node, Python servers)
  • Track database ports (SQL Server, RabbitMQ)
  • Detect port conflicts

Docker Container Monitoring

  • Real-time container status
  • Resource usage per container
  • Container health checks
  • Multi-container application monitoring

Resource Optimization

  • Identify resource bottlenecks
  • Track process-level resource usage
  • Historical trend analysis
  • Capacity planning

System Alerts

  • Get notified of critical system events
  • CPU/RAM threshold violations
  • Port availability monitoring
  • Network connectivity issues

πŸ“Š Performance

Metric Value Notes
Snapshot Interval 3 seconds Configurable in config.py
Database SQLite Lightweight with optimized queries
Memory Footprint < 50MB Typical usage in production
WebSocket Binary protocol Efficient bidirectional communication
API Response Time < 50ms Average for most endpoints
Historical Data Retention Configurable Default: automatic cleanup of old data
Concurrent WebSocket Connections Unlimited Limited by system resources
Database Size ~1MB/day Depends on snapshot interval and retention

πŸ› Troubleshooting

Port Already in Use

# Change the port in the uvicorn command
uvicorn app.main:app --port 8001

# Or find and kill the process using the port (Linux/macOS)
lsof -ti:8000 | xargs kill -9

# Windows
netstat -ano | findstr :8000
taskkill /PID <PID> /F

Database Issues

The database is automatically created on first run. If you encounter issues:

# Delete the database file to reset
rm devwatchman/devwatchman.db

# The database will be recreated on next startup

Permission Errors (Linux/macOS)

Some metrics may require elevated privileges:

# Run with sudo (not recommended for production)
sudo uvicorn app.main:app --host 0.0.0.0 --port 8000

# Better: adjust file permissions
chmod 644 devwatchman/devwatchman.db

WebSocket Connection Issues

  • Check firewall settings
  • Ensure port 8000 is open for WebSocket connections
  • Verify browser supports WebSockets
  • Check for proxy/reverse proxy configurations

Docker Monitoring Issues

# Ensure Docker daemon is running
docker info

# Check Docker permissions (Linux)
sudo usermod -aG docker $USER

# Restart the application after Docker changes

High CPU Usage

If DevWatchMan itself uses too much CPU:

# Increase snapshot interval in config.py
SNAPSHOT_INTERVAL_SECONDS = 5  # Instead of 3

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guide for Python code
  • Write meaningful commit messages
  • Add comments for complex logic
  • Test your changes thoroughly
  • Update documentation as needed

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘€ Author

Sakila Lakmal


πŸ™ Acknowledgments

  • FastAPI - For the amazing web framework
  • psutil - For comprehensive system monitoring capabilities
  • Chart.js - For beautiful, responsive charts
  • TailwindCSS - For the utility-first CSS framework
  • Tauri - For enabling cross-platform desktop applications
  • The open-source community for continuous inspiration

πŸ“ž Support

If you encounter any issues or have questions:

  1. Check the Troubleshooting section
  2. Search existing GitHub Issues
  3. Create a new issue with detailed information
  4. Include error logs and system information

⭐ Star this repository if you find it helpful!

Made with ❀️ by Sakila Lakmal

About

DevWatchMan is a comprehensive real-time system monitoring application built with FastAPI and modern web technologies. It provides live insights into your system's performance including CPU, memory, disk usage, network statistics, port monitoring, and intelligent alertingβ€”all through a beautiful, responsive web dashboard.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published