net/sockstats: expose debug info
Exposes some internal state of the sockstats package via the C2N and PeerAPI endpoints, so that it can be used for debugging. For now this includes the estimated radio on percentage and a second-by-second view of the times the radio was active. Also fixes another off-by-one error in the radio on percentage that was leading to >100% values (if n seconds have passed since we started to monitor, there may be n + 1 possible seconds where the radio could have been on). Updates tailscale/corp#9230 Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:

committed by
Mihai Parparita

parent
7c386ca6d2
commit
d0906cda97
@ -37,10 +37,19 @@ func TestRadioMonitor(t *testing.T) {
|
||||
"active, 10 sec idle",
|
||||
func(tt *testTime, rm *radioMonitor) {
|
||||
rm.active()
|
||||
tt.Add(10 * time.Second)
|
||||
tt.Add(9 * time.Second)
|
||||
},
|
||||
50, // radio on 5 seconds of 10 seconds
|
||||
},
|
||||
{
|
||||
"active, spanning two seconds",
|
||||
func(tt *testTime, rm *radioMonitor) {
|
||||
rm.active()
|
||||
tt.Add(1100 * time.Millisecond)
|
||||
rm.active()
|
||||
},
|
||||
100, // radio on for 2 seconds
|
||||
},
|
||||
{
|
||||
"400 iterations: 2 sec active, 1 min idle",
|
||||
func(tt *testTime, rm *radioMonitor) {
|
||||
@ -57,7 +66,7 @@ func TestRadioMonitor(t *testing.T) {
|
||||
{
|
||||
"activity at end of time window",
|
||||
func(tt *testTime, rm *radioMonitor) {
|
||||
tt.Add(2 * time.Second)
|
||||
tt.Add(1 * time.Second)
|
||||
rm.active()
|
||||
},
|
||||
50,
|
||||
|
Reference in New Issue
Block a user