Commit Graph

22 Commits

Author SHA1 Message Date
98a4e76c05 docs: comprehensive README update for multi-device features
- Update GPU section for multi-vendor support (NVIDIA, AMD, Intel)
- Add Authentication section with local and LDAP documentation
- Add RBAC documentation with permission reference
- Add Log Collection section with agent configuration
- Expand API Reference with auth, users, roles, agents, logs endpoints
- Add Operational Modes section (standalone, server, agent)
- Add Database Configuration for SQLite and PostgreSQL
- Add Data Retention configuration reference
- Add Deployment section with PKI setup and agent configuration
- Update project structure to reflect new directories
- Update troubleshooting for multi-vendor GPU support

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 09:01:54 +01:00
62b2dad19d feat: add Docker Compose and installation scripts
Docker Compose:
- docker-compose.yml: Base configuration for development
  - Frontend (nginx) on port 3000
  - Backend (Go) on ports 8080 (HTTP) and 9849 (gRPC)
  - Volume mounts for /proc, /sys (system metrics)
  - Named volume for data persistence
  - Health check for backend
- docker-compose.prod.yml: Production overrides
  - Resource limits (CPU/memory)
  - Log rotation configuration

Installation Script (scripts/install.sh):
- One-line installation support via curl/wget
- Cross-platform: Linux (amd64, arm64, arm)
- Creates system user and directories
- Downloads and installs binary from GitHub releases
- Generates YAML configuration file
- Creates and enables systemd service
- Security hardening with systemd sandboxing
- Resource limits for production use

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 08:55:57 +01:00
014bc9bbb5 feat: add log collection and viewing system
Log Collectors (backend/internal/collectors/logs/):
- LogEntry model with level, source, message, fields
- Manager for coordinating multiple collectors
- JournalCollector: systemd journal via journalctl CLI
- FileCollector: tail log files with format parsing (plain, json, nginx)
- DockerCollector: docker container logs via docker CLI
- All collectors are pure Go (no CGO dependencies)

Database Storage:
- Add logs table with indexes for efficient querying
- StoreLogs: batch insert log entries
- QueryLogs: filter by agent, source, level, time, full-text search
- DeleteOldLogs: retention cleanup
- Implementations for both SQLite and PostgreSQL

Frontend Log Viewer:
- Log types and level color definitions
- Logs API client with streaming support
- /logs route with search, level filters, source filters
- Live streaming mode for real-time log tailing
- Paginated loading with load more

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 08:52:31 +01:00
c0dbf80521 feat(frontend): add authentication UI and admin pages
Frontend Auth System:
- Add auth types (User, Role, Permission, LoginResponse)
- Add auth API client with token injection (authApi, usersApi, rolesApi)
- Add auth store with localStorage persistence and expiration
- Add hasPermission/hasAnyPermission permission checks

Login Page:
- Create /login route with username/password form
- Auto-redirect if already authenticated
- Loading states and error handling

Admin Pages:
- Add /admin layout with route guards ($effect-based)
- Create users management page with CRUD modals
- Create roles management page with permission editor
- Category-based permission selection UI

Header Integration:
- Add UserMenu component with dropdown
- Show admin link for users with admin permissions
- Show Sign In link when not authenticated

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 08:40:59 +01:00
7b746643c7 feat: add RBAC with permission model and management APIs
RBAC System (internal/auth/):
- Permission constants for all resources (dashboard, agents, alerts, etc.)
- Wildcard permission support ("*" for admin, "category:*" for groups)
- Authorizer service with role-based permission checking
- RequirePermission middleware for route protection

Role Management API:
- GET /roles - List all roles
- GET /roles/:id - Get role details
- POST /roles - Create custom role
- PUT /roles/:id - Update role (custom only)
- DELETE /roles/:id - Delete role (custom only)

User Management API (admin):
- GET /users - List all users
- GET /users/:id - Get user details
- GET /users/:id/roles - Get user's roles
- POST /users - Create new user
- PUT /users/:id - Update user profile
- DELETE /users/:id - Disable user account
- POST /users/:id/enable - Re-enable user
- POST /users/:id/reset-password - Reset password
- PUT /users/:id/roles - Assign roles to user

Built-in Roles (via database migrations):
- admin: Full access (*)
- operator: Agent and alert management
- viewer: Read-only dashboard access

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 08:28:22 +01:00
50c5811e22 feat: add authentication system with local and LDAP support
Auth Package (internal/auth/):
- Service: main auth orchestrator with multi-provider support
- LocalProvider: username/password auth with bcrypt hashing
- LDAPProvider: LDAP/Active Directory authentication with:
  - Service account bind for user search
  - User bind for password verification
  - Automatic user provisioning on first login
  - Group membership to role synchronization
