From af7d551010cb39c00263d680634c76e8f9ce2787 Mon Sep 17 00:00:00 2001 From: Daniel Valdivia Date: Fri, 23 Aug 2019 09:33:38 -0700 Subject: [PATCH] Add support for Total Space and Available Space on mc admin info (#2872) --- cmd/admin-info-server.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/admin-info-server.go b/cmd/admin-info-server.go index eaf39172..19c47cea 100644 --- a/cmd/admin-info-server.go +++ b/cmd/admin-info-server.go @@ -23,7 +23,7 @@ import ( "strings" "time" - humanize "github.com/dustin/go-humanize" + "github.com/dustin/go-humanize" "github.com/fatih/color" "github.com/minio/cli" json "github.com/minio/mc/pkg/colorjson" @@ -87,7 +87,13 @@ type xlBackend struct { // backendStatus represents the overall information of all backend storage types type backendStatus struct { - Used uint64 `json:"used"` + // Total used space per tenant. + Used uint64 `json:"used"` + // Total available space. + Available uint64 `json:"available"` + // Total disk space. + Total uint64 `json:"total"` + // Backend type. Backend interface{} `json:"backend"` } @@ -145,7 +151,7 @@ func (u infoMessage) String() (msg string) { if u.ServerInfo.Properties.Version == "DEVELOPMENT.GOGET" { version = "" } - msg += fmt.Sprintf(" Version: %s\n", version) + msg += fmt.Sprintf(" Version: %s\n", version) // Region if u.ServerInfo.Properties.Region != "" { msg += fmt.Sprintf(" Region: %s\n", u.ServerInfo.Properties.Region) @@ -160,7 +166,9 @@ func (u infoMessage) String() (msg string) { } // Incoming/outgoing - msg += fmt.Sprintf(" Storage: Used %s", humanize.IBytes(u.StorageInfo.Used)) + msg += fmt.Sprintf(" Storage: Used %s, Free %s", + humanize.IBytes(u.StorageInfo.Used), + humanize.IBytes(u.StorageInfo.Available)) if v, ok := u.ServerInfo.StorageInfo.Backend.(xlBackend); ok { upBackends := 0 downBackends := 0 @@ -303,7 +311,9 @@ func mainAdminServerInfo(ctx *cli.Context) error { // Construct the backend status storageInfo := backendStatus{ - Used: serverInfo.Data.StorageInfo.Used, + Used: serverInfo.Data.StorageInfo.Used, + Available: serverInfo.Data.StorageInfo.Available, + Total: serverInfo.Data.StorageInfo.Total, } if serverInfo.Data.StorageInfo.Backend.Type == madmin.Erasure {