Skip to content

Commit

Permalink
exclude devices in drain status from free space calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Mar 12, 2018
1 parent 2a253ae commit 1d1ddb5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions status.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,23 @@ func (d deviceStatus) IO() string {

func (s *efesStatus) Print() {
// Sum totals
var totalUsed, totalSize int64 // in MB
var totalUsed, totalSize, totalFree int64 // in MB
for _, d := range s.devices {
if d.BytesUsed != nil {
totalUsed += *d.BytesUsed
}
if d.BytesTotal != nil {
totalSize += *d.BytesTotal
}
if d.BytesFree != nil && d.Status == "alive" {
totalFree += *d.BytesFree
}
}
totalFree := totalSize - totalUsed
var totalUse int64
if totalSize == 0 {
totalUse = 0
} else {
totalUse = (100 * totalUsed) / totalSize
totalUse = 100 - (100*totalFree)/totalSize
}

// Convert to GB
Expand Down

0 comments on commit 1d1ddb5

Please sign in to comment.