- SessionManager: token-based session lifecycle
- Middleware: Gin middleware for route protection
- API: REST endpoints for login/logout/register

Security Features:
- bcrypt with cost factor 12 for password hashing
- Secure random 32-byte session tokens
- HTTP-only session cookies with SameSite=Lax
- Bearer token support for API clients
- Session expiration and cleanup
- Account disable with session invalidation

API Endpoints:
- POST /auth/login - Authenticate and get session
- POST /auth/logout - Invalidate current session
- POST /auth/logout/all - Invalidate all user sessions
- POST /auth/register - Create account (if enabled)
- GET /auth/me - Get current user info
- PUT /auth/me - Update profile
- PUT /auth/me/password - Change password

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 08:24:39 +01:00
c0e678931d feat: add database layer with SQLite and PostgreSQL support
Database Package (internal/database/):
- Database interface abstraction for multiple backends
- SQLite implementation with pure Go driver (no CGO)
- PostgreSQL implementation with connection pooling
- Factory pattern for creating database from config
- Tiered retention with automatic aggregation:
  - Raw metrics: 24h (5s resolution)
  - 1-minute aggregation: 7 days
  - 5-minute aggregation: 30 days
  - Hourly aggregation: 1 year

Schema includes:
- agents: registration, status, certificates
- users: local + LDAP authentication
- roles: RBAC with permissions JSON
- sessions: token-based authentication
- metrics_*: time-series with aggregation
- alerts: triggered alerts with acknowledgment

Configuration Updates:
- DatabaseConfig with SQLite path and PostgreSQL settings
- RetentionConfig for customizing data retention
- Environment variables: TYTO_DB_*, TYTO_DB_CONNECTION_STRING
- Default SQLite at /var/lib/tyto/tyto.db

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 08:18:48 +01:00
50a7a774ea feat: add multi-device frontend dashboard
Devices Store (stores/devices.ts):
- Device state management with Map<deviceId, DeviceMetrics>
- View mode: overview (device grid) vs detail (single device)
- Per-device history tracking for sparklines
- Device sorting by status (online first) then hostname

Multi-Device Types (types/metrics.ts):
- DeviceMetrics with status (online/degraded/offline)
- MultiDeviceMessage union type for SSE messages
- DeviceStatusChange for connect/disconnect events

Device Components:
- DeviceCard: Compact device summary with CPU/RAM/GPU bars
- DeviceGrid: Responsive grid of all connected devices
- FleetStatusBar: Shows device counts and navigation breadcrumb

SSE Handler Updates:
- Auto-detect multi-device vs single-device mode
- Route messages to appropriate handler
- Clear devices on host switch

View Mode Routing:
- Overview mode: Shows DeviceGrid with all devices
- Detail mode: Shows full dashboard for selected device
- Seamless transition between modes
- Device selection updates the metrics store for dashboard cards

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 08:05:09 +01:00
80f6e788f4 feat: implement server hub for multi-device agent management
Server Package (internal/server/):
- Registry: Agent registration with approval workflow, persistence
- Hub: Connection manager for connected agents, message routing
- GRPCServer: mTLS-enabled gRPC server with interceptors
- SSEBridge: Bridges agent metrics to browser SSE clients

Registry Features:
- JSON file-based persistence
- Agent lifecycle: pending -> approved -> connected -> offline
- Revocation support for certificate-based agent removal
- Automatic last-seen tracking

Hub Features:
- Bidirectional gRPC stream handling
- MetricsSubscriber interface for metric distribution
- Stale connection detection and cleanup
- Broadcast and per-agent command sending

gRPC Server:
- Unary and stream interceptors for auth
- Agent ID extraction from mTLS certificates
- Delegation to Hub for business logic

Agent Management API:
- GET/DELETE /api/v1/agents - List/remove agents
- GET /api/v1/agents/pending - Pending approvals
- POST /api/v1/agents/pending/:id/approve|reject
- GET /api/v1/agents/:id/metrics - Latest agent metrics
- GET /api/v1/agents/connected - Connected agents

