Commit e6418f3
Add network deep diagnostics: NIC stats, conntrack, IRQ, softnet, TCP extended (#8)
* Add network deep diagnostics: NIC stats, conntrack, IRQ distribution, softnet, TCP extended
New data collection in network collector (Tier 1, procfs/sysfs):
NIC hardware details per interface:
- Driver, speed, queue count (rx/tx)
- Ring buffer current/max (ethtool -g)
- RX discards and buffer errors (ethtool -S)
- RPS enabled status, bond slave detection
Conntrack table stats:
- count/max/usage% from /proc/sys/net/netfilter/
- Anomaly detection at 70%/90% usage
IRQ distribution:
- Per-CPU NET_RX softirq delta (two-point sampling)
- Detects IRQ imbalance across CPUs
Softnet stats:
- Per-CPU processed/dropped/time_squeeze from /proc/net/softnet_stat
- Anomaly detection for softnet drops
Extended TCP stats from /proc/net/netstat TcpExt:
- ListenOverflows, ListenDrops (accept queue overflow)
- PruneCalled (TCP memory pressure)
- TCPOFOQueue (out-of-order packets)
- TCPAbortOnMemory
Additional sysctl reads:
- tcp_mem, tcp_max_tw_buckets, tcp_keepalive_time, netdev_budget
New anomaly thresholds:
- conntrack_usage_pct (70%/90%)
- softnet_dropped (1/10)
- listen_overflows (1/100)
- nic_rx_discards (100/10000)
New recommendations:
- Conntrack near full → increase nf_conntrack_max
- Ring buffer too small with rx_discards → ethtool -G
- ListenOverflows → add reuseport to nginx
- PruneCalled → increase tcp_mem
- conntrack, ring buffer, listen overflow explanations for MCP
All existing tests pass. New fields use omitempty for backward compatibility.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Review & expand network deep diagnostics: 32 anomaly rules, rate-based detection, full coverage
Code review fixes:
- Fix double sleep in IRQ distribution (was doubling collection time)
- Fix sysctl syntax for tcp_mem recommendation
- Fill ConntrackStats.Drops/InsertFailed/EarlyDrop from procfs
- Read NIC speed and MTU from sysfs
- Parameterize sysRoot for testability (NewNetworkCollectorFull)
New data sources:
- UDP stats from /proc/net/snmp (RcvbufErrors, SndbufErrors, InErrors)
- Socket memory from /proc/net/sockstat (TCP orphans, mem pages)
- TCP recv-side counters (TCPRcvQDrop, TCPZeroWindowDrop, TCPToZeroWindowAdv)
- Listen queue depths from ss -tnl (Recv-Q/Send-Q fill percentage)
- ESTABLISHED Recv-Q saturation from ss -tn
- NIC offloads (ethtool -k: TSO/GRO/GSO), coalescing (ethtool -c), XPS
- 15 new sysctls: rmem_max, wmem_max, netdev_max_backlog, ip_local_port_range,
tcp_fin_timeout, tcp_keepalive_intvl/probes, tcp_slow_start_after_idle,
tcp_fastopen, tcp_syncookies, tcp_notsent_lowat, default_qdisc, ARP gc_thresh
Rate-based detection (two-point sampling):
- Merge parseSNMP + parseUDPStats into single file read
- Two-point sampling for softnet_stat and /proc/net/netstat
- Rate fields: SoftnetDropRate, SoftnetSqueezeRate, ListenOverflowRate,
TCPAbortMemRate, UDPRcvbufErrRate, TCPRcvQDropRate, TCPZeroWindowDropRate
- Anomaly evaluators use per-second rates instead of cumulative counters
Anomaly rules (29 → 32):
- tcp_close_wait: CLOSE_WAIT socket accumulation (app not closing)
- softnet_time_squeeze: NAPI budget exhausted (rate-based)
- tcp_abort_on_memory: connections killed by memory pressure (rate-based)
- irq_imbalance: uneven NET_RX distribution with low-traffic guard
- udp_rcvbuf_errors: UDP receive buffer overflow (rate-based)
- tcp_rcvq_drop: app not reading from ESTABLISHED sockets (rate-based)
- tcp_zero_window_drop: receiver window=0, sender dropping (rate-based)
- listen_queue_saturation: accept queue fill % from ss -tnl
Recommendations:
- Add Type field ("fix" vs "optimization") to all 28 recommendations
- netdev_max_backlog, rmem_max/wmem_max, ip_local_port_range
- tcp_slow_start_after_idle, tcp_fastopen, netdev_budget
- UDP rmem_max, ARP gc_thresh for K8s/container environments
- Accept queue SO_REUSEPORT with per-socket evidence
- TCP zero-window: increase tcp_rmem + profile app
- ESTABLISHED Recv-Q saturation: identify slow reader process
Tests: 451 pass, 18 new test functions, testdata fixtures for
conntrack, softnet_stat, softirqs, netstat, sockstat, enrichNICDetails
Documentation (EN + RU):
- CLI help (man page): all tiers, deep diagnostics, 32 rules
- README: Manual Usage section with jq one-liners, 32 rules, 27 anti-patterns
- doc/en+ru chapters 5, 11, 12 fully rewritten
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: dmitriimaksimovdevelop <227611064+dmitriimaksimovdevelop@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 245a919 commit e6418f3
27 files changed
Lines changed: 2655 additions & 304 deletions
File tree
- cmd/melisai
- doc
- en
- ru
- internal
- collector
- mcp
- model
- scripts
- testdata/proc
- net
- sys/net/netfilter
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
129 | | - | |
| 131 | + | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
| |||
212 | 214 | | |
213 | 215 | | |
214 | 216 | | |
215 | | - | |
| 217 | + | |
216 | 218 | | |
217 | 219 | | |
218 | 220 | | |
| |||
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
232 | 243 | | |
233 | 244 | | |
234 | 245 | | |
235 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
236 | 358 | | |
237 | 359 | | |
238 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
43 | 63 | | |
44 | 64 | | |
45 | 65 | | |
| |||
60 | 80 | | |
61 | 81 | | |
62 | 82 | | |
63 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
64 | 99 | | |
65 | 100 | | |
66 | 101 | | |
| |||
0 commit comments