|
|
|
@ -1497,22 +1497,13 @@ func (a adminAPIHandlers) ServerInfoHandler(w http.ResponseWriter, r *http.Reque |
|
|
|
|
|
|
|
|
|
defer logger.AuditLog(w, r, "ServerInfo", mustGetClaimsFromToken(r)) |
|
|
|
|
|
|
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.ServerInfoAdminAction) |
|
|
|
|
if objectAPI == nil { |
|
|
|
|
// Validate request signature.
|
|
|
|
|
_, adminAPIErr := checkAdminRequestAuth(ctx, r, iampolicy.ServerInfoAdminAction, "") |
|
|
|
|
if adminAPIErr != ErrNone { |
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(adminAPIErr), r.URL) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
buckets := madmin.Buckets{} |
|
|
|
|
objects := madmin.Objects{} |
|
|
|
|
usage := madmin.Usage{} |
|
|
|
|
|
|
|
|
|
dataUsageInfo, err := loadDataUsageFromBackend(ctx, objectAPI) |
|
|
|
|
if err == nil { |
|
|
|
|
buckets = madmin.Buckets{Count: dataUsageInfo.BucketsCount} |
|
|
|
|
objects = madmin.Objects{Count: dataUsageInfo.ObjectsTotalCount} |
|
|
|
|
usage = madmin.Usage{Size: dataUsageInfo.ObjectsTotalSize} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
vault := fetchVaultStatus() |
|
|
|
|
|
|
|
|
|
ldap := madmin.LDAP{} |
|
|
|
@ -1534,31 +1525,54 @@ func (a adminAPIHandlers) ServerInfoHandler(w http.ResponseWriter, r *http.Reque |
|
|
|
|
// Get the notification target info
|
|
|
|
|
notifyTarget := fetchLambdaInfo() |
|
|
|
|
|
|
|
|
|
// Fetching the Storage information, ignore any errors.
|
|
|
|
|
storageInfo, _ := objectAPI.StorageInfo(ctx, false) |
|
|
|
|
server := getLocalServerProperty(globalEndpoints, r) |
|
|
|
|
servers := globalNotificationSys.ServerInfo() |
|
|
|
|
servers = append(servers, server) |
|
|
|
|
|
|
|
|
|
var backend interface{} |
|
|
|
|
if storageInfo.Backend.Type == BackendType(madmin.Erasure) { |
|
|
|
|
backend = madmin.ErasureBackend{ |
|
|
|
|
Type: madmin.ErasureType, |
|
|
|
|
OnlineDisks: storageInfo.Backend.OnlineDisks.Sum(), |
|
|
|
|
OfflineDisks: storageInfo.Backend.OfflineDisks.Sum(), |
|
|
|
|
StandardSCData: storageInfo.Backend.StandardSCData, |
|
|
|
|
StandardSCParity: storageInfo.Backend.StandardSCParity, |
|
|
|
|
RRSCData: storageInfo.Backend.RRSCData, |
|
|
|
|
RRSCParity: storageInfo.Backend.RRSCParity, |
|
|
|
|
mode := madmin.ObjectLayerInitializing |
|
|
|
|
|
|
|
|
|
buckets := madmin.Buckets{} |
|
|
|
|
objects := madmin.Objects{} |
|
|
|
|
usage := madmin.Usage{} |
|
|
|
|
|
|
|
|
|
objectAPI := newObjectLayerFn() |
|
|
|
|
if objectAPI != nil { |
|
|
|
|
mode = madmin.ObjectLayerOnline |
|
|
|
|
// Load data usage
|
|
|
|
|
dataUsageInfo, err := loadDataUsageFromBackend(ctx, objectAPI) |
|
|
|
|
if err == nil { |
|
|
|
|
buckets = madmin.Buckets{Count: dataUsageInfo.BucketsCount} |
|
|
|
|
objects = madmin.Objects{Count: dataUsageInfo.ObjectsTotalCount} |
|
|
|
|
usage = madmin.Usage{Size: dataUsageInfo.ObjectsTotalSize} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
backend = madmin.FSBackend{ |
|
|
|
|
Type: madmin.FsType, |
|
|
|
|
|
|
|
|
|
// Fetching the backend information
|
|
|
|
|
backendInfo := objectAPI.BackendInfo() |
|
|
|
|
if backendInfo.Type == BackendType(madmin.Erasure) { |
|
|
|
|
// Calculate the number of online/offline disks of all nodes
|
|
|
|
|
var allDisks []madmin.Disk |
|
|
|
|
for _, s := range servers { |
|
|
|
|
allDisks = append(allDisks, s.Disks...) |
|
|
|
|
} |
|
|
|
|
onlineDisks, offlineDisks := getOnlineOfflineDisksStats(allDisks) |
|
|
|
|
|
|
|
|
|
backend = madmin.ErasureBackend{ |
|
|
|
|
Type: madmin.ErasureType, |
|
|
|
|
OnlineDisks: onlineDisks.Sum(), |
|
|
|
|
OfflineDisks: offlineDisks.Sum(), |
|
|
|
|
StandardSCData: backendInfo.StandardSCData, |
|
|
|
|
StandardSCParity: backendInfo.StandardSCParity, |
|
|
|
|
RRSCData: backendInfo.RRSCData, |
|
|
|
|
RRSCParity: backendInfo.RRSCParity, |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
backend = madmin.FSBackend{ |
|
|
|
|
Type: madmin.FsType, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mode := "online" |
|
|
|
|
server := getLocalServerProperty(globalEndpoints, r) |
|
|
|
|
servers := globalNotificationSys.ServerInfo() |
|
|
|
|
servers = append(servers, server) |
|
|
|
|
|
|
|
|
|
domain := globalDomainNames |
|
|
|
|
services := madmin.Services{ |
|
|
|
|
Vault: vault, |
|
|
|
@ -1568,25 +1582,6 @@ func (a adminAPIHandlers) ServerInfoHandler(w http.ResponseWriter, r *http.Reque |
|
|
|
|
Notifications: notifyTarget, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// find all disks which belong to each respective endpoints
|
|
|
|
|
for i := range servers { |
|
|
|
|
for _, disk := range storageInfo.Disks { |
|
|
|
|
if strings.Contains(disk.Endpoint, servers[i].Endpoint) { |
|
|
|
|
servers[i].Disks = append(servers[i].Disks, disk) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// add all the disks local to this server.
|
|
|
|
|
for _, disk := range storageInfo.Disks { |
|
|
|
|
if disk.DrivePath == "" && disk.Endpoint == "" { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
if disk.Endpoint == disk.DrivePath { |
|
|
|
|
servers[len(servers)-1].Disks = append(servers[len(servers)-1].Disks, disk) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
infoMsg := madmin.InfoMessage{ |
|
|
|
|
Mode: mode, |
|
|
|
|
Domain: domain, |
|
|
|
|