$ show nicolargo/glances
Glances is a cross-platform, real-time system monitoring tool written in Python. It collects system metrics (CPU, memory, disk, network, processes, sensors, containers, GPU, NPU, etc.) via the `psutil` library and optional hardware-specific backends, and renders them through multiple interfaces: a curses-based terminal UI, a web UI (Vue.js + FastAPI REST API), a pure JSON/CSV stdout mode, a Model Context Protocol (MCP) server for AI assistant integration, and exports to 20+ time-series databases and message brokers (InfluxDB, Prometheus, Kafka, Elasticsearch, etc.). The architecture is modular and plugin-based: each metric domain is a self-contained plugin inheriting from a common base class, and each export target is a separate module. Glances can run standalone (local monitoring), in client/server mode (XML-RPC or REST), or as a central browser that discovers and displays multiple Glances instances via Zeroconf. The project is production-grade, with extensive test coverage, CI/CD across multiple OSes, Docker images, and active security maintenance. Its primary use case is real-time monitoring of single or distributed systems, with optional historical data export for long-term analysis.
The LLM identified 5 files worth highlighting for reuse:
Base class for all Glances plugins. Provides decorators for refresh timing, rate computation, min/max/mean tracking, result logging, and input validation. Implements a consistent interface for update(), update_views(), get_export(), and alert threshold handling. The pattern is reusable for any plugin-based monitoring system and demonstrates clean separation of concerns.
Base class for all export modules. Handles configuration loading, field filtering, InfluxDB line protocol normalization, and a common export() interface. The {build_export} and {normalize_for_influxdb} methods are particularly reusable for any system that needs to export structured data to multiple backends.
Provides a secure implementation of subprocess execution (secure_popen) that mitigates shell injection by controlling operator usage. The allow_operators flag and argument validation pattern are directly reusable in any Python application that needs to execute user-influenced commands safely.
Implements a directed acyclic graph (DAG) for plugin dependency resolution. Used to ensure plugins are updated in the correct order based on their dependencies. The DAG class is standalone and can be extracted for any project needing dependency ordering.
Simple Timer and Counter classes for measuring elapsed time and counting iterations. Used extensively for refresh interval management and performance measurement. Self-contained and reusable in any Python project needing precise timing utilities.