netwatch-sdk
The shared Rust SDK behind NetWatch Cloud — wire-format types and host-side collectors used by both netwatch-agent (runs on customer hosts) and the NetWatch Cloud SaaS backend.
This crate is the contract between agent and server. If you're writing an agent plugin, building a custom ingest pipeline, or wiring up a third-party client that should look like a NetWatch agent on the wire, this is the crate you depend on.
Install
[]
= "0.1"
Minimal example
use ;
See docs/architecture.md for the full collection cycle, docs/wire-format.md for the JSON payloads, and docs/collectors.md for every public function.
What's in the box
- Wire format —
IngestRequest,Snapshot,HostInfo,InterfaceMetric,HealthMetric,SystemMetric, plus collector-specific payloads. Allserde-derived, JSON-compatible, and forward-compatible: optional fields are#[serde(skip_serializing_if = "Option::is_none")]so old agents talk to new servers and vice versa. - Collectors — pure-Rust + targeted shell-outs for:
traffic— per-interface byte/packet counters with rolling rate history (stateful)connections— TCP/UDP socket enumeration viass(Linux) /lsof+nettop(macOS), with kernel-measured RTTprocess_bandwidth— per-process bandwidth attribution from connection countsnetwork_intel— port-scan, beacon, DNS-tunnel, and bandwidth-threshold detectors plus DNS analytics (stateful)health— gateway/DNS ICMP probing with rolling RTT historydisk,system,config— disk IO/usage, CPU/memory/load, gateway/DNS detection
- Platform shim — uniform
collect_interface_stats()across Linux (/sys/class/net) and macOS (netstat -ibn); soft fallback on other Unix-likes.
Documentation
- Architecture — how a snapshot gets built, stateful vs stateless collectors, agent/SDK/cloud topology.
- Wire format — every public type in
types.rswith field-by-field semantics. - Collectors reference — every public function across all collector modules.
- Platform support — what works where and how things degrade.
- Extending — adding a new collector, a new alert detector, or a new platform.
- Testing — running the suite and what's actually covered.
- Publishing — version bump, crates.io release.
- Roadmap — eBPF integration plan · test-coverage plan
Platform support
| Platform | Status |
|---|---|
| Linux | First-class — every collector implemented natively |
| macOS | First-class — uses lsof / nettop / vm_stat / sysctl |
| Windows | Not yet (collectors return empty / None; types remain compatible) |
Detail in docs/platform-support.md.
Relationship to other NetWatch projects
┌──────────────────────────┐ ┌───────────────────────┐
│ netwatch-agent (public) │ │ netwatch-cloud server │
│ https://github.com/ │ │ (private) │
│ matthart1983/ │◀─▶│ │
│ netwatch-agent │ │ │
└────────┬─────────────────┘ └──────────┬────────────┘
│ both depend on this crate │
▼ ▼
┌─────────────────────────────────────┐
│ netwatch-sdk (this crate) │
│ wire format + collectors │
└─────────────────────────────────────┘
- netwatch — the original OSS TUI. Unrelated code, similar purpose, kept separate intentionally.
- netwatch-agent — compiled binary you install on hosts; depends on this crate.
- netwatch-dashboard — Next.js web UI for NetWatch Cloud.
- netwatch-cloud — hosted SaaS backend (closed source).
License
MIT © 2025–2026 Matt Hartley