haproxystats 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/haproxystats/stats.rb +22 -10
  2. metadata +1 -1
@@ -52,17 +52,19 @@ class HAProxyStats < HAProxySocket
52
52
  out
53
53
  end
54
54
 
55
- # Return number of backend servers for +service+ that are UP
55
+ # Return UP servers as array
56
56
  def up(service)
57
- # Return a list of UP severs
58
- out = Array.new
59
- backends(service).each do |this|
60
- if @stats[service][this]['status'] == 'UP'
61
- out = out << this
62
- end
63
- end
64
- # Return the ratio
65
- out
57
+ find(service, 'UP')
58
+ end
59
+
60
+ # Return MAINT servers as array
61
+ def maint(service)
62
+ find(service, 'MAINT')
63
+ end
64
+
65
+ # Return DOWN servers as array
66
+ def down(service)
67
+ find(service, 'DOWN')
66
68
  end
67
69
 
68
70
  # Return a ratio of the backend servers that are UP (between 0 and 1)
@@ -70,4 +72,14 @@ class HAProxyStats < HAProxySocket
70
72
  def upratio(service)
71
73
  up(service).length.to_f / backends(service).length
72
74
  end
75
+
76
+ private
77
+ def find(service, state)
78
+ out = Array.new
79
+ backends(service).each do |this|
80
+ if @stats[service][this]['status'] == state
81
+ out = out << this
82
+ end
83
+ end
84
+ end
73
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haproxystats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: