Skip to content

Commit

Permalink
Merge pull request #3 from Anthrazz/fix-column-width
Browse files Browse the repository at this point in the history
Fix column width for longer server names
  • Loading branch information
Anthrazz authored Feb 9, 2023
2 parents c8ac895 + 27b55ab commit cfc2502
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion plugins/PingCollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit cfc2502

Please sign in to comment.