Server Mode Startup:
- Full initialization of registry, hub, gRPC, SSE bridge
- Graceful shutdown with signal handling
- Agent mode now uses the agent package

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 07:53:23 +01:00
5e781c0e04 feat: implement lightweight agent with gRPC and mTLS support
Agent Package (internal/agent/):
- Agent struct with all collectors and memory-efficient pooling
- Run loop with configurable collection interval
- Graceful shutdown with context cancellation
- Auto-reconnection callback for re-registration

gRPC Client (internal/agent/client.go):
- mTLS support with CA, agent cert, and key
- Bidirectional streaming for metrics
- Heartbeat fallback when streaming fails
- Exponential backoff with jitter for reconnection
- Concurrent reconnection handling with mutex

Protocol Buffers (proto/tyto.proto):
- AgentService with Stream, Register, Heartbeat RPCs
- MetricsReport with summary fields for aggregation
- ConfigUpdate and Command messages for server control
- RegisterStatus enum for registration workflow

CLI Integration (cmd/tyto/main.go):
- Full agent subcommand with flag parsing
- Support for --id, --server, --interval, --ca-cert, etc.
- Environment variable overrides (TYTO_AGENT_*)
- Signal handling for graceful shutdown

Build System (Makefile):
- Cross-compilation for linux/amd64, arm64, armv7
- Stripped binaries with version info
- Proto generation target
- Test and coverage targets

Config Updates:
- DefaultConfig() and LoadFromPath() functions
- Agent config properly parsed from YAML

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 07:42:44 +01:00
c8fbade575 feat: add PKI infrastructure for mTLS authentication
PKI Package (internal/pki/):
- CA initialization with configurable validity and key size
- Server certificate generation with DNS/IP SANs
- Agent certificate generation (agent ID in CN)
- Certificate revocation list (CRL) support
- mTLS TLS configuration helpers
- File-based certificate store with JSON persistence

CLI Commands (cmd/tyto/):
- `tyto pki init-ca` - Initialize new Certificate Authority
- `tyto pki gen-server` - Generate server certificate
- `tyto pki gen-agent` - Generate agent certificate
- `tyto pki revoke` - Revoke certificate by serial
- `tyto pki list` - List all certificates
- `tyto pki info` - Show CA information

Security Features:
- RSA 4096-bit keys by default
- TLS 1.2 minimum version
- Client certificate verification for mTLS
- CRL checking in TLS handshake
- Agent ID extraction from verified certificates

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 07:29:42 +01:00
a0a947094d feat: add multi-GPU support and operational modes
Multi-GPU Collection System:
- Add modular GPU collector architecture in collectors/gpu/
- Support AMD (amdgpu), NVIDIA (nvidia-smi), and Intel (i915/xe) GPUs
- GPU Manager auto-detects and aggregates all vendor collectors
- Backward-compatible JSON output for existing frontend

Operational Modes:
- Standalone mode (default): single-host monitoring, no database
- Server mode: multi-device with database, auth, agents (WIP)
- Agent mode: lightweight reporter to central server (WIP)
- Mode selection via TYTO_MODE env var or config.yaml

Configuration Updates:
- Add server config (gRPC port, mTLS settings, registration)
- Add agent config (ID, server URL, TLS certificates)
- Add database config (SQLite/PostgreSQL support)
- Support TYTO_* prefixed environment variables

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 07:21:50 +01:00
62219ea97a fix: add settings button to header and fix page title
- Add gear icon button to open settings/export panel (desktop + mobile)
- Fix page title from "System Monitor" to "Tyto" in +page.svelte

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 06:43:40 +01:00
a2504c1327 feat: rename project to Tyto with owl branding
- Rename project from system-monitor to Tyto (barn owl themed)
- Update Go module name and all import paths
- Update Docker container names (tyto-backend, tyto-frontend)
- Update localStorage keys (tyto-settings, tyto-hosts)
- Create barn owl SVG favicon and PWA icons (192, 512)
- Update header with owl logo icon
- Update manifest.json and app.html with Tyto branding

Named after Tyto alba, the barn owl — nature's silent, watchful guardian

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 06:36:01 +01:00
2f8d19cfdd docs: add comprehensive README with shields and LICENSE
- Add README with shields.io badges for Go, SvelteKit, Docker
- Document quick start with Docker Compose
- Add multi-host monitoring setup guide with network diagram
- Include full API reference with endpoint table
- Add configuration section with environment variables
- Document keyboard shortcuts and alert configuration
- Add troubleshooting section with collapsible details
- Include MIT LICENSE file

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 06:19:16 +01:00
b0c500e07b feat: add process details, notifications, export, multi-host support
- Add per-process details modal with kill/pause/resume functionality
  - GET /api/v1/processes/:pid for detailed process info
  - POST /api/v1/processes/:pid/signal for sending signals
  - ProcessDetailModal component with state, resources, command line

