vmpooler 0.13.0 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/vmpooler +15 -10
- data/lib/vmpooler.rb +4 -16
- data/lib/vmpooler/api.rb +41 -34
- data/lib/vmpooler/api/helpers.rb +1 -1
- data/lib/vmpooler/api/request_logger.rb +20 -0
- data/lib/vmpooler/api/v1.rb +52 -27
- data/lib/vmpooler/generic_connection_pool.rb +7 -5
- data/lib/vmpooler/metrics.rb +24 -0
- data/lib/vmpooler/metrics/dummy_statsd.rb +24 -0
- data/lib/vmpooler/metrics/graphite.rb +47 -0
- data/lib/vmpooler/metrics/promstats.rb +380 -0
- data/lib/vmpooler/metrics/promstats/collector_middleware.rb +121 -0
- data/lib/vmpooler/metrics/statsd.rb +40 -0
- data/lib/vmpooler/pool_manager.rb +18 -28
- data/lib/vmpooler/providers/dummy.rb +2 -1
- data/lib/vmpooler/providers/vsphere.rb +88 -25
- data/lib/vmpooler/util/parsing.rb +16 -0
- data/lib/vmpooler/version.rb +1 -1
- metadata +25 -6
- data/lib/vmpooler/dummy_statsd.rb +0 -22
- data/lib/vmpooler/graphite.rb +0 -42
- data/lib/vmpooler/statsd.rb +0 -37
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Vmpooler
|
4
|
-
class DummyStatsd
|
5
|
-
attr_reader :server, :port, :prefix
|
6
|
-
|
7
|
-
def initialize(*)
|
8
|
-
end
|
9
|
-
|
10
|
-
def increment(*)
|
11
|
-
true
|
12
|
-
end
|
13
|
-
|
14
|
-
def gauge(*)
|
15
|
-
true
|
16
|
-
end
|
17
|
-
|
18
|
-
def timing(*)
|
19
|
-
true
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/vmpooler/graphite.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rubygems' unless defined?(Gem)
|
4
|
-
|
5
|
-
module Vmpooler
|
6
|
-
class Graphite
|
7
|
-
attr_reader :server, :port, :prefix
|
8
|
-
|
9
|
-
def initialize(params = {})
|
10
|
-
raise ArgumentError, "Graphite server is required. Config: #{params.inspect}" if params['server'].nil? || params['server'].empty?
|
11
|
-
|
12
|
-
@server = params['server']
|
13
|
-
@port = params['port'] || 2003
|
14
|
-
@prefix = params['prefix'] || 'vmpooler'
|
15
|
-
end
|
16
|
-
|
17
|
-
def increment(label)
|
18
|
-
log label, 1
|
19
|
-
end
|
20
|
-
|
21
|
-
def gauge(label, value)
|
22
|
-
log label, value
|
23
|
-
end
|
24
|
-
|
25
|
-
def timing(label, duration)
|
26
|
-
log label, duration
|
27
|
-
end
|
28
|
-
|
29
|
-
def log(path, value)
|
30
|
-
Thread.new do
|
31
|
-
socket = TCPSocket.new(server, port)
|
32
|
-
begin
|
33
|
-
socket.puts "#{prefix}.#{path} #{value} #{Time.now.to_i}"
|
34
|
-
ensure
|
35
|
-
socket.close
|
36
|
-
end
|
37
|
-
end
|
38
|
-
rescue StandardError => e
|
39
|
-
warn "Failure logging #{path} to graphite server [#{server}:#{port}]: #{e}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/lib/vmpooler/statsd.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rubygems' unless defined?(Gem)
|
4
|
-
require 'statsd'
|
5
|
-
|
6
|
-
module Vmpooler
|
7
|
-
class Statsd
|
8
|
-
attr_reader :server, :port, :prefix
|
9
|
-
|
10
|
-
def initialize(params = {})
|
11
|
-
raise ArgumentError, "Statsd server is required. Config: #{params.inspect}" if params['server'].nil? || params['server'].empty?
|
12
|
-
|
13
|
-
host = params['server']
|
14
|
-
@port = params['port'] || 8125
|
15
|
-
@prefix = params['prefix'] || 'vmpooler'
|
16
|
-
@server = ::Statsd.new(host, @port)
|
17
|
-
end
|
18
|
-
|
19
|
-
def increment(label)
|
20
|
-
server.increment(prefix + '.' + label)
|
21
|
-
rescue StandardError => e
|
22
|
-
warn "Failure incrementing #{prefix}.#{label} on statsd server [#{server}:#{port}]: #{e}"
|
23
|
-
end
|
24
|
-
|
25
|
-
def gauge(label, value)
|
26
|
-
server.gauge(prefix + '.' + label, value)
|
27
|
-
rescue StandardError => e
|
28
|
-
warn "Failure updating gauge #{prefix}.#{label} on statsd server [#{server}:#{port}]: #{e}"
|
29
|
-
end
|
30
|
-
|
31
|
-
def timing(label, duration)
|
32
|
-
server.timing(prefix + '.' + label, duration)
|
33
|
-
rescue StandardError => e
|
34
|
-
warn "Failure updating timing #{prefix}.#{label} on statsd server [#{server}:#{port}]: #{e}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|