Commit graph

90 commits

Author SHA1 Message Date
1192774e30
Use build timestamp version in TUI display
The TUI agent state was using CARGO_PKG_VERSION (0.1.0) instead of
version::current_version() which returns the RFC 3339 build timestamp.
2026-02-10 07:51:52 -06:00
65fbf3bb31
use datestamp instead of creating a version 2026-02-09 13:49:19 -06:00
792825f682
major overhaul to use more C for snmp, may not be stable 2026-02-09 12:31:41 -06:00
cd45e9ff51
feat: add agent-side ICMP ping health monitoring
Implements health monitoring in the agent using ICMP ping, allowing
devices assigned to local (non-cloud) agents to be monitored.

Changes:
- Add surge-ping library for async ICMP ping operations
- Create ping.rs module with ping_device() function (5s timeout)
- Rename JobType::MONITOR to JobType::PING in protobuf
- Add monitoring_check channels for result communication
- Implement execute_ping_job() to handle PING jobs
- Update TUI to display ping result events

The agent now receives PING jobs from Phoenix, executes ICMP pings,
and sends MonitoringCheck results back for storage in the database.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-08 13:44:09 -06:00
cee0788300
format 2026-02-07 11:43:50 -06:00
f5b7e589f2
fix: implement agent IP detection and remove dead poller code
- Implement get_local_ip() using UDP socket trick to resolve local
  interface address without sending traffic, so heartbeat reports
  actual agent IP instead of "unknown"
- Remove dead poller/scheduler/executor and api_client modules that
  referenced non-existent modules and were never compiled
2026-02-07 09:17:47 -06:00
2111453653
Fix TUI 2026-02-06 13:18:23 -06:00
6275562f35
Resolve issues from TUI implementation 2026-02-06 13:08:06 -06:00
a2cef243ee
Handle discovered ip addresses 2026-02-06 12:20:53 -06:00
8c969401fb
fix live and scheduled polling 2026-02-05 12:45:13 -06:00
d44682ce9c
fix: increase SNMP timeout to 120s for SNMPv3 discovery
Discovery with SNMPv3 was completing in 52 seconds, dangerously close
to the 60s timeout. Increasing to 120s provides comfortable headroom
for complete MikroTik OID tree traversal with encryption overhead.
2026-02-05 09:02:05 -06:00
357d1711be
fix: increase SNMP timeout to 60s for SNMPv3 operations
SNMPv3 has significant encryption and authentication overhead compared to
v2c. MikroTik enterprise tree walks (1.3.6.1.4.1.14988) can take 16+
seconds with SNMPv3, causing timeouts with the previous 30s limit.

