Commit Graph

54 Commits

Author SHA1 Message Date
01b20ef01c claude sucks 2025-08-10 20:59:54 -07:00
f3f8022aa3 test 2025-08-10 20:57:06 -07:00
ddec7ebe50 Try fix 2025-08-10 20:52:03 -07:00
0677fe39dd Fix command executor 2025-08-10 20:43:31 -07:00
983fc1cd29 Try fix nixosmodule 2025-08-10 20:39:45 -07:00
2d948073b2 Fix commands 2025-08-10 20:34:22 -07:00
988a38b1f9 Fix start argument by default issue 2025-08-09 19:26:39 -07:00
1b58dfad31 Implement graceful shutdown for MQTT connection failures
- Added connection verification with timeout-based validation on startup
- Enhanced error handling to catch Tortoise.publish_sync exceptions
- Graceful exit via System.stop(1) prevents erl_crash.dump files
- Added comprehensive logging for connection failures and shutdown reasons
- Updated CLAUDE.md to document graceful shutdown behavior

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-09 19:21:57 -07:00
f965bf5802 Add connection verification to prevent false success on MQTT failures
- Add wait_for_connection() to test actual MQTT connectivity after start_link
- Use publish_sync with timeout to verify broker is reachable
- Properly fail startup if MQTT broker is unavailable
- Add clear timeout and connection error messages

This fixes the issue where systant reported 'connected successfully'
even when the MQTT broker was unreachable.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-09 19:00:42 -07:00
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
bc7ac0c854 Update CLAUDE.md documentation for network throughput
Update documentation to reflect network throughput implementation:
- Network sensors now show real-time RX/TX throughput in MB/s
- Changed from cumulative byte counters to bandwidth monitoring
- Updated sensor descriptions and features list

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 21:12:57 -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
17b0f68d59 Remove unused iftop dependency
The network throughput implementation uses /proc/net/dev parsing
instead of iftop, so the iftop dependency is not needed.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 21:04:02 -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
f8a8421c2f Remove unused packages from flake.nix
- Remove postgresql (no database used)
- Remove aider-chat (not essential)
- Remove nodePackages.npm (redundant with nodejs)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 20:40:20 -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
3399947eb0 Add start command explicitly to nix run default app 2025-08-08 19:29:07 -07:00
28e9c06d92 Set elixirLS dir to server/ 2025-08-08 19:06:26 -07:00
014fd6eb4e Fix flake.nix head error 2025-08-08 19:05:16 -07:00
2c46141e47 Fix deps for nix run 2025-08-05 23:39:57 -07:00
7b5c653ed4 Obviously you should have pushed these, claude 2025-08-05 23:02:52 -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
616e3f3765 Enhanced dashboard with comprehensive metrics display
- Add GPU metrics display for NVIDIA and AMD cards with utilization, temperature, and memory
- Add Network interfaces display with RX/TX bytes and error tracking
- Add Temperature monitoring with CPU and sensor data
- Add Top processes display with CPU/memory usage
- Implement color-coded temperature indicators
- Add data formatting helpers for bytes, MB/GB, and percentages
- Conditional rendering for available metric modules
- Enhanced grid layout for optimal metrics viewing

Dashboard now displays all metric modules from the configuration system:
CPU load, memory usage, disk usage, GPU status, network I/O, temperatures, and top processes.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 21:06:50 -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
4a928b7067 Update CLAUDE.md and fix final Tortoise handler return value
- Add dashboard development commands (just dashboard, mix phx.server)
- Document Dashboard.Application and Dashboard.MqttSubscriber components
- Add comprehensive dashboard section with MQTT configuration details
- Include critical implementation notes for Tortoise handler return values
- Fix handle_message to return {:ok, state} instead of [] to prevent crashes

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-03 19:44:41 -07:00
c8e8e1dc24 Fix dashboard MQTT connection and remove simulation code
- Replace SimpleMqtt simulation with real MqttSubscriber
- Fix String.split bug when handling MQTT topic parsing
- Use hostname-based client ID to avoid MQTT client conflicts
- Add process management tools (hivemind, just) to development environment

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-03 19:39:59 -07:00
400270ae52 Commit from last night 2025-08-03 13:33:21 -07:00
96de648bca Add real-time MQTT-powered LiveView dashboard
Features:
- MQTT subscriber GenServer connects to mqtt.home
- Real-time host discovery via systant/+/stats topic
- LiveView with Phoenix PubSub for instant updates
- Host cards showing live data and last seen timestamps
- Clean UI with Tailwind styling
- Proper OTP supervision tree

