mirror of
https://github.com/minio/minio.git
synced 2025-11-07 04:42:56 -05:00
Expose total and available disk space (#7453)
This commit is contained in:
committed by
Nitish Tiwari
parent
979309148e
commit
0188009c7e
@@ -250,7 +250,9 @@ func (fs *FSObjects) StorageInfo(ctx context.Context) StorageInfo {
|
||||
used = atomic.LoadUint64(&fs.totalUsed)
|
||||
}
|
||||
storageInfo := StorageInfo{
|
||||
Used: used,
|
||||
Used: used,
|
||||
Total: di.Total,
|
||||
Available: di.Free,
|
||||
}
|
||||
storageInfo.Backend.Type = BackendFS
|
||||
return storageInfo
|
||||
|
||||
@@ -142,6 +142,26 @@ func (c *minioCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
float64(s.Used),
|
||||
)
|
||||
|
||||
// Total disk available space seen by Minio server instance
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName("minio", "disk", "storage_available_bytes"),
|
||||
"Total disk available space seen by Minio server instance",
|
||||
nil, nil),
|
||||
prometheus.GaugeValue,
|
||||
float64(s.Available),
|
||||
)
|
||||
|
||||
// Total disk space seen by Minio server instance
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName("minio", "disk", "storage_total_bytes"),
|
||||
"Total disk space seen by Minio server instance",
|
||||
nil, nil),
|
||||
prometheus.GaugeValue,
|
||||
float64(s.Total),
|
||||
)
|
||||
|
||||
// Minio Total Disk/Offline Disk
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
|
||||
@@ -41,6 +41,10 @@ const (
|
||||
type StorageInfo struct {
|
||||
Used uint64 // Used total used per tenant.
|
||||
|
||||
Total uint64 // Total disk space.
|
||||
|
||||
Available uint64 // Total disk space available.
|
||||
|
||||
// Backend type.
|
||||
Backend struct {
|
||||
// Represents various backend types, currently on FS and Erasure.
|
||||
|
||||
@@ -307,6 +307,8 @@ func (s *xlSets) StorageInfo(ctx context.Context) StorageInfo {
|
||||
for _, set := range s.sets {
|
||||
lstorageInfo := set.StorageInfo(ctx)
|
||||
storageInfo.Used = storageInfo.Used + lstorageInfo.Used
|
||||
storageInfo.Total = storageInfo.Total + lstorageInfo.Total
|
||||
storageInfo.Available = storageInfo.Available + lstorageInfo.Available
|
||||
storageInfo.Backend.OnlineDisks = storageInfo.Backend.OnlineDisks + lstorageInfo.Backend.OnlineDisks
|
||||
storageInfo.Backend.OfflineDisks = storageInfo.Backend.OfflineDisks + lstorageInfo.Backend.OfflineDisks
|
||||
}
|
||||
|
||||
11
cmd/xl-v1.go
11
cmd/xl-v1.go
@@ -120,18 +120,23 @@ func getStorageInfo(disks []StorageAPI) StorageInfo {
|
||||
return StorageInfo{}
|
||||
}
|
||||
|
||||
// Combine all disks to get total usage.
|
||||
var used uint64
|
||||
// Combine all disks to get total usage
|
||||
var used, total, available uint64
|
||||
for _, di := range validDisksInfo {
|
||||
used = used + di.Used
|
||||
total = total + di.Total
|
||||
available = available + di.Free
|
||||
}
|
||||
|
||||
_, sscParity := getRedundancyCount(standardStorageClass, len(disks))
|
||||
_, rrscparity := getRedundancyCount(reducedRedundancyStorageClass, len(disks))
|
||||
|
||||
storageInfo := StorageInfo{
|
||||
Used: used,
|
||||
Used: used,
|
||||
Total: total,
|
||||
Available: available,
|
||||
}
|
||||
|
||||
storageInfo.Backend.Type = BackendErasure
|
||||
storageInfo.Backend.OnlineDisks = onlineDisks
|
||||
storageInfo.Backend.OfflineDisks = offlineDisks
|
||||
|
||||
Reference in New Issue
Block a user