mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -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
@@ -122,7 +122,30 @@ If successful restarts the running minio service, for distributed setup restarts
|
||||
|
||||
```
|
||||
|
||||
## 3. Lock operations
|
||||
## 3. Info operations
|
||||
|
||||
<a name="ServerInfo"></a>
|
||||
### ServerInfo() ([]ServerInfo, error)
|
||||
Fetch all information for all cluster nodes, such as uptime, region, network statistics, etc..
|
||||
|
||||
|
||||
__Example__
|
||||
|
||||
```go
|
||||
|
||||
serversInfo, err := madmClnt.ServerInfo()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
for _, peerInfo := range serversInfo {
|
||||
log.Printf("Node: %s, Info: %v\n", peerInfo.Addr, peerInfo.Data)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## 4. Lock operations
|
||||
|
||||
<a name="ListLocks"></a>
|
||||
### ListLocks(bucket, prefix string, duration time.Duration) ([]VolumeLockInfo, error)
|
||||
@@ -154,7 +177,7 @@ __Example__
|
||||
|
||||
```
|
||||
|
||||
## 4. Heal operations
|
||||
## 5. Heal operations
|
||||
|
||||
<a name="ListObjectsHeal"></a>
|
||||
### ListObjectsHeal(bucket, prefix string, recursive bool, doneCh <-chan struct{}) (<-chan ObjectInfo, error)
|
||||
@@ -360,7 +383,7 @@ If upload is successfully healed returns nil, otherwise returns error indicating
|
||||
log.Println("Heal-upload result: ", healResult)
|
||||
```
|
||||
|
||||
## 5. Config operations
|
||||
## 6. Config operations
|
||||
|
||||
<a name="GetConfig"></a>
|
||||
### GetConfig() ([]byte, error)
|
||||
@@ -384,23 +407,6 @@ __Example__
|
||||
log.Println("config received successfully: ", string(buf.Bytes()))
|
||||
```
|
||||
|
||||
## 6. Misc operations
|
||||
|
||||
<a name="SetCredentials"></a>
|
||||
|
||||
### SetCredentials() error
|
||||
Set new credentials of a Minio setup.
|
||||
|
||||
__Example__
|
||||
|
||||
``` go
|
||||
err = madmClnt.SetCredentials("YOUR-NEW-ACCESSKEY", "YOUR-NEW-SECRETKEY")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
log.Println("New credentials successfully set.")
|
||||
|
||||
```
|
||||
|
||||
<a name="SetConfig"></a>
|
||||
### SetConfig(config io.Reader) (SetConfigResult, error)
|
||||
@@ -435,3 +441,22 @@ __Example__
|
||||
}
|
||||
log.Println("SetConfig: ", string(buf.Bytes()))
|
||||
```
|
||||
|
||||
## 7. Misc operations
|
||||
|
||||
<a name="SetCredentials"></a>
|
||||
|
||||
### SetCredentials() error
|
||||
Set new credentials of a Minio setup.
|
||||
|
||||
__Example__
|
||||
|
||||
``` go
|
||||
err = madmClnt.SetCredentials("YOUR-NEW-ACCESSKEY", "YOUR-NEW-SECRETKEY")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
log.Println("New credentials successfully set.")
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -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