Skip to content

Commit

Permalink
allow to show versions when display cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar committed Nov 7, 2023
1 parent 8728297 commit 18ce732
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/cluster/command/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func newDisplayCmd() *cobra.Command {
cmd.Flags().BoolVar(&dopt.ShowProcess, "process", false, "display cpu and memory usage of nodes")
cmd.Flags().BoolVar(&dopt.ShowManageHost, "manage-host", false, "display manage host of nodes")
cmd.Flags().BoolVar(&dopt.ShowNuma, "numa", false, "display numa information of nodes")
cmd.Flags().BoolVar(&dopt.ShowVersions, "versions", false, "display component version of instances")
cmd.Flags().Uint64Var(&statusTimeout, "status-timeout", 10, "Timeout in seconds when getting node status")

return cmd
Expand Down
9 changes: 9 additions & 0 deletions pkg/cluster/manager/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type DisplayOption struct {
ShowProcess bool
ShowManageHost bool
ShowNuma bool
ShowVersions bool
}

// InstInfo represents an instance info
Expand All @@ -70,6 +71,7 @@ type InstInfo struct {
DeployDir string `json:"deploy_dir"`
NumaNode string `json:"numa_node"`
NumaCores string `json:"numa_cores"`
Version string `json:"version"`

ComponentName string
Port int
Expand Down Expand Up @@ -205,6 +207,9 @@ func (m *Manager) Display(dopt DisplayOption, opt operator.Options) error {
if dopt.ShowNuma {
rowHead = append(rowHead, "Numa Node", "Numd Cores")
}
if dopt.ShowVersions {
rowHead = append(rowHead, "Version")
}

rowHead = append(rowHead, "Data Dir", "Deploy Dir")
clusterTable = append(clusterTable, rowHead)
Expand Down Expand Up @@ -235,6 +240,9 @@ func (m *Manager) Display(dopt DisplayOption, opt operator.Options) error {
if dopt.ShowNuma {
row = append(row, v.NumaNode, v.NumaCores)
}
if dopt.ShowVersions {
row = append(row, v.Version)
}

row = append(row, v.DataDir, v.DeployDir)
clusterTable = append(clusterTable, row)
Expand Down Expand Up @@ -667,6 +675,7 @@ func (m *Manager) GetClusterTopology(dopt DisplayOption, opt operator.Options) (
Since: since,
NumaNode: utils.Ternary(ins.GetNumaNode() == "", "-", ins.GetNumaNode()).(string),
NumaCores: utils.Ternary(ins.GetNumaCores() == "", "-", ins.GetNumaCores()).(string),
Version: ins.CalculateVersion(base.Version),
})
mu.Unlock()
}, opt.Concurrency)
Expand Down

0 comments on commit 18ce732

Please sign in to comment.