From f1a67d6a3f2a22f02adbe0b3036229636ed9a970 Mon Sep 17 00:00:00 2001 From: Anthrazz <25553648+Anthrazz@users.noreply.github.com> Date: Thu, 9 Feb 2023 18:26:58 +0100 Subject: [PATCH 1/2] use pointer receiver on all methods --- plugins/PingCollector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/PingCollector.go b/plugins/PingCollector.go index e0ede9b..ab15d43 100644 --- a/plugins/PingCollector.go +++ b/plugins/PingCollector.go @@ -80,7 +80,7 @@ func (p *PingCollector) getNewPinger() *ping.Pinger { return pinger } -func (p PingCollector) ExecuteTest() (DataPointInterface, error) { +func (p *PingCollector) ExecuteTest() (DataPointInterface, error) { pinger := p.getNewPinger() pinger.Run() // Blocks until finished. From 27b55ab6e34546195a1eb9ed7f7245370b6749c9 Mon Sep 17 00:00:00 2001 From: Anthrazz <25553648+Anthrazz@users.noreply.github.com> Date: Thu, 9 Feb 2023 18:27:39 +0100 Subject: [PATCH 2/2] fix column width for longer server names --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 0fc0e27..f59f320 100644 --- a/main.go +++ b/main.go @@ -104,8 +104,8 @@ func (gs *GlobalStateType) AddServer(ip string, testPlugin string) error { gs.Server = append(gs.Server, s) // set the length of the longest IP, needed for AutoScaleQueryHistory() - if len(ip) > gs.LongestIPLength { - gs.LongestIPLength = len(ip) + if len(s.TestPlugin.GetName()) > gs.LongestIPLength { + gs.LongestIPLength = len(s.TestPlugin.GetName()) } return nil @@ -120,7 +120,7 @@ func (gs *GlobalStateType) AutoScaleQueryHistory() { // Do not scale under 13 history entries because table header "QUERY HISTORY" // is 13 chars long, so we can use the already allocated space - if newSize > 13 { + if newSize > len("QUERY HISTORY") { gs.MaximumHistoryLength = newSize } } @@ -422,6 +422,7 @@ func renderRoutine(ctx context.Context, wg *sync.WaitGroup, commands <-chan Comm ) table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false}) table.SetCenterSeparator("|") + table.SetColWidth(globalState.LongestIPLength) for _, resolver := range globalState.Server {