mirror of
https://github.com/minio/minio.git
synced 2025-11-28 13:09:09 -05:00
Add data usage collect with its new admin API (#8553)
Admin data usage info API returns the following (Only FS & XL, for now) - Number of buckets - Number of objects - The total size of objects - Objects histogram - Bucket sizes
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/minio/minio/pkg/cpu"
|
||||
@@ -140,6 +141,63 @@ func (adm *AdminClient) StorageInfo() (StorageInfo, error) {
|
||||
return storageInfo, nil
|
||||
}
|
||||
|
||||
type objectHistogramInterval struct {
|
||||
name string
|
||||
start, end int64
|
||||
}
|
||||
|
||||
// ObjectsHistogramIntervals contains the list of intervals
|
||||
// of an histogram analysis of objects sizes.
|
||||
var ObjectsHistogramIntervals = []objectHistogramInterval{
|
||||
{"LESS_THAN_1024_B", -1, 1024 - 1},
|
||||
{"BETWEEN_1024_B_AND_1_MB", 1024, 1024*1024 - 1},
|
||||
{"BETWEEN_1_MB_AND_10_MB", 1024 * 1024, 1024*1024*10 - 1},
|
||||
{"BETWEEN_10_MB_AND_64_MB", 1024 * 1024 * 10, 1024*1024*64 - 1},
|
||||
{"BETWEEN_64_MB_AND_128_MB", 1024 * 1024 * 64, 1024*1024*128 - 1},
|
||||
{"BETWEEN_128_MB_AND_512_MB", 1024 * 1024 * 128, 1024*1024*512 - 1},
|
||||
{"GREATER_THAN_512_MB", 1024 * 1024 * 512, -1},
|
||||
}
|
||||
|
||||
// DataUsageInfo represents data usage of an Object API
|
||||
type DataUsageInfo struct {
|
||||
LastUpdate time.Time `json:"lastUpdate"`
|
||||
ObjectsCount uint64 `json:"objectsCount"`
|
||||
ObjectsTotalSize uint64 `json:"objectsTotalSize"`
|
||||
ObjectsSizesHistogram map[string]uint64 `json:"objectsSizesHistogram"`
|
||||
|
||||
BucketsCount uint64 `json:"bucketsCount"`
|
||||
BucketsSizes map[string]uint64 `json:"bucketsSizes"`
|
||||
}
|
||||
|
||||
// DataUsageInfo - returns data usage of the current object API
|
||||
func (adm *AdminClient) DataUsageInfo() (DataUsageInfo, error) {
|
||||
resp, err := adm.executeMethod("GET", requestData{relPath: adminAPIPrefix + "/datausageinfo"})
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return DataUsageInfo{}, err
|
||||
}
|
||||
|
||||
// Check response http status code
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return DataUsageInfo{}, httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
// Unmarshal the server's json response
|
||||
var dataUsageInfo DataUsageInfo
|
||||
|
||||
respBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return DataUsageInfo{}, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(respBytes, &dataUsageInfo)
|
||||
if err != nil {
|
||||
return DataUsageInfo{}, err
|
||||
}
|
||||
|
||||
return dataUsageInfo, nil
|
||||
}
|
||||
|
||||
// ServerDrivesPerfInfo holds informantion about address and write speed of
|
||||
// all drives in a single server node
|
||||
type ServerDrivesPerfInfo struct {
|
||||
|
||||
Reference in New Issue
Block a user