graphiterb 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
data/graphiterb.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{graphiterb}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Philip (flip) Kromer (@mrflip)"]
@@ -33,25 +33,31 @@ module Graphiterb
33
33
 
34
34
  def memory lines
35
35
  lines.each do |line|
36
- next unless line =~ /^Mem: *\d+k *total, *(\d+)k *used, *(\d+)k *free/
37
- return [$1, $2].map(&:to_i)
36
+ next unless line =~ /^Mem: *(\d+)k *total, *(\d+)k *used, *(\d+)k *free/
37
+ total = $1.to_f
38
+ return [$2, $3].map do |bytes|
39
+ bytes.to_f / total rescue 0.0
40
+ end
38
41
  end
39
42
  [0,0]
40
43
  end
41
44
 
42
45
  def swap lines
43
46
  lines.each do |line|
44
- next unless line =~ /^Swap: *\d+k *total, *(\d+)k *used, *(\d+)k *free/
45
- return [$1, $2].map(&:to_i)
47
+ next unless line =~ /^Swap: *(\d+)k *total, *(\d+)k *used, *(\d+)k *free/
48
+ total = $1.to_f
49
+ return [$2, $3].map do |bytes|
50
+ bytes.to_f / total rescue 0.0
51
+ end
46
52
  end
47
53
  [0,0]
48
54
  end
49
55
 
50
-
51
56
  def get_metrics metrics, since
52
- df.each do |handle, size, spaceused, spacefree, percentfree, location|
57
+ df.each do |handle, size, spaceused, spacefree, percentused, location|
53
58
  disk_name = handle.gsub(/^\//, '').split('/')
54
- metrics << [scope(hostname, disk_name, 'available'), spacefree.to_i]
59
+ percent_free = (100.0 * spaceused.to_f / (spaceused.to_f + spacefree.to_f)) rescue 0.0
60
+ metrics << [scope(hostname, disk_name, 'available'), percent_free]
55
61
  end
56
62
 
57
63
  lines = top
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiterb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Philip (flip) Kromer (@mrflip)