This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
mpr-monitor is a FreeBSD monitoring dashboard for Broadcom/LSI SAS HBA (mpr and mps driver) DMA chain frame utilization. It tracks chain frame exhaustion which can cause I/O stalls on production storage servers.
Platform: FreeBSD 14.x, Python 3 (stdlib only, no external dependencies).
Three independent components with no shared state except CSV files:
-
Data Collector (
src/mpr_collect.sh) — Shell daemon that pollssysctl dev.mpr.N.*anddev.mps.N.*every 60 seconds and appends rows to per-controller CSV files in/var/log/mpr_monitor/. -
HTTP Server (
src/mpr_monitor_httpd.py) — Python stdlibhttp.serveron port 8080. Three routes:GET /→ servesindex.htmlGET /api/controllers→ JSON list of detected mpr/mps controllersGET /data/<name>_stats.csv→ CSV data (mpr0–5, mps0–5)
-
Dashboard (
src/index.html) — Single-file SPA using Chart.js (CDN). Parses CSV client-side, renders charts, auto-reloads every 30/60/300s. Health indicators are color-coded by lowwater percentage (green >50%, yellow 15–50%, red <15% or any alloc failures).
Data flow: sysctl → mpr_collect.sh → CSV files → mpr_monitor_httpd.py → index.html
- No build system, no package manager, no tests, no linter. This is a deployment-only project with ~1,200 lines total.
- Installation:
sh install.sh(as root on FreeBSD). Installs to/usr/local/share/mpr_monitor/and creates rc.d services. - Uninstall:
sh install.sh uninstall - Service control:
service mpr_collect start|stop|statusandservice mpr_monitor start|stop|status - The HTTP server runs as
nobody; the collector runs asroot(needs sysctl access). - CSV format:
timestamp,chain_free,chain_free_lowwater,chain_alloc_fail,io_cmds_active,io_cmds_highwater - Frontend downsamples data beyond 500 points. Time axis format switches based on data timespan.
- rc.d scripts are in
src/rc.d/and follow FreeBSDrc.subrconventions.