Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix column width for longer server names #3

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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