diff --git a/server/client.go b/server/client.go index 9f09283a..256a94cc 100644 --- a/server/client.go +++ b/server/client.go @@ -4521,6 +4521,8 @@ func (c *client) diagnosticsLoop() { } return } + // Log before populate, so that the previous metrics are available. + (&c.diagTCPData).LogInteresting(c, routeID, &c.diagMetrics) (&c.diagMetrics).PopulateFromTCPDiagnostics(&c.diagTCPData, expvarMaps, routeID) c.mu.Unlock() } @@ -4555,3 +4557,8 @@ func (c *client) Warnf(format string, v ...interface{}) { format = fmt.Sprintf("%s - %s", c, format) c.srv.Warnf(format, v...) } + +func (c *client) Fatalf(format string, v ...interface{}) { + format = fmt.Sprintf("%s - %s", c, format) + c.srv.Fatalf(format, v...) +} diff --git a/server/tcpinfo_linux.go b/server/tcpinfo_linux.go index e21ac9c4..557cc47f 100644 --- a/server/tcpinfo_linux.go +++ b/server/tcpinfo_linux.go @@ -170,3 +170,20 @@ func populateExpvarMapsTCPDiagnostics(maps *TCPInfoExpMaps, fullLabel string, me vm.Field(i).Interface().(*expvar.Map).Set(fullLabel, vmetrics.FieldByName(tm.Field(i).Name)) } } + +func (d *TCPDiagnostics) LogInteresting(log Logger, fullLabel string, previous *TCPInfoExpMetrics) { + if int64(d.Info.Pmtu) != previous.PathMTU.Value() { + log.Noticef("[SOCKET-DIAGNOSTICS] %q: Path MTU change: was %v now %v", + fullLabel, previous.PathMTU.Value(), d.Info.Pmtu) + } + if int64(d.Info.Lost) != previous.LostPackets.Value() { + v := previous.LostPackets.Value() + log.Warnf("[SOCKET-DIAGNOSTICS] %q: LOST PACKETS: was %v now %v INCREASE: %v", + fullLabel, v, int64(d.Info.Lost), v-int64(d.Info.Lost)) + } + if int64(d.Info.Total_retrans) != previous.TotalRetransPackets.Value() { + v := previous.TotalRetransPackets.Value() + log.Warnf("[SOCKET-DIAGNOSTICS] %q: total retransmission increase: was %v now %v INCREASE: %v", + fullLabel, v, int64(d.Info.Total_retrans), v-int64(d.Info.Total_retrans)) + } +} diff --git a/server/tcpinfo_other.go b/server/tcpinfo_other.go index 837bf563..e4ce706b 100644 --- a/server/tcpinfo_other.go +++ b/server/tcpinfo_other.go @@ -45,4 +45,6 @@ func NewTCPInfoExpMaps() *TCPInfoExpMaps { return &TCPInfoExpMaps{} } +func (d *TCPDiagnostics) LogInteresting(log Logger, fullLabel string, previous *TCPInfoExpMetrics) {} + // There will be other functions here, as we populate maps.