Part 4 of #42. Each report now carries a dedup_key (tinker_tickets#123), so Tinker stops guessing "the same problem" from the title. Keys come from one function, SystemHealthMonitor.dedup_key_for, which reads both raw issue strings and the summary part of old ticket titles, so the backfill gives existing tickets exactly the key the daemon sends. - Ceph health warnings use the real health-check code (cluster:ceph:<CODE>), the key Thor uses, so Thor can adopt those tickets later. The daemon reads the code from `ceph health`; a message->code table covers old titles. - Unrecognised issues are sent without a key and keep the title hash. - scripts/dedup_key_map.py reads hwmonDaemon's tickets from Tinker (read only), keys the newest ticket per key, and writes the map for Tinker's scripts/backfill_dedup_keys.php. It reports anything it couldn't map. - README: key table and the merge -> map -> backfill runbook. Co-Authored-By: Claude Opus 5.5 <[email protected]>
12 KiB
System Health Monitoring Daemon
A robust system health monitoring daemon that tracks hardware status and automatically creates tickets for detected issues.
⚡ Quick run
Copy and paste on any Proxmox node (as root). No clone needed.
# Test it: prints the health summary and the tickets it WOULD create (nothing is sent)
python3 -c "import urllib.request; exec(urllib.request.urlopen('https://code.lotusguild.org/LotusGuild/hwmonDaemon/raw/branch/main/hwmonDaemon.py').read().decode('utf-8'))" --dry-run
# Run for real (creates tickets)
python3 -c "import urllib.request; exec(urllib.request.urlopen('https://code.lotusguild.org/LotusGuild/hwmonDaemon/raw/branch/main/hwmonDaemon.py').read().decode('utf-8'))"
# Install the systemd timer (hourly check)
curl -o /etc/systemd/system/hwmon.service https://code.lotusguild.org/LotusGuild/hwmonDaemon/raw/branch/main/hwmon.service && curl -o /etc/systemd/system/hwmon.timer https://code.lotusguild.org/LotusGuild/hwmonDaemon/raw/branch/main/hwmon.timer && systemctl daemon-reload && systemctl enable --now hwmon.timer
Why this exists
A six-node Proxmox/Ceph cluster fails in small, boring ways: a drive starts reallocating sectors, a node runs hot, a pool fills up, Ceph reports slow operations. Nobody watches a dashboard all day, and a naive alert that fires every hour buries the one that matters. hwmonDaemon runs on every node, checks the hardware, and files one ticket per real problem in Tinker Tickets, with the diagnosis already written up.
flowchart LR
subgraph node["each Proxmox node (systemd timer)"]
smart["SMART + drive usage"] --> detect
sys["memory / CPU load / ECC"] --> detect
net["management + Ceph network"] --> detect
ceph["Ceph health + OSDs"] --> detect
lxc["LXC storage"] --> detect
detect{{"Detect + filter<br/>sustained load, standing flags"}}
end
detect -->|"dedup key: category + host + device"| api["Tinker Tickets API"]
api -->|"open ticket exists"| upd["update it"]
api -->|"closed, problem recurs"| reopen["reopen it"]
api -->|"new problem"| new["create ticket"]
Design choices worth calling out:
- Dedup by hash of category + hostname + device, so a repeating alert updates the existing ticket and a recurrence reopens a closed one.
- Sustained, not spiky: CPU tickets are gated on the 15-minute load average per core, not a transient spike.
- Knows the cluster: a standing Ceph
nooutflag (set on purpose for a node without a UPS) is not ticketed. - Dry-run first:
--dry-runprints exactly what would be filed, which is how the screenshots below were produced (on a live node, with nothing sent).
Gallery
Output from a live node (micro1) in dry-run mode:
An issue was detected (Ceph reporting slow BlueStore operations), so the daemon renders the ticket it would create, including an executive summary and the cluster status:
Rendered from real command output with scripts/render_terminal.py.
Features
- Comprehensive system health monitoring:
- Drive health (SMART status and disk usage)
- Memory usage
- CPU utilization
- Network connectivity (Management and Ceph networks)
- Automatic ticket creation for detected issues
- Configurable thresholds and monitoring parameters
- Dry-run mode for testing
- Systemd integration for automated daily checks
- LXC container storage monitoring
- Historical trend analysis for predictive failure detection
- Manufacturer-specific SMART attribute interpretation
- ECC memory error detection
Installation
- Copy the service and timer files to systemd:
sudo cp hwmon.service /etc/systemd/system/
sudo cp hwmon.timer /etc/systemd/system/
- Reload systemd daemon:
sudo systemctl daemon-reload
- Enable and start the timer:
sudo systemctl enable hwmon.timer
sudo systemctl start hwmon.timer
One liner (run as root)
curl -o /etc/systemd/system/hwmon.service https://code.lotusguild.org/LotusGuild/hwmonDaemon/raw/branch/main/hwmon.service && curl -o /etc/systemd/system/hwmon.timer https://code.lotusguild.org/LotusGuild/hwmonDaemon/raw/branch/main/hwmon.timer && systemctl daemon-reload && systemctl enable hwmon.timer && systemctl start hwmon.timer
Manual Execution
Direct Execution (from local file)
- Run the daemon with dry-run mode to test:
python3 hwmonDaemon.py --dry-run
- Run the daemon normally:
python3 hwmonDaemon.py
Remote Execution (same as systemd service)
Execute directly from repository without downloading:
- Run with dry-run mode to test:
/usr/bin/env python3 -c "import urllib.request; exec(urllib.request.urlopen('https://code.lotusguild.org/LotusGuild/hwmonDaemon/raw/branch/main/hwmonDaemon.py').read().decode('utf-8'))" --dry-run
- Run normally (creates actual tickets):
/usr/bin/env python3 -c "import urllib.request; exec(urllib.request.urlopen('https://code.lotusguild.org/LotusGuild/hwmonDaemon/raw/branch/main/hwmonDaemon.py').read().decode('utf-8'))"
Configuration
The daemon monitors:
- Disk usage (warns at 80%, critical at 90%)
- LXC storage usage (warns at 80%, critical at 90%)
- Memory usage (warns at 80%)
- CPU usage (warns at 95%)
- Network connectivity to management (10.10.10.1) and Ceph (10.10.90.1) networks
- SMART status of physical drives with manufacturer-specific profiles
- Temperature monitoring (warns at 65°C)
- Automatic duplicate ticket prevention
- Enhanced logging with debug capabilities
Per-check ticket switches
Checks that can be seen from outside the host are moving to thor (#40, #42). Each one has a switch in /etc/hwmonDaemon/.env, so it can be turned off the day thor takes it over:
| Setting | Controls |
|---|---|
CPU_ENABLED |
"CPU usage sustained above threshold" tickets |
LXC_STORAGE_ENABLED |
LXC container storage tickets |
NETWORK_ENABLED |
"Management/Ceph network is unreachable" tickets |
CEPH_ENABLED |
All Ceph checks (this one skips the check entirely) |
All default to on. Accepted values are true/false, 1/0, yes/no and on/off. Anything else logs a warning and leaves the check on. When CPU_ENABLED, LXC_STORAGE_ENABLED or NETWORK_ENABLED is off, the check still runs and reports its metrics (dry-run summary, Prometheus), but it opens no tickets and no longer counts toward P1 escalation.
Data Storage
The daemon creates and maintains:
- Log Directory:
/var/log/hwmonDaemon/ - Historical SMART Data: JSON files for trend analysis
- Data Retention: 30 days of historical monitoring data
- Storage Limit: Automatically enforced 10MB maximum
- Cleanup: Oldest files deleted first when limit exceeded
Ticket Creation
The daemon automatically creates tickets with:
- Standardized titles:
[source][auto][hwmon][area] Summary [scope][environment][type], e.g.[compute-storage-01][auto][hwmon][hardware] Drive WD-WCC4N2FYYCXP has SMART issues [single-node][production][problem]. The[hwmon]tag names the app that opened the ticket and isn't part of Tinker's dedup hash. - A footer naming hwmonDaemon and the reporting host
- A
dedup_key(tinker_tickets#123) that decides which ticket a report lands on, so Tinker no longer guesses from the title
Dedup keys
Keys are scope:subject:kind and come from SystemHealthMonitor.dedup_key_for:
| Issue | Key |
|---|---|
| Drive SMART / temperature | drive:<serial>:smart, drive:<serial>:temperature (no serial: host:<host>:drive_sdX:smart) |
| ECC | host:<host>:ecc |
| CPU | host:<host>:cpu |
| Network reachability | host:<host>:mgmt_net_unreachable, host:<host>:ceph_net_unreachable |
| LXC storage | lxc:<vmid>:storage:<mount> (/ is root) |
| Kernel log errors | host:<host>:syslog:<error kind> |
| Ceph health warning | cluster:ceph:<CODE>, the same key Thor uses, so Thor can adopt the ticket |
| Ceph usage / HEALTH_ERR / OSD down | cluster:ceph:usage, cluster:ceph:HEALTH_ERR, cluster:ceph_osd:osd.N:down |
| PBS | pbs:zfs:<pool>:state / usage / errors, pbs:task:<type>:failed |
An issue that matches none of these is sent without a key and keeps Tinker's title hash.
Changing a key re-keys tickets. Existing tickets have to be given their keys in Tinker, or the next report opens a duplicate. Hosts run main straight from Gitea every hour, so merging is the deploy, and the backfill has to land between the merge and the next hourly run:
- Just after an hourly run finishes (a few minutes past the hour), merge.
- Build the map from Tinker (read only; uses
TICKET_API_KEYfrom/etc/hwmonDaemon/.env, or setTICKET_API_KEYin the environment):python3 scripts/dedup_key_map.py --out hwmon-keys.jsonIt lists every key, older tickets left alone, and any ticket it couldn't map (exit 1 if there are any). - On the Tinker host:
php scripts/backfill_dedup_keys.php --map=hwmon-keys.json --dry-run, check it, then run it without--dry-run. - After the next run, reports should come back as
updated/deduplicated, notcreated. If the backfill can't be done before the hour, revert the merge instead.
- Detailed descriptions of detected issues with drive specifications
- Priority levels based on severity (P2-P4)
- Proper categorization and status tracking
- Executive summaries and technical analysis
Dependencies
- Python 3
- Required Python packages:
- psutil
- requests
- System tools:
- smartmontools (for SMART disk monitoring)
- nvme-cli (for NVMe drive monitoring)
Excluded Paths
The following paths are automatically excluded from monitoring:
/media/*/mnt/pve/mediafs/*/opt/metube_downloads- Pattern-based exclusions for media and download directories
Application-Managed Volumes
Some mounts are expected to read nearly full, so df is the wrong signal. Sia's hostd
allocates its whole data.dat over time, then reuses freed slots. For mounts listed in
LXC_MANAGED_VOLUMES (currently /mnt/sia on LXC 141):
- The usual LXC thresholds apply to hostd's used/total sectors, read from its database in read-only mode.
- A critical ticket is created if the filesystem has less than
min_free_bytes(20 GiB) left. - If hostd's usage can't be read, the daemon logs a warning and only checks the free-space floor.
Service Configuration
The daemon runs:
- Hourly via systemd timer (with 60-second randomized delay)
- As root user for hardware access
- With automatic restart on failure
- 5-minute timeout for execution
- Logs to systemd journal
Recent Improvements
Version 2.0 (January 2026):
- ✅ Added 10MB storage limit with automatic cleanup
- ✅ File locking to prevent race conditions
- ✅ Disabled monitoring for unreliable Ridata drives
- ✅ Added timeouts to all network/subprocess calls (10s API, 30s subprocess)
- ✅ Fixed unchecked regex patterns
- ✅ Improved error handling throughout
- ✅ Enhanced systemd service configuration with restart policies
Troubleshooting
# View service logs
sudo journalctl -u hwmon.service -f
# Check service status
sudo systemctl status hwmon.timer
# Manual test run
python3 hwmonDaemon.py --dry-run
Security Note
Ensure proper network security measures are in place as the service downloads and executes code from a specified URL.
CI
| Workflow | Purpose | Triggers |
|---|---|---|
lint.yml |
flake8 on all .py files |
Every push and PR |
security.yml |
bandit -ll (medium+ severity) |
Every push, PR, and weekly Monday 6am |
Branch protection is enabled on main — the lint check must pass before any PR can merge.
Lint config: .flake8 (max-line-length 120, F841/E501 ignored).


