Commit Graph

11 Commits

Author SHA1 Message Date
505aede8d3 Fix config file loading and MQTT connection error handling
Config file loading fixes:
- Fix tilde expansion in config paths (~/.config/systant/systant.toml)
- Add detailed debug logging for config file search paths
- Properly expand home directory paths with System.user_home()

MQTT connection improvements:
- Add clearer connection status logging with broker host:port
- Improve error handling in connection callback
- Better error messages when connection fails or is lost
- More detailed initial connection logging

These fixes address production deployment issues where config files
aren't found and MQTT connection errors aren't properly reported.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-09 18:54:42 -07:00
8bbf91f25f Change Home Assistant device name and manufacturer/model 2025-08-08 21:17:46 -07:00
9dd21023ef Fix network throughput sensors having duplicate unique IDs
Both RX and TX sensors were using 'network' as value_template_path,
causing identical unique_ids and only one sensor to be created in HA.
Now using distinct paths: network.rx_throughput and network.tx_throughput.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 21:10:55 -07:00
0d3912ee44 Convert network throughput display from B/s to MB/s
Display network throughput in more readable MB/s units instead of B/s.
1,101,646.76 B/s becomes 1.05 MB/s for better readability in Home Assistant.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 21:08:28 -07:00
b8e7c48ecf Implement network throughput monitoring instead of cumulative bytes
- Add iftop as runtime dependency in package.nix and flake.nix
- Modify SystemMetrics to calculate network throughput (bytes/second)
- Track previous network stats in MQTT client state for throughput calculation
- Update Home Assistant discovery to show RX/TX throughput sensors
- Replace cumulative byte counters with real-time throughput metrics
- Add proper throughput calculation with time-based differentials

This provides much more useful real-time network monitoring compared
to ever-increasing cumulative byte counts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 21:02:29 -07:00
4ab0972870 Add Home Assistant MQTT auto-discovery integration
- Implement `Systant.HaDiscovery` module for automatic device registration
- Add comprehensive sensor discovery: CPU, memory, GPU, disk, network, temperature
- Update MQTT client to publish discovery messages on startup
- Add HomeAssistant configuration section to systant.toml
- Create example configuration file with localhost MQTT broker
- Update CLAUDE.md with complete HA integration documentation
- Add mosquitto to development dependencies for testing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 20:38:34 -07:00
fbd0c6dcf6 Complete secure MQTT command system with clean JSON responses
- Remove null error field from successful command responses for cleaner JSON
- Fix client_id consistency between MqttClient and MqttHandler for reliable publishing
- Add comprehensive command system documentation to CLAUDE.md:
  * User-configurable commands via systant.toml
  * Enterprise security features (whitelist-only, parameter validation, timeouts)
  * Simple command interface: {"command":"trigger","params":[...]}
  * Built-in commands and response format examples
  * Complete MQTT topic structure documentation

Command system now production-ready with:
 Secure execution (no arbitrary shell commands)
 Clean JSON responses (no null fields)
 Comprehensive logging and audit trail
 User-customizable command definitions
 Request/response correlation with auto-generated IDs

Ready for Home Assistant integration.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 22:40:26 -07:00
168b3558f7 Implement secure MQTT command execution system
- Add comprehensive command configuration to systant.toml with user-defined commands
- Create Systant.CommandExecutor module with strict security validation:
  * Whitelist-only command execution (no arbitrary shell commands)
  * Parameter validation against allowed lists
  * Command timeouts and confirmation requirements
  * Full audit logging and response tracking
- Implement Systant.MqttHandler for processing command messages:
  * JSON command parsing and validation
  * Response publishing to systant/{hostname}/responses topic
  * Built-in "list" command to show available commands
  * Error handling with detailed response messages
- Update MqttClient to use custom handler instead of Logger
- Security features:
  * Only predefined commands from TOML config
  * Parameter substitution with validation ($SERVICE, $PATH, etc.)
  * Execution timeouts and comprehensive logging
  * Structured response format with request tracking

Example commands configured: restart services, system info, disk usage, process status, network tests.
Users can customize commands in their systant.toml file.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 21:21:23 -07:00
b1cd085f6b Implement comprehensive TOML-based configuration system
- Add Systant.Config module for TOML configuration with environment overrides
- Create systant.toml template with all metric module controls
- Update SystemMetrics to use configuration-driven collection
- Add filtering for disks, network interfaces, and processes
- Implement per-module enable/disable controls
- Update MqttClient to use new configuration system
- Add Hivemind/Just development workflow integration
- Update dashboard with graphical metrics display and raw data toggle
- Comprehensive documentation updates in CLAUDE.md

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 21:02:02 -07:00
eff32b3233 Implement comprehensive system metrics collection with real-time monitoring
## System Metrics Collection
- Add SystemMetrics module with CPU, memory, disk, and system info collection
- Integrate Erlang :os_mon application (cpu_sup, memsup, disksup)
- Collect and format active system alarms with structured JSON output
- Replace simple "Hello" messages with rich system data in MQTT payloads

## MQTT Integration
- Update MqttClient to publish comprehensive metrics every 30 seconds
- Add :os_mon to application dependencies for system monitoring
- Maintain backward compatibility with existing dashboard consumption

## Documentation Updates
- Update CLAUDE.md with Phase 1 completion status and implementation details
- Completely rewrite README.md to reflect current project capabilities
- Document alarm format, architecture, and development workflow

## Technical Improvements
- Graceful error handling for metrics collection failures
- Clean alarm formatting: {severity, path/details, id}
- Dashboard automatically receives and displays real-time system data and alerts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 12:48:44 -07:00
b6769abbe9 Restructure as monorepo and add flake packages/apps
- Move Elixir code to server/ subdirectory for monorepo structure
- Update flake.nix to provide packages and apps outputs for nix run support
- Update nix/package.nix to accept src parameter instead of fetchgit
- Add NixOS module export for easy consumption

Now supports: nix run, nix build, and nix develop from git repo

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 19:54:17 -07:00