Skip to content

Commit

Permalink
method improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
rderoldan1 committed Jul 26, 2013
1 parent 7bfe9be commit bf826b3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/usagewatch_ext/mac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ def self.uw_diskused

# Show the percentage of disk used.
def self.uw_diskused_perc
df = `df -kl`
total, used = 0.0, 0.0
df, total, used = `df -kl`, 0.0, 0.0
df.each_line.with_index do |line, line_index|
line = line.split(" ")
next if line_index.eql? 0 or line[0] =~ /localhost/ #ignore backup filesystem
total += ((line[3].to_f)/1024)/1024
used +=((line[2].to_f)/1024)/1024
total += to_gb line[3].to_f
used += to_gb line[2].to_f
end
((used/total) * 100).round(2)
end
Expand Down Expand Up @@ -104,4 +103,8 @@ def self.top(lines)
end
array
end

def self.to_gb(bytes)
(bytes/1024)/1024
end
end

0 comments on commit bf826b3

Please sign in to comment.