$ show cppla/ServerStatus
ServerStatus is a lightweight server monitoring and cloud dashboard system. It consists of a Go-based server that accepts TCP connections from Python clients, collects system metrics (CPU, memory, disk, network, processes, ping latency), and exposes a real-time JSON stats endpoint and a full REST management API. The server also supports service monitoring (HTTP/TCP probes), SSL certificate expiry checks, and a configurable watchdog rule engine that evaluates expressions against live metrics and triggers HTTP callbacks. The web UI is a single-page application with filtering, sorting, detail drawers, and an admin panel for CRUD operations on configuration. The architecture is a classic client-server model: multiple Python agents (client-linux.py or client-psutil.py) connect to a single Go server over a custom TCP protocol. The server authenticates agents, receives periodic metric updates, and serves a web dashboard and API. The Go server is a monolith with separate modules for HTTP handling, TCP agent handling, configuration management, SSL checking, and watchdog evaluation. It uses the Gin web framework for HTTP and the expr-lang library for rule evaluation. Key entry points are the TCP agent listener (port 35601), the HTTP server (port 80/8080), and the CLI flags for configuration. External dependencies include Go modules (gin, expr-lang), Python libraries (psutil for the psutil client), and Docker for containerized deployment. The system is designed for easy deployment via Docker Compose or shell scripts, with environment variable overrides for all client and server settings.
The LLM identified 4 files worth highlighting for reuse:
Implements a configurable watchdog rule engine that evaluates user-defined expressions (e.g., 'cpu>90&load_1>5') against live server metrics using the expr-lang library. Includes a legacy expression normalizer that converts single-character operators (&, |, =) to Go-compatible forms (&&, ||, ==). The compileWatchdog function compiles rules into reusable programs, and evaluateWatchdogs checks each node against all rules, respecting per-rule cooldown intervals. The sendCallback method delivers alerts via HTTP POST. This module is self-contained and could be extracted for any monitoring system that needs expression-based alerting.
Provides safe file writing utilities with atomic rename, automatic backups (with pruning to keep last 10), and a fallback for Docker single-file bind mounts where rename fails (EBUSY). The atomicWrite function writes to a temp file, syncs, renames, and syncs the directory. The writeConfig function creates timestamped backups before overwriting. This pattern is reusable for any application that needs crash-safe configuration persistence, especially in containerized environments.
Contains the configuration document model, normalization logic, and runtime config building. The normalizeConfig function validates and coerces all config fields (servers, monitors, sslcerts, watchdog) with proper defaults, range clamping (monthstart 1-28, port 1-65535), duplicate username detection, and integer/boolean normalization from JSON numbers. The buildRuntimeConfig compiles watchdog rules and returns a RuntimeConfig struct. This module is self-contained and demonstrates robust input validation patterns reusable in any Go application that manages JSON configuration.
A cross-platform Python client that collects system metrics using psutil (CPU, memory, disk, network, processes, threads) and performs TCP-based ping latency measurements to three targets (CU, CT, CM) in separate daemon threads. It also monitors custom services (HTTP/HTTPS/TCP) as defined by the server configuration. The client handles authentication, reconnection, and periodic updates via a custom TCP protocol. The code is well-structured with environment variable overrides, CLI argument parsing, and thread-safe network speed calculation. This client can be adapted for any monitoring system that needs a lightweight agent.