change grctl cluster command

This commit is contained in:
barnettZQG 2020-02-09 21:22:19 +08:00
parent 7e876b223f
commit 2c48069187

View File

@ -21,6 +21,7 @@ package cmd
import (
"fmt"
"os"
"os/exec"
"strconv"
"strings"
@ -88,22 +89,8 @@ func getClusterInfo(c *cli.Context) error {
}())+"%")
fmt.Println(table)
//show services health status
allNodeHealth, err := clients.RegionClient.Nodes().GetAllNodeHealth()
handleErr(err)
serviceTable2 := termtables.CreateTable()
serviceTable2.AddHeaders("Service", "HealthyQuantity/Total", "Message")
serviceStatusInfo := allNodeHealth
status, message := clusterStatus(serviceStatusInfo["Role"], serviceStatusInfo["Ready"])
serviceTable2.AddRow("\033[0;33;33mClusterStatus\033[0m", status, message)
for name, v := range serviceStatusInfo {
if name == "Role" {
continue
}
status, message := summaryResult(v)
serviceTable2.AddRow(name, status, message)
}
fmt.Println(serviceTable2.Render())
//show component health status
printComponentStatus()
//show node detail
serviceTable := termtables.CreateTable()
serviceTable.AddHeaders("Uid", "IP", "HostName", "NodeRole", "Status")
@ -232,3 +219,7 @@ func clusterStatus(roleList []map[string]string, ReadyList []map[string]string)
}
return clusterStatus, errMessage
}
func printComponentStatus() {
exec.Command("kubectl", "get", "pod", "-n", "rbd-system", "-o", "wide").Run()
}