mirror of
https://github.com/minio/minio.git
synced 2025-11-11 06:20:14 -05:00
admin: ServerInfo() returns info for each node (#4150)
ServerInfo() will gather information from all nodes before returning it back to the client.
This commit is contained in:
committed by
Harshavardhana
parent
df346753e1
commit
83abad0b37
@@ -74,17 +74,24 @@ type ServerConnStats struct {
|
||||
TotalOutputBytes uint64 `json:"received"`
|
||||
}
|
||||
|
||||
// ServerInfo holds the whole server information that will be
|
||||
// returned by ServerInfo API.
|
||||
type ServerInfo struct {
|
||||
// ServerInfoData holds storage, connections and other
|
||||
// information of a given server
|
||||
type ServerInfoData struct {
|
||||
StorageInfo StorageInfo `json:"storage"`
|
||||
ConnStats ServerConnStats `json:"network"`
|
||||
Properties ServerProperties `json:"server"`
|
||||
}
|
||||
|
||||
// ServerInfo holds server information result of one node
|
||||
type ServerInfo struct {
|
||||
Error error `json:"error"`
|
||||
Addr string `json:"addr"`
|
||||
Data *ServerInfoData `json:"data"`
|
||||
}
|
||||
|
||||
// ServerInfo - Connect to a minio server and call Server Info Management API
|
||||
// to fetch server's information represented by ServerInfo structure
|
||||
func (adm *AdminClient) ServerInfo() (ServerInfo, error) {
|
||||
func (adm *AdminClient) ServerInfo() ([]ServerInfo, error) {
|
||||
// Prepare web service request
|
||||
reqData := requestData{}
|
||||
reqData.queryValues = make(url.Values)
|
||||
@@ -94,26 +101,26 @@ func (adm *AdminClient) ServerInfo() (ServerInfo, error) {
|
||||
resp, err := adm.executeMethod("GET", reqData)
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return ServerInfo{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Check response http status code
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return ServerInfo{}, httpRespToErrorResponse(resp)
|
||||
return nil, httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
// Unmarshal the server's json response
|
||||
var info ServerInfo
|
||||
var serversInfo []ServerInfo
|
||||
|
||||
respBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return ServerInfo{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(respBytes, &info)
|
||||
err = json.Unmarshal(respBytes, &serversInfo)
|
||||
if err != nil {
|
||||
return ServerInfo{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return info, nil
|
||||
return serversInfo, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user