vmpooler 0.12.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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