Increased timeout from 30s to 60s in both client.rs and device_poller.rs
to accommodate SNMPv3's additional latency.
2026-02-05 08:45:20 -06:00
c62330bf40
handle other encryption methods 2026-02-04 17:46:09 -06:00
55d55a2c86
fix tests 2026-02-04 17:29:19 -06:00
f454a1f7ea
experimental tcp snmp handling 2026-02-04 17:25:39 -06:00
df334e4db8
Security hardening and performance improvements 2026-02-04 16:50:36 -06:00
91913bd6e4
Implement snmp v3 support 2026-02-04 12:02:10 -06:00
1be76b0049
show partially redacted snmp community 2026-02-03 16:50:11 -06:00
0f19518065
snmpv3 first stab 2026-02-03 16:46:19 -06:00
4719bb8249
bump russh 2026-02-02 17:17:53 -06:00
89a53eb07a
fix snmp community redaction 2026-02-02 17:03:46 -06:00
78aee7ce40
add ssh support 2026-02-02 16:39:09 -06:00
8e8ea6426d
mikrotik api improvements 2026-02-02 14:02:27 -06:00
d137925a0f
update deps 2026-02-02 13:26:02 -06:00
575735b0da
Handle generic mikrotik commands 2026-02-02 13:18:31 -06:00
eb330b2f6f
protobufs update for mikrotik things 2026-02-02 12:25:40 -06:00
98d1bbbb21
structured logging 2026-01-31 15:40:42 -06:00
b8aecf0a55
more tests 2026-01-31 15:26:36 -06:00
4cd357777f
Add TRAP_ENABLED env var to conditionally enable trap listener 2026-01-31 14:39:24 -06:00
89adc3a6b3
Add SNMP trap listener for v1 and v2c traps
- Add trap.rs with BER/ASN.1 parser for SNMP trap PDUs
- Support both SNMPv1 and SNMPv2c trap formats
- Listen on configurable UDP port (default 162)
- Log received traps at INFO level
- Add LOG_LEVEL env var for log verbosity control
- Add TRAP_PORT env var and CLI flag
- Update docker-compose with trap port mapping
2026-01-31 14:14:56 -06:00
8ed2208271
poll each device simultaneously 2026-01-31 14:00:00 -06:00
bf1c6314cb
agent version tracking 2026-01-30 17:25:08 -06:00
c3e6e8c5b0
fix clippy error 2026-01-30 16:00:33 -06:00
380beaca1a
Agent overhaul with zero persistence 2026-01-30 15:50:20 -06:00
3793477e2f
relax ping failures 2026-01-29 12:12:01 -06:00
b8932f16b0
fix clippy issues 2026-01-29 12:02:20 -06:00
cee8d693da
make websocket client more robust 2026-01-29 11:55:01 -06:00
dbf66af5c0
support snmp v1 2026-01-29 11:28:45 -06:00
0548ca313d
include device id and ip in snmp error logs 2026-01-25 12:20:45 -06:00
cf08b0589b
cleanup 2026-01-24 12:43:24 -06:00
8ee809d21e
websocket improvements 2026-01-23 12:43:11 -06:00
9cb924fd77
connectivity improvements 2026-01-23 10:33:13 -06:00
ee7ce7fe00
feat: use system ping instead of raw ICMP sockets
- Replace raw ICMP socket implementation with system ping command
- Add regex-lite dependency for parsing ping output
- Add tokio process feature for async command execution
- Support macOS and Linux ping output formats
- Add iputils to Dockerfile for setuid-root ping
- Remove socket2 dependency (no longer needed)

This eliminates the need for CAP_NET_RAW capability in containers.
2026-01-21 13:11:24 -06:00
84b7519ad0
cargo clippy fix 2026-01-20 11:33:52 -06:00
6cea690e6b
format 2026-01-20 11:33:37 -06:00
71267870b0
refactor: remove log dependency, replace with custom macros
- Added custom logging macros (log_error!, log_warn!, log_info!, log_debug!)
- Implemented LogLevel enum and LOG_LEVEL static for runtime level control
- Exported macros with #[macro_export] for use across all modules
- Replaced all log:: calls in websocket_client.rs, health.rs, and version.rs
- Removed obsolete test code referencing old log crate
- Removed log dependency from Cargo.toml
- Fixed useless comparison warning in test
- Binary size: still 1.5M (no change - log was lightweight)
- Tests: 65 passing, 0 warnings

This completes the removal of 9 dependencies (thiserror, hostname, chrono,
base64, rand, ureq, tiny_http, anyhow, log). Dependency count: 19 → 10.

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 17:31:12 -06:00
0daaf9ed68
refactor: start replacing log crate with custom macros (WIP)
Added custom logging macros to main.rs to prepare for removing the
log crate dependency:
- Added LogLevel enum and LOG_LEVEL static
- Created log_error!, log_warn!, log_info!, log_debug! macros
- Replaced log calls in main.rs with custom macros
- Made format_timestamp() public for use in macros

Still TODO:
- Update websocket_client.rs, health.rs, version.rs
- Remove log from Cargo.toml

This is work in progress toward removing more dependencies.
2026-01-19 17:23:59 -06:00
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
d02193921d
Increase SNMP timeout from 5s to 30s to reduce timeout errors
Problem:
- Rust agent was experiencing frequent SNMP timeouts
- 5-second timeout is too aggressive for slow devices or congested networks
- Phoenix app uses 30-second timeout with better reliability

Solution:
- Increased SNMP_TIMEOUT_SECS constant from 5 to 30 seconds
- Applied to both get() and walk() operations
- Now matches Phoenix application timeout configuration

Benefits:
- Reduces false positive timeout errors
- Better handling of slow network devices
- Consistent timeout behavior across Elixir and Rust pollers
- Maintains reliability during network congestion

Note: SNMP timeout is per-request. Total polling time may still be
limited by Task::spawn_blocking timeout in poller executor (40s).

🤖 Generated with Claude Code
2026-01-19 17:17:45 -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