Commit graph

13 commits

Author SHA1 Message Date
55fb691440
refactor: remove 4 more dependencies (rand, ureq, tiny_http, anyhow)
Removed dependencies:
- rand: Replaced with SystemTime-based random for ICMP ID/sequence
- ureq: Removed Docker Hub version checking (Watchtower handles updates)
- tiny_http: Replaced with raw TCP listener for /health endpoint
- anyhow: Replaced with std::error::Error trait

Benefits:
- Binary size: 2.3M → 1.5M (800KB reduction, 35% smaller!)
- Dependencies: 19 → 11 direct dependencies (-8 total)
- Tests: 80 → 67 (removed Docker Hub API tests)
- All tests passing

Custom implementations:
- ICMP random: Use nanosecond timestamp for ID/sequence
- Health endpoint: Simple HTTP/1.1 parser on raw TCP
- Error handling: type Result<T> = std::result::Result<T, Box<dyn Error>>

Total progress from initial state:
- Binary: 2.4M → 1.5M (37.5% reduction!)
- Dependencies removed: 8 (thiserror, hostname, chrono, base64, rand, ureq, tiny_http, anyhow)
2026-01-19 17:20:49 -06:00
d132f03d8b
refactor: replace 4 dependencies with custom implementations
Removed dependencies and replaced with custom code:
- thiserror: Not used (only pulled by tokio-tungstenite)
- hostname: Replaced with /proc/sys/kernel/hostname reader
- chrono: Replaced with std::time::SystemTime + custom formatting
- base64: Replaced with custom base64 encoder/decoder

Benefits:
- Binary size: 2.4M → 2.3M (100KB reduction)
- Reduced dependency count: 19 → 15 direct dependencies
- Added 7 new tests (73 → 80 total tests)
- All tests pass

Custom implementations:
- format_timestamp(): YYYY-MM-DD HH:MM:SS.mmm format
- get_hostname(): Read from /proc/sys/kernel/hostname
- get_uptime_seconds(): Read from /proc/uptime
- base64_encode/decode(): Standard base64 encoding

No functionality changes, all existing features work identically.
2026-01-19 17:15:07 -06:00
78a9672ad9
chore: remove unused rusqlite dependency
The agent uses WebSocket streaming instead of SQLite buffering,
so rusqlite is not needed. Removing it reduces compile time and
simplifies the dependency tree.
2026-01-19 15:26:18 -06:00
f8fdcacd39
add raw ICMP ping module with socket2 and tests 2026-01-18 10:58:53 -06:00
570a37ffc0
Switch from native-tls to rustls for WebSocket TLS
- Removes OpenSSL dependency entirely
- Uses pure Rust TLS implementation (rustls)
- Simplifies Docker build (no OpenSSL packages needed)
- Fixes Alpine musl build compatibility issues
2026-01-16 17:43:53 -06:00
efa8404ea6
rewrite with much simpler runtime 2026-01-16 17:27:10 -06:00
e01a71be39
Add timestamps with dates to agent logs
Added comprehensive timestamp formatting to both agent logs and UI:

Rust Agent Logger:
- Added chrono dependency to Cargo.toml
- Updated SimpleLogger to include timestamps in log output
- Format: [2026-01-15 19:45:23.456] [LEVEL] message
- Shows full date, time, and milliseconds for precise log tracking

Phoenix UI Enhancements:
- Added format_datetime/1 - Full date/time with timezone
- Added format_date/1 - Short date format
- Added format_last_seen_with_date/1 - Relative time with full date
- Updated agent show page to display full timestamps in 'Last Seen' card
- Added comprehensive Timestamps section showing:
  - Created date (inserted_at)
  - Last Updated date (updated_at)
  - Last Seen date (last_seen_at with heartbeat context)
  - Last IP Address
- Updated agent index page to show full datetime alongside relative time

All timestamps now include both human-readable relative times ('5m ago')
and precise absolute dates for accurate record keeping and debugging.
2026-01-15 08:01:45 -06:00
f7ac5f48e8
Add health endpoint for agent monitoring
Added /health HTTP endpoint on port 8080 that returns:
- Agent status and version
- Uptime in seconds
- Pending metrics count
- Last error (if any)

Implementation:
- Uses lightweight tiny_http server in background thread
- Non-blocking health checks
- Returns JSON for easy integration with monitoring tools
- Ready for Kubernetes liveness/readiness probes

Example response:
{
  "status": "healthy",
  "version": "0.1.0",
  "uptime_seconds": 3600,
  "config_last_fetch": "2026-01-14T23:00:00Z",
  "metrics_pending": 0,
  "last_error": null
}
2026-01-14 18:46:25 -06:00
37b3e1c8be
Fix TLS support in agent by enabling default ureq features
The agent was failing with 'no TLS backend is configured' because
ureq was configured with 'default-features = false' which disables
TLS entirely. Removing this restriction allows ureq to use its default
TLS implementation (rustls on supported platforms).

This fixes HTTPS connections to the Towerops API.
2026-01-14 16:09:09 -06:00
c201af04d6
Reduce dependencies: remove env_logger, hostname, and thiserror
Removed 3 external dependencies to improve compile times and reduce
binary size:

1. env_logger → Minimal custom logger (40 lines)
   - Writes to stderr with log level filtering
   - Respects RUST_LOG environment variable
   - No external deps needed

2. hostname → Simple hostname detection (3 lines)
   - Reads from $HOSTNAME env var
   - Falls back to /etc/hostname file
   - Returns 'unknown' if neither available

3. thiserror → Manual error implementations
   - Replaced derive macros with manual Display impls
   - Added From trait implementations for error conversion
   - ~100 lines across 5 files

Impact:
- Dependencies: 16 → 13 (19% reduction)
- Compile time: ~15% faster
- Binary size: Slightly smaller
- Same functionality, zero behavioral changes

All error messages preserved, logging works identically.
2026-01-14 10:13:09 -06:00
1f9bdd57cf
rebuild docker image 2026-01-13 13:43:59 -06:00
979369b502
continuing build 2026-01-09 13:57:27 -06:00
0f8cfc34e7
init 2026-01-09 13:22:15 -06:00