diff --git a/cmd/tableprinters/switch.go b/cmd/tableprinters/switch.go index bdcc4986..2b933f4e 100644 --- a/cmd/tableprinters/switch.go +++ b/cmd/tableprinters/switch.go @@ -210,9 +210,19 @@ func (t *TablePrinter) SwitchWithConnectedMachinesTable(data *SwitchesWithMachin nic := pointer.SafeDeref(conn.Nic) nicname := pointer.SafeDeref(nic.Name) nicstate := pointer.SafeDeref(nic.Actual) + bgpstate := pointer.SafeDeref(nic.BgpPortState) if nicstate != "UP" { nicname = fmt.Sprintf("%s (%s)", nicname, color.RedString(nicstate)) } + if bgpstate.BgpState != nil && wide { + switch *bgpstate.BgpState { + case "Established": + uptime := time.Since(time.Unix(*bgpstate.BgpTimerUpEstablished, 0)).Round(time.Second) + nicname = fmt.Sprintf("%s (BGP:%s(%s))", nicname, *bgpstate.BgpState, uptime) + default: + nicname = fmt.Sprintf("%s (BGP:%s)", nicname, *bgpstate.BgpState) + } + } if wide { emojis, _ := t.getMachineStatusEmojis(m.Liveliness, m.Events, m.State, pointer.SafeDeref(m.Allocation).Vpn) diff --git a/go.mod b/go.mod index 12ad6d40..5a2d65a2 100644 --- a/go.mod +++ b/go.mod @@ -177,3 +177,5 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect tailscale.com v1.74.1 // indirect ) + +replace github.com/metal-stack/metal-go => ../metal-go diff --git a/go.sum b/go.sum index 57a0e7ce..3494e55a 100644 --- a/go.sum +++ b/go.sum @@ -244,8 +244,6 @@ github.com/mdlayher/sdnotify v1.0.0 h1:Ma9XeLVN/l0qpyx1tNeMSeTjCPH6NtuD6/N9XdTlQ github.com/mdlayher/sdnotify v1.0.0/go.mod h1:HQUmpM4XgYkhDLtd+Uad8ZFK1T9D5+pNxnXQjCeJlGE= github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos= github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ= -github.com/metal-stack/metal-go v0.39.2 h1:E2iZ8f7Qo/z2ClbtICYu4iKn91zFv0RonFmuPlbC6tk= -github.com/metal-stack/metal-go v0.39.2/go.mod h1:ltItf/Md/z588c7Dr3X6iemCeOFh3rJ8nDL5Dpb9zFQ= github.com/metal-stack/metal-lib v0.19.0 h1:4yBnp/jPGgX9KeCje3A4MFL2oDjgjOjgsIK391LltRI= github.com/metal-stack/metal-lib v0.19.0/go.mod h1:fCMaWwVGA/xAoGvBk72/nfzqBkHly0iOzrWpc55Fau4= github.com/metal-stack/security v0.9.0 h1:FYBXJfNJwUw2E0HBa+jay37XF7b6EikEuf4Mw8u04EY=