From 8486051255701aa574920e324b66400de91f5ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Pujol=20Ahull=C3=B3?= Date: Tue, 9 Sep 2014 12:39:46 +0200 Subject: [PATCH] issue #14 - amendments for Ubuntu 14.04 1. Removed first line from df command (just the header). International strings make it behave wrong. 2. Amended the percentual disk usage to get the correct column. --- lib/usagewatch/linux.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/usagewatch/linux.rb b/lib/usagewatch/linux.rb index f0a2b32..dd5a879 100644 --- a/lib/usagewatch/linux.rb +++ b/lib/usagewatch/linux.rb @@ -4,6 +4,7 @@ module Usagewatch # Show the amount of total disk used in Gigabytes def self.uw_diskused @df = `df` + @df = @df.split("\n").drop(1).join("\n") @parts = @df.split(" ").map { |s| s.to_i } @sum = 0 for i in (9..@parts.size - 1).step(6) do @@ -16,7 +17,7 @@ def self.uw_diskused # Show the percentage of disk used. def self.uw_diskused_perc df = `df --total` - df.split(" ").last.to_f.round(2) + df.split("\n").last.split(" ")[4].to_f.round(2) end # Show the percentage of CPU used