mirror of
https://github.com/minio/minio.git
synced 2025-11-10 14:09:48 -05:00
The prometheus metrics refractoring (#8003)
The measures are consolidated to the following metrics - `disk_storage_used` : Disk space used by the disk. - `disk_storage_available`: Available disk space left on the disk. - `disk_storage_total`: Total disk space on the disk. - `disks_offline`: Total number of offline disks in current MinIO instance. - `disks_total`: Total number of disks in current MinIO instance. - `s3_requests_total`: Total number of s3 requests in current MinIO instance. - `s3_errors_total`: Total number of errors in s3 requests in current MinIO instance. - `s3_requests_current`: Total number of active s3 requests in current MinIO instance. - `internode_rx_bytes_total`: Total number of internode bytes received by current MinIO server instance. - `internode_tx_bytes_total`: Total number of bytes sent to the other nodes by current MinIO server instance. - `s3_rx_bytes_total`: Total number of s3 bytes received by current MinIO server instance. - `s3_tx_bytes_total`: Total number of s3 bytes sent by current MinIO server instance. - `minio_version_info`: Current MinIO version with commit-id. - `s3_ttfb_seconds_bucket`: Histogram that holds the latency information of the requests. And this PR also modifies the current StorageInfo queries - Decouples StorageInfo from ServerInfo . - StorageInfo is enhanced to give endpoint information. NOTE: ADMIN API VERSION IS BUMPED UP IN THIS PR Fixes #7873
This commit is contained in:
committed by
Harshavardhana
parent
f01d53b20f
commit
8836d57e3c
@@ -42,15 +42,16 @@ func main() {
|
||||
}
|
||||
|
||||
```
|
||||
| Service operations | Info operations | Healing operations | Config operations | Top operations | IAM operations | Misc | KMS |
|
||||
|:------------------------------------|:------------------------------------------------------------|:-------------------|:--------------------------|:------------------------|:--------------------------------------|:--------------------------------------------------|:--------------------------------|
|
||||
| [`ServiceRestart`](#ServiceRestart) | [`ServerInfo`](#ServerInfo) | [`Heal`](#Heal) | [`GetConfig`](#GetConfig) | [`TopLocks`](#TopLocks) | [`AddUser`](#AddUser) | | [`GetKeyStatus`](#GetKeyStatus) |
|
||||
| [`ServiceStop`](#ServiceStop) | [`ServerCPULoadInfo`](#ServerCPULoadInfo) | | [`SetConfig`](#SetConfig) | | [`SetUserPolicy`](#SetUserPolicy) | [`StartProfiling`](#StartProfiling) | |
|
||||
| | [`ServerMemUsageInfo`](#ServerMemUsageInfo) | | | | [`ListUsers`](#ListUsers) | [`DownloadProfilingData`](#DownloadProfilingData) | |
|
||||
| [`ServiceTrace`](#ServiceTrace) | [`ServerDrivesPerfInfo`](#ServerDrivesPerfInfo) | | | | [`AddCannedPolicy`](#AddCannedPolicy) | [`ServerUpdate`](#ServerUpdate) | |
|
||||
| | [`NetPerfInfo`](#NetPerfInfo) | | | | | | |
|
||||
| | [`ServerCPUHardwareInfo`](#ServerCPUHardwareInfo) | | | | | | |
|
||||
| Service operations | Info operations | Healing operations | Config operations | Top operations | IAM operations | Misc | KMS |
|
||||
|:------------------------------------|:--------------------------------------------------|:-------------------|:--------------------------|:------------------------|:--------------------------------------|:--------------------------------------------------|:--------------------------------|
|
||||
| [`ServiceRestart`](#ServiceRestart) | [`ServerInfo`](#ServerInfo) | [`Heal`](#Heal) | [`GetConfig`](#GetConfig) | [`TopLocks`](#TopLocks) | [`AddUser`](#AddUser) | | [`GetKeyStatus`](#GetKeyStatus) |
|
||||
| [`ServiceStop`](#ServiceStop) | [`ServerCPULoadInfo`](#ServerCPULoadInfo) | | [`SetConfig`](#SetConfig) | | [`SetUserPolicy`](#SetUserPolicy) | [`StartProfiling`](#StartProfiling) | |
|
||||
| | [`ServerMemUsageInfo`](#ServerMemUsageInfo) | | | | [`ListUsers`](#ListUsers) | [`DownloadProfilingData`](#DownloadProfilingData) | |
|
||||
| [`ServiceTrace`](#ServiceTrace) | [`ServerDrivesPerfInfo`](#ServerDrivesPerfInfo) | | | | [`AddCannedPolicy`](#AddCannedPolicy) | [`ServerUpdate`](#ServerUpdate) | |
|
||||
| | [`NetPerfInfo`](#NetPerfInfo) | | | | | | |
|
||||
| | [`ServerCPUHardwareInfo`](#ServerCPUHardwareInfo) | | | | | | |
|
||||
| | [`ServerNetworkHardwareInfo`](#ServerNetworkHardwareInfo) | | | | | | |
|
||||
| | [`StorageInfo`](#StorageInfo) | | | | | | |
|
||||
|
||||
## 1. Constructor
|
||||
<a name="MinIO"></a>
|
||||
@@ -150,16 +151,12 @@ __Example__
|
||||
### ServerInfo() ([]ServerInfo, error)
|
||||
Fetches information for all cluster nodes, such as server properties, storage information, network statistics, etc.
|
||||
|
||||
| Param | Type | Description |
|
||||
|---------------------------------|--------------------|--------------------------------------------------------------------|
|
||||
| `si.Addr` | _string_ | Address of the server the following information is retrieved from. |
|
||||
| `si.ConnStats` | _ServerConnStats_ | Connection statistics from the given server. |
|
||||
| `si.HTTPStats` | _ServerHTTPStats_ | HTTP connection statistics from the given server. |
|
||||
| `si.Properties` | _ServerProperties_ | Server properties such as region, notification targets. |
|
||||
| `si.Data.StorageInfo.Used` | _int64_ | Used disk space. |
|
||||
| `si.Data.StorageInfo.Total` | _int64_ | Total disk space. |
|
||||
| `si.Data.StorageInfo.Available` | _int64_ | Available disk space. |
|
||||
| `si.Data.StorageInfo.Backend` | _struct{}_ | Represents backend type embedded structure. |
|
||||
| Param | Type | Description |
|
||||
|----------------------------------|--------------------|--------------------------------------------------------------------|
|
||||
| `si.Addr` | _string_ | Address of the server the following information is retrieved from. |
|
||||
| `si.ConnStats` | _ServerConnStats_ | Connection statistics from the given server. |
|
||||
| `si.HTTPStats` | _ServerHTTPStats_ | HTTP connection statistics from the given server. |
|
||||
| `si.Properties` | _ServerProperties_ | Server properties such as region, notification targets. |
|
||||
|
||||
| Param | Type | Description |
|
||||
|-----------------------------|-----------------|----------------------------------------------------|
|
||||
@@ -187,23 +184,11 @@ Fetches information for all cluster nodes, such as server properties, storage in
|
||||
| `ServerHTTPStats.TotalDELETEStats` | _ServerHTTPMethodStats_ | Total statistics regarding DELETE operations |
|
||||
| `ServerHTTPStats.SuccessDELETEStats` | _ServerHTTPMethodStats_ | Total statistics regarding successful DELETE operations |
|
||||
|
||||
|
||||
| Param | Type | Description |
|
||||
|-------------------------------------|----------|-------------------------------------------------|
|
||||
| `ServerHTTPMethodStats.Count` | _uint64_ | Total number of operations. |
|
||||
| `ServerHTTPMethodStats.AvgDuration` | _string_ | Average duration of Count number of operations. |
|
||||
|
||||
| Param | Type | Description |
|
||||
|----------------------------|-----------------|-----------------------------------------------------------------------------------|
|
||||
| `Backend.Type` | _BackendType_ | Type of backend used by the server currently only FS or Erasure. |
|
||||
| `Backend.OnlineDisks` | _int_ | Total number of disks online (only applies to Erasure backend), is empty for FS. |
|
||||
| `Backend.OfflineDisks` | _int_ | Total number of disks offline (only applies to Erasure backend), is empty for FS. |
|
||||
| `Backend.StandardSCData` | _int_ | Data disks set for standard storage class, is empty for FS. |
|
||||
| `Backend.StandardSCParity` | _int_ | Parity disks set for standard storage class, is empty for FS. |
|
||||
| `Backend.RRSCData` | _int_ | Data disks set for reduced redundancy storage class, is empty for FS. |
|
||||
| `Backend.RRSCParity` | _int_ | Parity disks set for reduced redundancy storage class, is empty for FS. |
|
||||
| `Backend.Sets` | _[][]DriveInfo_ | Represents topology of drives in erasure coded sets. |
|
||||
|
||||
| Param | Type | Description |
|
||||
|----------------------|----------|-------------------------------------------------------|
|
||||
| `DriveInfo.UUID` | _string_ | Unique ID for each disk provisioned by server format. |
|
||||
@@ -288,6 +273,7 @@ Fetches network performance of all cluster nodes using given sized payload. Retu
|
||||
| `Error` | _string_ | Errors (if any) encountered while reaching this node |
|
||||
| `ReadThroughput` | _uint64_ | Network read throughput of the server in bytes per second |
|
||||
|
||||
|
||||
<a name="ServerCPUHardwareInfo"></a>
|
||||
### ServerCPUHardwareInfo() ([]ServerCPUHardwareInfo, error)
|
||||
|
||||
@@ -334,6 +320,42 @@ Fetches hardware information of CPU.
|
||||
| `NetworkInfo.HardwareAddr` | _[]byte_ | IEEE MAC-48, EUI-48 and EUI-64 form |
|
||||
| `NetworkInfo.Flags` | _uint32_ | e.g., FlagUp, FlagLoopback, FlagMulticast |
|
||||
|
||||
<a name="StorageInfo"></a>
|
||||
### StorageInfo() (StorageInfo, error)
|
||||
|
||||
Fetches Storage information for all cluster nodes.
|
||||
|
||||
| Param | Type | Description |
|
||||
|-------------------------|------------|---------------------------------------------|
|
||||
| `storageInfo.Used` | _[]int64_ | Used disk spaces. |
|
||||
| `storageInfo.Total` | _[]int64_ | Total disk spaces. |
|
||||
| `storageInfo.Available` | _[]int64_ | Available disk spaces. |
|
||||
| `StorageInfo.Backend` | _struct{}_ | Represents backend type embedded structure. |
|
||||
|
||||
| Param | Type | Description |
|
||||
|----------------------------|-----------------|--------------------------------------------------------------------------------------------------------------------------|
|
||||
| `Backend.Type` | _BackendType_ | Type of backend used by the server currently only FS or Erasure. |
|
||||
| `Backend.OnlineDisks` | _BackendDisks_ | Total number of disks online per node (only applies to Erasure backend) represented in map[string]int, is empty for FS. |
|
||||
| `Backend.OfflineDisks` | _BackendDisks_ | Total number of disks offline per node (only applies to Erasure backend) represented in map[string]int, is empty for FS. |
|
||||
| `Backend.StandardSCData` | _int_ | Data disks set for standard storage class, is empty for FS. |
|
||||
| `Backend.StandardSCParity` | _int_ | Parity disks set for standard storage class, is empty for FS. |
|
||||
| `Backend.RRSCData` | _int_ | Data disks set for reduced redundancy storage class, is empty for FS. |
|
||||
| `Backend.RRSCParity` | _int_ | Parity disks set for reduced redundancy storage class, is empty for FS. |
|
||||
| `Backend.Sets` | _[][]DriveInfo_ | Represents topology of drives in erasure coded sets. |
|
||||
|
||||
__Example__
|
||||
|
||||
```go
|
||||
|
||||
storageInfo, err := madmClnt.StorageInfo()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
log.Println(storageInfo)
|
||||
|
||||
```
|
||||
|
||||
## 5. Heal operations
|
||||
|
||||
<a name="Heal"></a>
|
||||
|
||||
@@ -54,7 +54,7 @@ func (adm AdminClient) GetLogs(node string, lineCnt int, logKind string, doneCh
|
||||
urlValues.Set("logType", logKind)
|
||||
for {
|
||||
reqData := requestData{
|
||||
relPath: "/v1/log",
|
||||
relPath: adminAPIPrefix + "/log",
|
||||
queryValues: urlValues,
|
||||
}
|
||||
// Execute GET to call log handler
|
||||
|
||||
@@ -29,9 +29,9 @@ import (
|
||||
|
||||
// GetConfig - returns the config.json of a minio setup, incoming data is encrypted.
|
||||
func (adm *AdminClient) GetConfig() ([]byte, error) {
|
||||
// Execute GET on /minio/admin/v1/config to get config of a setup.
|
||||
// Execute GET on /minio/admin/v2/config to get config of a setup.
|
||||
resp, err := adm.executeMethod("GET",
|
||||
requestData{relPath: "/v1/config"})
|
||||
requestData{relPath: adminAPIPrefix + "/config"})
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -85,11 +85,11 @@ func (adm *AdminClient) SetConfig(config io.Reader) (err error) {
|
||||
}
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/config",
|
||||
relPath: adminAPIPrefix + "/config",
|
||||
content: econfigBytes,
|
||||
}
|
||||
|
||||
// Execute PUT on /minio/admin/v1/config to set config.
|
||||
// Execute PUT on /minio/admin/v2/config to set config.
|
||||
resp, err := adm.executeMethod("PUT", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
|
||||
44
pkg/madmin/examples/storage-info.go
Normal file
44
pkg/madmin/examples/storage-info.go
Normal file
@@ -0,0 +1,44 @@
|
||||
// +build ignore
|
||||
|
||||
/*
|
||||
* MinIO Cloud Storage, (C) 2019 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/minio/minio/pkg/madmin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
|
||||
// dummy values, please replace them with original values.
|
||||
|
||||
// API requests are secure (HTTPS) if secure=true and insecure (HTTPS) otherwise.
|
||||
// New returns an MinIO Admin client object.
|
||||
madmClnt, err := madmin.New("your-minio.example.com:9000", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
st, err := madmClnt.StorageInfo()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
log.Println(st)
|
||||
}
|
||||
@@ -41,11 +41,11 @@ func (adm *AdminClient) UpdateGroupMembers(g GroupAddRemove) error {
|
||||
}
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/update-group-members",
|
||||
relPath: adminAPIPrefix + "/update-group-members",
|
||||
content: data,
|
||||
}
|
||||
|
||||
// Execute PUT on /minio/admin/v1/update-group-members
|
||||
// Execute PUT on /minio/admin/v2/update-group-members
|
||||
resp, err := adm.executeMethod("PUT", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
@@ -74,7 +74,7 @@ func (adm *AdminClient) GetGroupDescription(group string) (*GroupDesc, error) {
|
||||
v := url.Values{}
|
||||
v.Set("group", group)
|
||||
reqData := requestData{
|
||||
relPath: "/v1/group",
|
||||
relPath: adminAPIPrefix + "/group",
|
||||
queryValues: v,
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func (adm *AdminClient) GetGroupDescription(group string) (*GroupDesc, error) {
|
||||
// ListGroups - lists all groups names present on the server.
|
||||
func (adm *AdminClient) ListGroups() ([]string, error) {
|
||||
reqData := requestData{
|
||||
relPath: "/v1/groups",
|
||||
relPath: adminAPIPrefix + "/groups",
|
||||
}
|
||||
|
||||
resp, err := adm.executeMethod("GET", reqData)
|
||||
@@ -146,7 +146,7 @@ func (adm *AdminClient) SetGroupStatus(group string, status GroupStatus) error {
|
||||
v.Set("status", string(status))
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/set-group-status",
|
||||
relPath: adminAPIPrefix + "/set-group-status",
|
||||
queryValues: v,
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func (adm *AdminClient) ServerCPUHardwareInfo() ([]ServerCPUHardwareInfo, error)
|
||||
v := url.Values{}
|
||||
v.Set(HARDWARE, string(CPU))
|
||||
resp, err := adm.executeMethod("GET", requestData{
|
||||
relPath: "/v1/hardware",
|
||||
relPath: adminAPIPrefix + "/hardware",
|
||||
queryValues: v,
|
||||
})
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ func (adm *AdminClient) Heal(bucket, prefix string, healOpts HealOpts,
|
||||
return healStart, healTaskStatus, err
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("/v1/heal/%s", bucket)
|
||||
path := fmt.Sprintf(adminAPIPrefix+"/heal/%s", bucket)
|
||||
if bucket != "" && prefix != "" {
|
||||
path += "/" + prefix
|
||||
}
|
||||
@@ -280,7 +280,7 @@ type BgHealState struct {
|
||||
// current server or cluster.
|
||||
func (adm *AdminClient) BackgroundHealStatus() (BgHealState, error) {
|
||||
// Execute POST request to background heal status api
|
||||
resp, err := adm.executeMethod("POST", requestData{relPath: "/v1/background-heal/status"})
|
||||
resp, err := adm.executeMethod("POST", requestData{relPath: adminAPIPrefix + "/background-heal/status"})
|
||||
if err != nil {
|
||||
return BgHealState{}, err
|
||||
}
|
||||
|
||||
@@ -59,11 +59,13 @@ type DriveInfo HealDriveInfo
|
||||
|
||||
// StorageInfo - represents total capacity of underlying storage.
|
||||
type StorageInfo struct {
|
||||
Used uint64 // Total used spaced per tenant.
|
||||
Used []uint64 // Used total used per disk.
|
||||
|
||||
Available uint64 // Total available space.
|
||||
Total []uint64 // Total disk space per disk.
|
||||
|
||||
Total uint64 // Total disk space.
|
||||
Available []uint64 // Total disk space available per disk.
|
||||
|
||||
MountPaths []string // Disk mountpoints
|
||||
|
||||
// Backend type.
|
||||
Backend struct {
|
||||
@@ -71,18 +73,41 @@ type StorageInfo struct {
|
||||
Type BackendType
|
||||
|
||||
// Following fields are only meaningful if BackendType is Erasure.
|
||||
OnlineDisks int // Online disks during server startup.
|
||||
OfflineDisks int // Offline disks during server startup.
|
||||
StandardSCData int // Data disks for currently configured Standard storage class.
|
||||
StandardSCParity int // Parity disks for currently configured Standard storage class.
|
||||
RRSCData int // Data disks for currently configured Reduced Redundancy storage class.
|
||||
RRSCParity int // Parity disks for currently configured Reduced Redundancy storage class.
|
||||
OnlineDisks BackendDisks // Online disks during server startup.
|
||||
OfflineDisks BackendDisks // Offline disks during server startup.
|
||||
StandardSCData int // Data disks for currently configured Standard storage class.
|
||||
StandardSCParity int // Parity disks for currently configured Standard storage class.
|
||||
RRSCData int // Data disks for currently configured Reduced Redundancy storage class.
|
||||
RRSCParity int // Parity disks for currently configured Reduced Redundancy storage class.
|
||||
|
||||
// List of all disk status, this is only meaningful if BackendType is Erasure.
|
||||
Sets [][]DriveInfo
|
||||
}
|
||||
}
|
||||
|
||||
// BackendDisks - represents the map of endpoint-disks.
|
||||
type BackendDisks map[string]int
|
||||
|
||||
// Sum - Return the sum of the disks in the endpoint-disk map.
|
||||
func (d1 BackendDisks) Sum() (sum int) {
|
||||
for _, count := range d1 {
|
||||
sum += count
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
// Merge - Reduces two endpoint-disk maps.
|
||||
func (d1 BackendDisks) Merge(d2 BackendDisks) BackendDisks {
|
||||
for i1, v1 := range d1 {
|
||||
if v2, ok := d2[i1]; ok {
|
||||
d2[i1] = v2 + v1
|
||||
continue
|
||||
}
|
||||
d2[i1] = v1
|
||||
}
|
||||
return d2
|
||||
}
|
||||
|
||||
// ServerProperties holds some of the server's information such as uptime,
|
||||
// version, region, ..
|
||||
type ServerProperties struct {
|
||||
@@ -141,7 +166,7 @@ type ServerInfo struct {
|
||||
// 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) {
|
||||
resp, err := adm.executeMethod("GET", requestData{relPath: "/v1/info"})
|
||||
resp, err := adm.executeMethod("GET", requestData{relPath: adminAPIPrefix + "/info"})
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -168,6 +193,36 @@ func (adm *AdminClient) ServerInfo() ([]ServerInfo, error) {
|
||||
return serversInfo, nil
|
||||
}
|
||||
|
||||
// StorageInfo - Connect to a minio server and call Storage Info Management API
|
||||
// to fetch server's information represented by StorageInfo structure
|
||||
func (adm *AdminClient) StorageInfo() (StorageInfo, error) {
|
||||
resp, err := adm.executeMethod("GET", requestData{relPath: adminAPIPrefix + "/storageinfo"})
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return StorageInfo{}, err
|
||||
}
|
||||
|
||||
// Check response http status code
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return StorageInfo{}, httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
// Unmarshal the server's json response
|
||||
var storageInfo StorageInfo
|
||||
|
||||
respBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return StorageInfo{}, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(respBytes, &storageInfo)
|
||||
if err != nil {
|
||||
return StorageInfo{}, err
|
||||
}
|
||||
|
||||
return storageInfo, nil
|
||||
}
|
||||
|
||||
// ServerDrivesPerfInfo holds informantion about address and write speed of
|
||||
// all drives in a single server node
|
||||
type ServerDrivesPerfInfo struct {
|
||||
@@ -185,7 +240,7 @@ func (adm *AdminClient) ServerDrivesPerfInfo(size int64) ([]ServerDrivesPerfInfo
|
||||
v.Set("size", strconv.FormatInt(size, 10))
|
||||
|
||||
resp, err := adm.executeMethod("GET", requestData{
|
||||
relPath: "/v1/performance",
|
||||
relPath: adminAPIPrefix + "/performance",
|
||||
queryValues: v,
|
||||
})
|
||||
|
||||
@@ -229,7 +284,7 @@ func (adm *AdminClient) ServerCPULoadInfo() ([]ServerCPULoadInfo, error) {
|
||||
v := url.Values{}
|
||||
v.Set("perfType", string("cpu"))
|
||||
resp, err := adm.executeMethod("GET", requestData{
|
||||
relPath: "/v1/performance",
|
||||
relPath: adminAPIPrefix + "/performance",
|
||||
queryValues: v,
|
||||
})
|
||||
|
||||
@@ -273,7 +328,7 @@ func (adm *AdminClient) ServerMemUsageInfo() ([]ServerMemUsageInfo, error) {
|
||||
v := url.Values{}
|
||||
v.Set("perfType", string("mem"))
|
||||
resp, err := adm.executeMethod("GET", requestData{
|
||||
relPath: "/v1/performance",
|
||||
relPath: adminAPIPrefix + "/performance",
|
||||
queryValues: v,
|
||||
})
|
||||
|
||||
@@ -318,7 +373,7 @@ func (adm *AdminClient) NetPerfInfo(size int) (map[string][]NetPerfInfo, error)
|
||||
v.Set("size", strconv.Itoa(size))
|
||||
}
|
||||
resp, err := adm.executeMethod("GET", requestData{
|
||||
relPath: "/v1/performance",
|
||||
relPath: adminAPIPrefix + "/performance",
|
||||
queryValues: v,
|
||||
})
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ import (
|
||||
|
||||
// GetKeyStatus requests status information about the key referenced by keyID
|
||||
// from the KMS connected to a MinIO by performing a Admin-API request.
|
||||
// It basically hits the `/minio/admin/v1/kms/key/status` API endpoint.
|
||||
// It basically hits the `/minio/admin/v2/kms/key/status` API endpoint.
|
||||
func (adm *AdminClient) GetKeyStatus(keyID string) (*KMSKeyStatus, error) {
|
||||
// GET /minio/admin/v1/kms/key/status?key-id=<keyID>
|
||||
// GET /minio/admin/v2/kms/key/status?key-id=<keyID>
|
||||
qv := url.Values{}
|
||||
qv.Set("key-id", keyID)
|
||||
reqData := requestData{
|
||||
relPath: "/v1/kms/key/status",
|
||||
relPath: adminAPIPrefix + "/kms/key/status",
|
||||
queryValues: qv,
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@ func (adm *AdminClient) InfoCannedPolicy(policyName string) ([]byte, error) {
|
||||
queryValues.Set("name", policyName)
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/info-canned-policy",
|
||||
relPath: adminAPIPrefix + "/info-canned-policy",
|
||||
queryValues: queryValues,
|
||||
}
|
||||
|
||||
// Execute GET on /minio/admin/v1/info-canned-policy
|
||||
// Execute GET on /minio/admin/v2/info-canned-policy
|
||||
resp, err := adm.executeMethod("GET", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
@@ -52,10 +52,10 @@ func (adm *AdminClient) InfoCannedPolicy(policyName string) ([]byte, error) {
|
||||
// ListCannedPolicies - list all configured canned policies.
|
||||
func (adm *AdminClient) ListCannedPolicies() (map[string][]byte, error) {
|
||||
reqData := requestData{
|
||||
relPath: "/v1/list-canned-policies",
|
||||
relPath: adminAPIPrefix + "/list-canned-policies",
|
||||
}
|
||||
|
||||
// Execute GET on /minio/admin/v1/list-canned-policies
|
||||
// Execute GET on /minio/admin/v2/list-canned-policies
|
||||
resp, err := adm.executeMethod("GET", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
@@ -86,11 +86,11 @@ func (adm *AdminClient) RemoveCannedPolicy(policyName string) error {
|
||||
queryValues.Set("name", policyName)
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/remove-canned-policy",
|
||||
relPath: adminAPIPrefix + "/remove-canned-policy",
|
||||
queryValues: queryValues,
|
||||
}
|
||||
|
||||
// Execute DELETE on /minio/admin/v1/remove-canned-policy to remove policy.
|
||||
// Execute DELETE on /minio/admin/v2/remove-canned-policy to remove policy.
|
||||
resp, err := adm.executeMethod("DELETE", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
@@ -111,12 +111,12 @@ func (adm *AdminClient) AddCannedPolicy(policyName, policy string) error {
|
||||
queryValues.Set("name", policyName)
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/add-canned-policy",
|
||||
relPath: adminAPIPrefix + "/add-canned-policy",
|
||||
queryValues: queryValues,
|
||||
content: []byte(policy),
|
||||
}
|
||||
|
||||
// Execute PUT on /minio/admin/v1/add-canned-policy to set policy.
|
||||
// Execute PUT on /minio/admin/v2/add-canned-policy to set policy.
|
||||
resp, err := adm.executeMethod("PUT", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
@@ -143,11 +143,11 @@ func (adm *AdminClient) SetPolicy(policyName, entityName string, isGroup bool) e
|
||||
queryValues.Set("isGroup", groupStr)
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/set-user-or-group-policy",
|
||||
relPath: adminAPIPrefix + "/set-user-or-group-policy",
|
||||
queryValues: queryValues,
|
||||
}
|
||||
|
||||
// Execute PUT on /minio/admin/v1/set-user-or-group-policy to set policy.
|
||||
// Execute PUT on /minio/admin/v2/set-user-or-group-policy to set policy.
|
||||
resp, err := adm.executeMethod("PUT", reqData)
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
|
||||
@@ -54,7 +54,7 @@ func (adm *AdminClient) StartProfiling(profiler ProfilerType) ([]StartProfilingR
|
||||
v := url.Values{}
|
||||
v.Set("profilerType", string(profiler))
|
||||
resp, err := adm.executeMethod("POST", requestData{
|
||||
relPath: "/v1/profiling/start",
|
||||
relPath: adminAPIPrefix + "/profiling/start",
|
||||
queryValues: v,
|
||||
})
|
||||
defer closeResponse(resp)
|
||||
@@ -83,7 +83,7 @@ func (adm *AdminClient) StartProfiling(profiler ProfilerType) ([]StartProfilingR
|
||||
// DownloadProfilingData makes an admin call to download profiling data of a standalone
|
||||
// server or of the whole cluster in case of a distributed setup.
|
||||
func (adm *AdminClient) DownloadProfilingData() (io.ReadCloser, error) {
|
||||
path := fmt.Sprintf("/v1/profiling/download")
|
||||
path := fmt.Sprintf(adminAPIPrefix + "/profiling/download")
|
||||
resp, err := adm.executeMethod("GET", requestData{
|
||||
relPath: path,
|
||||
})
|
||||
|
||||
@@ -53,7 +53,7 @@ func (adm *AdminClient) serviceCallAction(action ServiceAction) error {
|
||||
|
||||
// Request API to Restart server
|
||||
resp, err := adm.executeMethod("POST", requestData{
|
||||
relPath: "/v1/service",
|
||||
relPath: adminAPIPrefix + "/service",
|
||||
queryValues: queryValues,
|
||||
})
|
||||
defer closeResponse(resp)
|
||||
@@ -85,7 +85,7 @@ func (adm AdminClient) ServiceTrace(allTrace, errTrace bool, doneCh <-chan struc
|
||||
urlValues.Set("all", strconv.FormatBool(allTrace))
|
||||
urlValues.Set("err", strconv.FormatBool(errTrace))
|
||||
reqData := requestData{
|
||||
relPath: "/v1/trace",
|
||||
relPath: adminAPIPrefix + "/trace",
|
||||
queryValues: urlValues,
|
||||
}
|
||||
// Execute GET to call trace handler
|
||||
|
||||
@@ -54,10 +54,10 @@ func (l LockEntries) Swap(i, j int) {
|
||||
|
||||
// TopLocks - returns the oldest locks in a minio setup.
|
||||
func (adm *AdminClient) TopLocks() (LockEntries, error) {
|
||||
// Execute GET on /minio/admin/v1/top/locks
|
||||
// Execute GET on /minio/admin/v2/top/locks
|
||||
// to get the oldest locks in a minio setup.
|
||||
resp, err := adm.executeMethod("GET",
|
||||
requestData{relPath: "/v1/top/locks"})
|
||||
requestData{relPath: adminAPIPrefix + "/top/locks"})
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -38,7 +38,7 @@ func (adm *AdminClient) ServerUpdate(updateURL string) (us ServerUpdateStatus, e
|
||||
|
||||
// Request API to Restart server
|
||||
resp, err := adm.executeMethod("POST", requestData{
|
||||
relPath: "/v1/update",
|
||||
relPath: adminAPIPrefix + "/update",
|
||||
queryValues: queryValues,
|
||||
})
|
||||
defer closeResponse(resp)
|
||||
|
||||
@@ -49,11 +49,11 @@ func (adm *AdminClient) RemoveUser(accessKey string) error {
|
||||
queryValues.Set("accessKey", accessKey)
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/remove-user",
|
||||
relPath: adminAPIPrefix + "/remove-user",
|
||||
queryValues: queryValues,
|
||||
}
|
||||
|
||||
// Execute DELETE on /minio/admin/v1/remove-user to remove a user.
|
||||
// Execute DELETE on /minio/admin/v2/remove-user to remove a user.
|
||||
resp, err := adm.executeMethod("DELETE", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
@@ -71,10 +71,10 @@ func (adm *AdminClient) RemoveUser(accessKey string) error {
|
||||
// ListUsers - list all users.
|
||||
func (adm *AdminClient) ListUsers() (map[string]UserInfo, error) {
|
||||
reqData := requestData{
|
||||
relPath: "/v1/list-users",
|
||||
relPath: adminAPIPrefix + "/list-users",
|
||||
}
|
||||
|
||||
// Execute GET on /minio/admin/v1/list-users
|
||||
// Execute GET on /minio/admin/v2/list-users
|
||||
resp, err := adm.executeMethod("GET", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
@@ -105,11 +105,11 @@ func (adm *AdminClient) GetUserInfo(name string) (u UserInfo, err error) {
|
||||
queryValues.Set("accessKey", name)
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/user-info",
|
||||
relPath: adminAPIPrefix + "/user-info",
|
||||
queryValues: queryValues,
|
||||
}
|
||||
|
||||
// Execute GET on /minio/admin/v1/user-info
|
||||
// Execute GET on /minio/admin/v2/user-info
|
||||
resp, err := adm.executeMethod("GET", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
@@ -160,12 +160,12 @@ func (adm *AdminClient) SetUser(accessKey, secretKey string, status AccountStatu
|
||||
queryValues.Set("accessKey", accessKey)
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/add-user",
|
||||
relPath: adminAPIPrefix + "/add-user",
|
||||
queryValues: queryValues,
|
||||
content: econfigBytes,
|
||||
}
|
||||
|
||||
// Execute PUT on /minio/admin/v1/add-user to set a user.
|
||||
// Execute PUT on /minio/admin/v2/add-user to set a user.
|
||||
resp, err := adm.executeMethod("PUT", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
@@ -192,11 +192,11 @@ func (adm *AdminClient) SetUserStatus(accessKey string, status AccountStatus) er
|
||||
queryValues.Set("status", string(status))
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/set-user-status",
|
||||
relPath: adminAPIPrefix + "/set-user-status",
|
||||
queryValues: queryValues,
|
||||
}
|
||||
|
||||
// Execute PUT on /minio/admin/v1/set-user-status to set status.
|
||||
// Execute PUT on /minio/admin/v2/set-user-status to set status.
|
||||
resp, err := adm.executeMethod("PUT", reqData)
|
||||
|
||||
defer closeResponse(resp)
|
||||
|
||||
@@ -30,6 +30,12 @@ import (
|
||||
"github.com/minio/minio-go/v6/pkg/s3utils"
|
||||
)
|
||||
|
||||
const (
|
||||
// AdminAPIVersion - admin api version used in the request.
|
||||
AdminAPIVersion = "v2"
|
||||
adminAPIPrefix = "/" + AdminAPIVersion
|
||||
)
|
||||
|
||||
// sum256 calculate sha256 sum for an input byte array.
|
||||
func sum256(data []byte) []byte {
|
||||
hash := sha256.New()
|
||||
|
||||
Reference in New Issue
Block a user