From 1d1ddb530cad9c4c9bfc71e8bb76afb944e8091f Mon Sep 17 00:00:00 2001
From: Cenk Alti <cenkalti@gmail.com>
Date: Mon, 12 Mar 2018 21:07:32 +0300
Subject: [PATCH] exclude devices in drain status from free space calculation

---
 status.go | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/status.go b/status.go
index 602d05f..a74e06a 100644
--- a/status.go
+++ b/status.go
@@ -60,7 +60,7 @@ 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
@@ -68,13 +68,15 @@ func (s *efesStatus) Print() {
 		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