Adapt new changes in StorageInfo (#2889)

This commit is contained in:
Praveen raj Mani
2019-10-23 08:47:38 -07:00
committed by Harshavardhana
parent 72403ecbd1
commit 80aecfddff
3 changed files with 51 additions and 32 deletions
+48 -29
View File
@@ -99,22 +99,29 @@ type backendStatus struct {
// ServerInfo holds the whole server information that will be
// returned by ServerInfo API.
type ServerInfo struct {
StorageInfo backendStatus `json:"storage"`
ConnStats madmin.ServerConnStats `json:"network"`
Properties madmin.ServerProperties `json:"server"`
CPULoad madmin.ServerCPULoadInfo `json:"cpu,omitempty"`
MemUsage madmin.ServerMemUsageInfo `json:"mem,omitempty"`
ConnStats madmin.ServerConnStats `json:"network"`
Properties madmin.ServerProperties `json:"server"`
CPULoad madmin.ServerCPULoadInfo `json:"cpu,omitempty"`
MemUsage madmin.ServerMemUsageInfo `json:"mem,omitempty"`
}
// infoMessage container to hold service status information.
type infoMessage struct {
Status string `json:"status"`
Service string `json:"service"`
Addr string `json:"address"`
Err string `json:"error"`
Status string `json:"status"`
Service string `json:"service"`
Addr string `json:"address"`
Err string `json:"error"`
StorageInfo backendStatus `json:"storage"`
*ServerInfo
}
func filterPerNode(addr string, m map[string]int) int {
if val, ok := m[addr]; ok {
return val
}
return -1
}
// String colorized service status message.
func (u infoMessage) String() (msg string) {
dot := "●"
@@ -168,7 +175,7 @@ func (u infoMessage) String() (msg string) {
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 {
if v, ok := u.StorageInfo.Backend.(xlBackend); ok {
upBackends := 0
downBackends := 0
for _, set := range v.Sets {
@@ -278,6 +285,14 @@ func mainAdminServerInfo(ctx *cli.Context) error {
// exit immediately if error encountered
return nil
}
// Fetch storage info of all servers (cluster or single server)
storageInfo, e := client.StorageInfo()
if err := processErr(e); err != nil {
// exit immediately if error encountered
return nil
}
// Fetch info of all CPU loads (all MinIO server instances)
cpuLoads, e := client.ServerCPULoadInfo()
@@ -309,25 +324,29 @@ func mainAdminServerInfo(ctx *cli.Context) error {
}
// Construct the backend status
storageInfo := backendStatus{
Used: serverInfo.Data.StorageInfo.Used,
Available: serverInfo.Data.StorageInfo.Available,
Total: serverInfo.Data.StorageInfo.Total,
storageInfoStat := backendStatus{}
for index, mountPath := range storageInfo.MountPaths {
if strings.Contains(mountPath, serverInfo.Addr) || serverInfo.Addr[0] == '/' || serverInfo.Addr[0] == '.' {
storageInfoStat.Used += storageInfo.Used[index]
storageInfoStat.Available += storageInfo.Available[index]
storageInfoStat.Total += storageInfo.Total[index]
}
}
if serverInfo.Data.StorageInfo.Backend.Type == madmin.Erasure {
storageInfo.Backend = xlBackend{
if storageInfo.Backend.Type == madmin.Erasure {
storageInfoStat.Backend = xlBackend{
Type: erasureType,
OnlineDisks: serverInfo.Data.StorageInfo.Backend.OnlineDisks,
OfflineDisks: serverInfo.Data.StorageInfo.Backend.OfflineDisks,
StandardSCData: serverInfo.Data.StorageInfo.Backend.StandardSCData,
StandardSCParity: serverInfo.Data.StorageInfo.Backend.StandardSCParity,
RRSCData: serverInfo.Data.StorageInfo.Backend.RRSCData,
RRSCParity: serverInfo.Data.StorageInfo.Backend.RRSCParity,
Sets: serverInfo.Data.StorageInfo.Backend.Sets,
OnlineDisks: filterPerNode(serverInfo.Addr, storageInfo.Backend.OnlineDisks),
OfflineDisks: filterPerNode(serverInfo.Addr, storageInfo.Backend.OfflineDisks),
StandardSCData: storageInfo.Backend.StandardSCData,
StandardSCParity: storageInfo.Backend.StandardSCParity,
RRSCData: storageInfo.Backend.RRSCData,
RRSCParity: storageInfo.Backend.RRSCParity,
Sets: storageInfo.Backend.Sets,
}
} else {
storageInfo.Backend = fsBackend{
storageInfoStat.Backend = fsBackend{
Type: fsType,
}
}
@@ -337,12 +356,12 @@ func mainAdminServerInfo(ctx *cli.Context) error {
Addr: serverInfo.Addr,
Err: serverInfo.Error,
ServerInfo: &ServerInfo{
StorageInfo: storageInfo,
ConnStats: serverInfo.Data.ConnStats,
Properties: serverInfo.Data.Properties,
CPULoad: cpuLoad,
MemUsage: memUsage,
ConnStats: serverInfo.Data.ConnStats,
Properties: serverInfo.Data.Properties,
CPULoad: cpuLoad,
MemUsage: memUsage,
},
StorageInfo: storageInfoStat,
}))
}
+1 -1
View File
@@ -11,7 +11,7 @@ require (
github.com/mattn/go-colorable v0.1.1
github.com/mattn/go-isatty v0.0.7
github.com/minio/cli v1.22.0
github.com/minio/minio v0.0.0-20191016175257-c4e2af8ca34d
github.com/minio/minio v0.0.0-20191023040114-8836d57e3c9d
github.com/minio/minio-go/v6 v6.0.39
github.com/minio/sha256-simd v0.1.1
github.com/mitchellh/go-homedir v1.1.0
+2 -2
View File
@@ -430,8 +430,8 @@ github.com/minio/minio v0.0.0-20190325204105-0250f7de678b/go.mod h1:6ODmvb06uOpN
github.com/minio/minio v0.0.0-20190510004154-ac3b59645e92/go.mod h1:yFbQSwuA61mB/SDurPvsaSydqDyJdfAlBYpMiEe1lz8=
github.com/minio/minio v0.0.0-20190903181048-8a71b0ec5a72 h1:TMytDyYdKnVxNJhkISFRsw9SVoHIlSMIJFk3y/l9nik=
github.com/minio/minio v0.0.0-20190903181048-8a71b0ec5a72/go.mod h1:H8OUaOxwJIALXHlfMpk2ESvk81dW+F7tSnrZi7rln/k=
github.com/minio/minio v0.0.0-20191016175257-c4e2af8ca34d h1:UaKu+15Teg95H6vQ6A8YEa27GZJbaHwLlVNu/MHhn0o=
github.com/minio/minio v0.0.0-20191016175257-c4e2af8ca34d/go.mod h1:26iXReDUAl0TJD5d4OIUoccQKrdE2/Oie6XRPjZN5gk=
github.com/minio/minio v0.0.0-20191023040114-8836d57e3c9d h1:gNdVSSXBQFz7JnsZPy13HJKdXR1JLGKm6QMMhGDBZzg=
github.com/minio/minio v0.0.0-20191023040114-8836d57e3c9d/go.mod h1:26iXReDUAl0TJD5d4OIUoccQKrdE2/Oie6XRPjZN5gk=
github.com/minio/minio-go v0.0.0-20190227180923-59af836a7e6d h1:gptD0/Hnam7h4Iq9D/33fscRpHfzOOUqUbH2nPw9HcU=
github.com/minio/minio-go v0.0.0-20190227180923-59af836a7e6d/go.mod h1:/haSOWG8hQNx2+JOfLJ9GKp61EAmgPwRVw/Sac0NzaM=
github.com/minio/minio-go v0.0.0-20190313212832-5d20267d970d/go.mod h1:/haSOWG8hQNx2+JOfLJ9GKp61EAmgPwRVw/Sac0NzaM=