- Add desktop notifications for alerts
  - Browser Notification API integration
  - Toggle in AlertsCard with permission handling
  - Auto-close for warnings, persistent for critical

- Add CSV/JSON export functionality
  - GET /api/v1/export/metrics?format=csv|json
  - Export buttons in SettingsPanel
  - Includes host name in filename

- Add multi-host monitoring support
  - HostSelector component for switching between backends
  - Hosts store with localStorage persistence
  - All API calls updated for remote host URLs

- Add disk I/O rate charts to HistoryCard
  - Read/write bytes/sec sparklines
  - Complements existing network rate charts

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 06:08:43 +01:00
1e83819318 feat: add unit tests for backend collectors and frontend
Backend tests:
- CPU, memory, disk, network collector tests (existing)
- Added temperature, processes, system, AMD GPU collector tests
- All tests use mock filesystem data

Frontend tests:
- Added Vitest with jsdom environment
- Tests for formatters (formatBytes, formatUptime, etc.)
- Tests for theme store

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 05:49:26 +01:00
247b7f2fe6 fix: make SparkLine SVG responsive with viewBox
SVG was using fixed width/height attributes causing clipping in
smaller containers. Now uses viewBox for coordinate system and
w-full h-full classes to fill container properly.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 05:41:58 +01:00
407ba8224b fix: sync refresh rate from frontend to backend on SSE connect
When container restarts, backend resets to default 5s interval but
frontend still shows the user's stored preference from localStorage.

Now on SSE connect, frontend pushes its stored refresh rate to the
backend, ensuring they stay in sync after container rebuilds.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 05:39:51 +01:00
d9cc4f39dd fix(mobile): prevent sparkline chart overflow on small screens
- Add min-w-0 to flex containers to allow proper shrinking
- Hide sparklines below 400px viewport width
- Add flex-shrink-0 and overflow-hidden to sparkline containers
- Reduce font sizes and gaps on mobile for better fit

Affects CpuCard, MemoryCard, and GpuCard sparkline displays.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 05:38:33 +01:00
f4dbc55851 feat: add dashboard customization, alerts, PWA, and mobile support
Dashboard Editor & Layout:
- Full-screen visual editor for reorganizing cards
- Drag-and-drop cards between sections
- Toggle card visibility with persistence to localStorage
- Reset to default layout option

Alerts System:
- Threshold-based alerts for CPU, memory, temperature, disk, GPU
- Alert manager with duration requirements
- AlertsCard component with settings UI
- API endpoints for alerts CRUD

New Collectors:
- Docker container monitoring with parallel stats fetching
- Systemd service status via D-Bus
- Historical metrics storage (1 hour at 1s intervals)

PWA Support:
- Service worker with offline caching
- Web app manifest with SVG icons
- iOS PWA meta tags

Mobile Responsive:
- Collapsible hamburger menu on mobile
- Adaptive grid layouts for all screen sizes
- Touch-friendly hover states
- Safe area insets for notched devices

UI Enhancements:
- Light/dark theme toggle with persistence
- Keyboard shortcuts (T=theme, R=refresh, ?=help)
- Per-process expandable details in ProcessesCard
- Sparkline charts for historical data

Performance Fixes:
- Buffered SSE channels to prevent blocking
- Parallel Docker stats collection with timeout
- D-Bus timeout for systemd collector

Tests:
- Unit tests for CPU, memory, network collectors
- Alert manager tests

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 05:35:28 +01:00
38a598baaa Initial commit: System monitor web application
Full-stack system monitoring dashboard for Linux with AMD GPU support.

Features:
- Real-time metrics via Server-Sent Events (SSE)
- CPU usage per core with frequency and load averages
- Memory and swap utilization
- Disk usage and I/O activity
- Network interfaces with traffic stats
- Process list sorted by CPU or memory
- Temperature sensors (CPU, GPU, NVMe, motherboard)
- AMD GPU monitoring (utilization, VRAM, temp, clocks, power, fan)
- Configurable refresh rate (1-60 seconds)

Stack:
- Backend: Go + Gin, reading from /proc and /sys
- Frontend: SvelteKit 5 + Tailwind CSS
- Deployment: Docker Compose with host volume mounts

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 04:26:11 +01:00