Expose total and available disk space (#7453)

This commit is contained in:
Harshavardhana
2019-04-04 21:21:50 -07:00
committed by Nitish Tiwari
parent 979309148e
commit 0188009c7e
7 changed files with 94 additions and 56 deletions

View File

@@ -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

View File

@@ -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(

View File

@@ -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.

View File

@@ -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
}

View File

@@ -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