github.com/netdata/go.d.plugin@v0.58.1/modules/scaleio/collect_storage_pool.go (about) 1 // SPDX-License-Identifier: GPL-3.0-or-later 2 3 package scaleio 4 5 import "github.com/netdata/go.d.plugin/modules/scaleio/client" 6 7 func (s ScaleIO) collectStoragePool(ss map[string]client.StoragePoolStatistics) map[string]storagePoolMetrics { 8 ms := make(map[string]storagePoolMetrics, len(ss)) 9 10 for id, stats := range ss { 11 pool, ok := s.discovered.pool[id] 12 if !ok { 13 continue 14 } 15 var pm storagePoolMetrics 16 collectStoragePoolCapacity(&pm, stats, pool) 17 collectStoragePoolComponents(&pm, stats) 18 19 ms[id] = pm 20 } 21 return ms 22 } 23 24 func collectStoragePoolCapacity(pm *storagePoolMetrics, ps client.StoragePoolStatistics, pool client.StoragePool) { 25 collectCapacity(&pm.Capacity.capacity, ps.CapacityStatistics) 26 pm.Capacity.Utilization = calcCapacityUtilization(ps.CapacityInUseInKb, ps.MaxCapacityInKb, pool.SparePercentage) 27 pm.Capacity.AlertThreshold.Critical = pool.CapacityAlertCriticalThreshold 28 pm.Capacity.AlertThreshold.High = pool.CapacityAlertHighThreshold 29 } 30 31 func collectStoragePoolComponents(pm *storagePoolMetrics, ps client.StoragePoolStatistics) { 32 pm.Components.Devices = ps.NumOfDevices 33 pm.Components.Snapshots = ps.NumOfSnapshots 34 pm.Components.Volumes = ps.NumOfVolumes 35 pm.Components.Vtrees = ps.NumOfVtrees 36 } 37 38 func calcCapacityUtilization(inUse int64, max int64, sparePercent int64) float64 { 39 spare := float64(max) / 100 * float64(sparePercent) 40 return divFloat(float64(100*inUse), float64(max)-spare) 41 }