Dashboard ready to receive live data from systant hosts!
Visit /hosts to see real-time monitoring.
2025-08-02 21:57:59 -07:00
9ae6a15970 Clean up stale directories and fix monorepo structure
- Remove remaining home-assistant-integration/ and dev-config/
- Move dashboard to repo root for proper monorepo layout
- Remove crash dumps and symlinks
- Clean structure: server/ and dashboard/ at root level
2025-08-02 21:53:53 -07:00
91559e7461 Remove HA/Python components and add Phoenix LiveView dashboard
- Remove home-assistant-integration/ and dev-config/
- Remove Python/HA dependencies from flake.nix
- Add Phoenix LiveView dashboard with clean Elixir-only stack
- Add Node.js and PostgreSQL for Phoenix development
- Much cleaner monorepo architecture focusing on Elixir ecosystem

Next: Connect dashboard to MQTT for real-time host monitoring
2025-08-02 21:52:19 -07:00
e7b0287847 Simplify HA dev config to work with core-only Nix package
- Remove frontend dependencies that aren't in Nix package
- Use minimal config with just HTTP, API, and MQTT
- Prepare for either Docker alternative or core-only testing
2025-08-02 21:15:46 -07:00
2491f8433b Fix flake.nix by removing non-existent pytest-homeassistant-custom-component package 2025-08-02 21:08:44 -07:00
8bf3f9e96a Update HA dev config to use existing mqtt.home broker
- Remove mosquitto from flake (use existing broker)
- Point dev config to mqtt.home instead of localhost
- Cleaner setup using your existing MQTT infrastructure
2025-08-02 21:01:45 -07:00
8a0fa9604c Add Home Assistant development environment to flake
- Add home-assistant and mosquitto to dev shell
- Create minimal dev-config/ for HA development instance
- Symlink custom integration for easy testing
- Add HA dev files to .gitignore
- No HA codebase committed, just references via Nix

Usage:
  nix develop
  hass --config ./dev-config

Features:
- Isolated from production HA instance
- MQTT broker for testing
- Debug logging enabled
- In-memory database for fast iteration
2025-08-02 21:00:07 -07:00
c7949285d1 Add Home Assistant custom integration for Systant
- Create basic integration structure with manifest.json
- Add config flow for easy setup via UI
- Implement MQTT-based host discovery and sensor creation
- Auto-discover Systant hosts via systant/+/stats topic
- Create device entities with last_seen sensor for each host
- Add Python tooling to flake.nix for HA development

Integration features:
- Automatic host discovery via MQTT
- Device representation for each monitored host
- Extensible sensor architecture
- Proper Home Assistant integration patterns
2025-08-02 20:19:57 -07:00
36e590becb Fix COOKIE issue by setting RELEASE_COOKIE environment variable
- Remove dummy COOKIE file creation (doesn't work in Nix store)
- Set RELEASE_COOKIE env var in wrapper script instead
- This follows NixOS best practices for Elixir releases
2025-08-02 20:14:24 -07:00
8cbad5c849 Create dummy COOKIE file in Nix package to avoid runtime error 2025-08-02 20:09:57 -07:00
495152826f Fix COOKIE error by disabling cookies in release config 2025-08-02 20:08:54 -07:00
9b3b7ab39b Add COOKIE workaround for Nix package 2025-08-02 20:06:57 -07:00
289bb00f82 Fix Nix build by removing accidentally committed build artifacts
- Remove server/_build/ and server/deps/ from git tracking
- Update .gitignore to properly ignore server build directories
- These directories caused symlink conflicts in Nix build

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 19:56:47 -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
46e585ec92 Clean up Nix configuration and remove old files
- Move Nix package and module to nix/ directory for better organization
- Remove old Nix files (systant.nix, systant-old.nix, etc.)
- Remove debug script and systemd service file
- Update config files for new Nix structure
- Add CLAUDE.md with project documentation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 19:41:40 -07:00
e217c7b180 Add flake.nix 2025-08-02 19:14:04 -07:00
d1e497cdc2 Add hostname-aware MQTT topics
- Topics now default to systant/{hostname}/stats and systant/{hostname}/commands
- Runtime config automatically includes system hostname in topics
- NixOS module defaults use config.networking.hostName
- Supports multiple hosts without topic conflicts
- Environment variables can still override if needed

Example: systant/orion/stats, systant/server2/stats, etc.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 18:59:46 -07:00
248f3f88e6 Bypass COOKIE file requirement in systemd service
Set RELEASE_COOKIE environment variable directly in systemd service
to prevent startup script from trying to read non-existent COOKIE file.

The environment variable takes precedence over file reading.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 18:20:08 -07:00
54f8d23945 Remove COOKIE complexity - disable distributed Erlang
- Remove explicit cookie configuration from release
- Set RELEASE_DISTRIBUTION=none and RELEASE_NODE=nonode@nohost
- Simplify Nix derivation by removing postInstall hooks
- Single standalone daemon doesn't need Erlang node clustering

Fixes persistent COOKIE file issues in Nix builds.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 18:15:11 -07:00