mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
fix: disk usage capacity metric reporting (#11435)
This commit is contained in:
parent
075c429021
commit
67a8f37df0
@ -387,7 +387,7 @@ func getS3RequestsInFlightMD() MetricDescription {
|
||||
Subsystem: requestsSubsystem,
|
||||
Name: inflightTotal,
|
||||
Help: "Total number of S3 requests currently in flight.",
|
||||
Type: counterMetric,
|
||||
Type: gaugeMetric,
|
||||
}
|
||||
}
|
||||
func getS3RequestsTotalMD() MetricDescription {
|
||||
@ -1106,23 +1106,23 @@ func getClusterStorageMetrics() MetricsGroup {
|
||||
|
||||
metrics.Metrics = append(metrics.Metrics, Metric{
|
||||
Description: getClusterCapacityTotalBytesMD(),
|
||||
Value: float64(GetTotalCapacity(ctx)),
|
||||
Value: float64(GetTotalCapacity(storageInfo.Disks)),
|
||||
})
|
||||
|
||||
metrics.Metrics = append(metrics.Metrics, Metric{
|
||||
Description: getClusterCapacityFreeBytesMD(),
|
||||
Value: float64(GetTotalCapacityFree(ctx)),
|
||||
Value: float64(GetTotalCapacityFree(storageInfo.Disks)),
|
||||
})
|
||||
|
||||
s, _ := objLayer.StorageInfo(GlobalContext)
|
||||
metrics.Metrics = append(metrics.Metrics, Metric{
|
||||
Description: getClusterCapacityUsageBytesMD(),
|
||||
Value: GetTotalUsableCapacity(ctx, s),
|
||||
Value: GetTotalUsableCapacity(storageInfo.Disks, s),
|
||||
})
|
||||
|
||||
metrics.Metrics = append(metrics.Metrics, Metric{
|
||||
Description: getClusterCapacityUsageFreeBytesMD(),
|
||||
Value: GetTotalUsableCapacityFree(ctx, s),
|
||||
Value: GetTotalUsableCapacityFree(storageInfo.Disks, s),
|
||||
})
|
||||
|
||||
metrics.Metrics = append(metrics.Metrics, Metric{
|
||||
|
@ -535,7 +535,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
|
||||
"Total capacity online in the cluster",
|
||||
nil, nil),
|
||||
prometheus.GaugeValue,
|
||||
float64(GetTotalCapacity(GlobalContext)),
|
||||
float64(GetTotalCapacity(server.Disks)),
|
||||
)
|
||||
|
||||
// Report total capacity free
|
||||
@ -545,7 +545,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
|
||||
"Total free capacity online in the cluster",
|
||||
nil, nil),
|
||||
prometheus.GaugeValue,
|
||||
float64(GetTotalCapacityFree(GlobalContext)),
|
||||
float64(GetTotalCapacityFree(server.Disks)),
|
||||
)
|
||||
|
||||
s, _ := objLayer.StorageInfo(GlobalContext)
|
||||
@ -556,7 +556,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
|
||||
"Total usable capacity online in the cluster",
|
||||
nil, nil),
|
||||
prometheus.GaugeValue,
|
||||
GetTotalUsableCapacity(GlobalContext, s),
|
||||
GetTotalUsableCapacity(server.Disks, s),
|
||||
)
|
||||
// Report total usable capacity free
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@ -565,7 +565,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
|
||||
"Total free usable capacity online in the cluster",
|
||||
nil, nil),
|
||||
prometheus.GaugeValue,
|
||||
GetTotalUsableCapacityFree(GlobalContext, s),
|
||||
GetTotalUsableCapacityFree(server.Disks, s),
|
||||
)
|
||||
|
||||
// MinIO Offline Disks per node
|
||||
|
@ -18,22 +18,22 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/minio/minio/pkg/madmin"
|
||||
)
|
||||
|
||||
// GetTotalCapacity gets the total capacity in the cluster.
|
||||
func GetTotalCapacity(ctx context.Context) (capacity uint64) {
|
||||
d := globalNotificationSys.DiskHwInfo(ctx)
|
||||
for _, s := range d {
|
||||
capacity += s.GetTotalCapacity()
|
||||
func GetTotalCapacity(diskInfo []madmin.Disk) (capacity uint64) {
|
||||
|
||||
for _, disk := range diskInfo {
|
||||
capacity += disk.TotalSpace
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetTotalUsableCapacity gets the total usable capacity in the cluster.
|
||||
// This value is not an accurate representation of total usable in a multi-tenant deployment.
|
||||
func GetTotalUsableCapacity(ctx context.Context, s StorageInfo) (capacity float64) {
|
||||
raw := GetTotalCapacity(ctx)
|
||||
func GetTotalUsableCapacity(diskInfo []madmin.Disk, s StorageInfo) (capacity float64) {
|
||||
raw := GetTotalCapacity(diskInfo)
|
||||
var approxDataBlocks float64
|
||||
var actualDisks float64
|
||||
for _, scData := range s.Backend.StandardSCData {
|
||||
@ -45,18 +45,17 @@ func GetTotalUsableCapacity(ctx context.Context, s StorageInfo) (capacity float6
|
||||
}
|
||||
|
||||
// GetTotalCapacityFree gets the total capacity free in the cluster.
|
||||
func GetTotalCapacityFree(ctx context.Context) (capacity uint64) {
|
||||
d := globalNotificationSys.DiskHwInfo(ctx)
|
||||
for _, s := range d {
|
||||
capacity += s.GetTotalFreeCapacity()
|
||||
func GetTotalCapacityFree(diskInfo []madmin.Disk) (capacity uint64) {
|
||||
for _, d := range diskInfo {
|
||||
capacity += d.AvailableSpace
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetTotalUsableCapacityFree gets the total usable capacity free in the cluster.
|
||||
// This value is not an accurate representation of total free in a multi-tenant deployment.
|
||||
func GetTotalUsableCapacityFree(ctx context.Context, s StorageInfo) (capacity float64) {
|
||||
raw := GetTotalCapacityFree(ctx)
|
||||
func GetTotalUsableCapacityFree(diskInfo []madmin.Disk, s StorageInfo) (capacity float64) {
|
||||
raw := GetTotalCapacityFree(diskInfo)
|
||||
var approxDataBlocks float64
|
||||
var actualDisks float64
|
||||
for _, scData := range s.Backend.StandardSCData {
|
||||
|
Loading…
Reference in New Issue
Block a user