From 19c49468b7808a60ae780e990c4a237f7d824565 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 4 Sep 2020 14:33:41 -0700 Subject: [PATCH] handle admin info output for offline nodes properly (#3397) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` ● localhost:9002 Uptime: 11 minutes Version: 2020-09-03T23:04:07Z Network: 3/4 OK Drives: 1/1 OK ● localhost:9003 Uptime: offline Drives: 0/1 OK ● localhost:9005 Uptime: 11 minutes Version: 2020-09-03T23:04:07Z Network: 3/4 OK Drives: 1/1 OK ● localhost:9004 Uptime: 11 minutes Version: 2020-09-03T23:04:07Z Network: 3/4 OK Drives: 1/1 OK 3 drives online, 1 drive offline ``` --- cmd/admin-info.go | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/cmd/admin-info.go b/cmd/admin-info.go index b3ea25a9..8889f653 100644 --- a/cmd/admin-info.go +++ b/cmd/admin-info.go @@ -115,7 +115,34 @@ func (u clusterStruct) String() (msg string) { if srv.State == "offline" { // "PrintB" is color blue in console library package msg += fmt.Sprintf("%s %s\n", console.Colorize("InfoFail", dot), console.Colorize("PrintB", srv.Endpoint)) - msg += fmt.Sprintf(" Uptime: %s\n\n", console.Colorize("InfoFail", "offline")) + msg += fmt.Sprintf(" Uptime: %s\n", console.Colorize("InfoFail", "offline")) + + if backendType != "FS" { + // Info about drives on a server, only available for non-FS types + var OffDisks int + var OnDisks int + var dispNoOfDisks string + for _, disk := range srv.Disks { + switch disk.State { + case madmin.DriveStateOk: + fallthrough + case madmin.DriveStateUnformatted: + OnDisks++ + default: + OffDisks++ + } + } + + totalDisksPerServer := OnDisks + OffDisks + totalOnlineDisksCluster += OnDisks + totalOfflineDisksCluster += OffDisks + + dispNoOfDisks = strconv.Itoa(OnDisks) + "/" + strconv.Itoa(totalDisksPerServer) + msg += fmt.Sprintf(" Drives: %s %s\n", dispNoOfDisks, console.Colorize("InfoFail", "OK ")) + } + + msg += "\n" + // Continue to the next server continue } @@ -153,9 +180,12 @@ func (u clusterStruct) String() (msg string) { var OnDisks int var dispNoOfDisks string for _, disk := range srv.Disks { - if disk.State == "ok" { + switch disk.State { + case madmin.DriveStateOk: + fallthrough + case madmin.DriveStateUnformatted: OnDisks++ - } else { + default: OffDisks++ } }