echo_cli 0.6.32 → 0.6.33

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25536f05cb3b0450889c3ac1e6fe6fdb223dd5e8
4
- data.tar.gz: ed64ce29b3318c3a77dce4381972114a62ff6a39
3
+ metadata.gz: 5f538e55c167475588bcdddfe4ffb4d6808b869c
4
+ data.tar.gz: e377c43cd10c5a199cc7e7693888c5b02db225db
5
5
  SHA512:
6
- metadata.gz: 9e85a94067b22e442552d944056dd6431d0e4efc264afb0f5bce0bbe2991789e059c2368f76e2ff68814fd4e28b2474a0324228035afe793fff915d40f536c34
7
- data.tar.gz: a8f3b1d2c714bc4eec19dec7fd9ff14c54d769f430f29a4f46daccea4a7c04bb3d8d06f1057db9be4578408a78a01e5b4896d1a826ad3a5864f5ee6d6c6891de
6
+ metadata.gz: cf1b9790803ef37b1be2a370c5bfb3010454fb12a152e42f0a6755b5f42ee99ab01c6d0ef43e528b5ef3a10ce4d09920363f1eb7f4efd065d2258a529ee8671b
7
+ data.tar.gz: 3e1530c96aafb0cab03f65c6d6f504a50b8fd2222a6f5dc699b33a2f6518093c650343e7e4ac2f49ae0c6171006799c48623061b7c4d425894eedabaeb267cc4
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
+ /.gem/
3
4
  /Gemfile.lock
4
5
  /_yardoc/
5
6
  /coverage/
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "echo_cli"
8
8
  spec.version = Echo_cli::VERSION
9
9
  spec.authors = ["Brandon Raphael"]
10
- spec.email = ["brandonraphael1@gmail.com"]
10
+ spec.email = ["braphael@email.arizona.edu"]
11
11
 
12
12
  spec.summary = "A gem to interact directly with Echo's stack. Post metrics to Echo's StatsD server."
13
13
  spec.homepage = "https://www.github.allstate.com"
@@ -46,12 +46,12 @@ module Echo_cli
46
46
  time_start = Time.new.to_i.to_s
47
47
 
48
48
  # sort of a mini-smoketest to ensure the posts will work before creating a background process
49
- helper.do_post_tcp(ENV["ECHO_CLI_HOST"], "8125", metric)
49
+ helper.do_post_udp(ENV["ECHO_CLI_HOST"], "8125", metric)
50
50
 
51
51
  pid = Process.fork do
52
52
  prng = Random.new
53
53
  while true do
54
- helper.do_post_tcp(ENV["ECHO_CLI_HOST"], "8125", metric)
54
+ helper.do_post_udp(ENV["ECHO_CLI_HOST"], "8125", metric)
55
55
  sleep prng.rand(0.1...1.0)
56
56
  end
57
57
  end
@@ -65,7 +65,7 @@ module Echo_cli
65
65
  end
66
66
 
67
67
  while num > 0
68
- helper.do_post_tcp(ENV["ECHO_CLI_HOST"], "8125", metric)
68
+ helper.do_post_udp(ENV["ECHO_CLI_HOST"], "8125", metric)
69
69
  puts "\nPosted ".green + metric.yellow + " to ".green + "http://".yellow + ENV["ECHO_CLI_HOST"].yellow + ":".yellow + "8125".yellow + " at ".green + Time.new.to_i.to_s.yellow
70
70
  num -= 1
71
71
  end
@@ -145,7 +145,7 @@ module Echo_cli
145
145
  > $ echo_cli populate 'example.back.populate:1|c' {600} {100}
146
146
  LONGDESC
147
147
 
148
- def populate(metric, timespan = 600, frequency = 600)
148
+ def populate(metric, timespan = 1209600, frequency = 600)
149
149
  helper = Helper.new
150
150
  helper.set_envs
151
151
  metric = metric.gsub(/'/,"").gsub(/"/,"")
@@ -159,6 +159,8 @@ module Echo_cli
159
159
 
160
160
  if input == "y"
161
161
  puts "\nPopulating..."
162
+ timespan = timespan.to_i
163
+ frequency = frequency.to_i
162
164
  while timespan >= 0
163
165
  to_post = helper.get_metric_string_populate(metric) + " " + prng.rand(0...100).to_s + " " + (now - timespan).to_s
164
166
  helper.do_post_tcp(ENV["ECHO_CLI_HOST"], "2003", to_post)
@@ -257,13 +259,13 @@ module Echo_cli
257
259
  type = metric[metric.index('|') + 1 .. metric.length]
258
260
  case type
259
261
  when 'c'
260
- return "stats.counters." + metric[0..metric.index(':')-1] + ".*"
262
+ return metric[0..metric.index(':')-1] + ".*"
261
263
  when 'ms'
262
- return "stats.timers." + metric[0..metric.index(':')-1] + ".*"
264
+ return metric[0..metric.index(':')-1] + ".*"
263
265
  when 's'
264
- return "stats.sets." + metric[0..metric.index(':')-1] + ".*"
266
+ return metric[0..metric.index(':')-1] + ".*"
265
267
  when 'g'
266
- return "stats.gauges." + metric[0..metric.index(':')-1]
268
+ return metric[0..metric.index(':')-1]
267
269
  end
268
270
  end
269
271
 
@@ -271,13 +273,13 @@ module Echo_cli
271
273
  type = metric[metric.index('|') + 1 .. metric.length]
272
274
  case type
273
275
  when 'c'
274
- return "stats.counters." + metric[0..metric.index(':')-1] + ".count"
276
+ return metric[0..metric.index(':')-1] + ".count"
275
277
  when 'ms'
276
- return "stats.timers." + metric[0..metric.index(':')-1] + ".count"
278
+ return metric[0..metric.index(':')-1] + ".count"
277
279
  when 's'
278
- return "stats.sets." + metric[0..metric.index(':')-1] + ".count"
280
+ return metric[0..metric.index(':')-1] + ".count"
279
281
  when 'g'
280
- return "stats.gauges." + metric[0..metric.index(':')-1]
282
+ return metric[0..metric.index(':')-1]
281
283
  end
282
284
  end
283
285
 
@@ -290,6 +292,16 @@ module Echo_cli
290
292
  return true
291
293
  end
292
294
 
295
+ def do_post_udp(statsd_uri, port, request_body)
296
+ begin
297
+ udpsocket = UDPSocket.new
298
+ udpsocket.connect(statsd_uri, port)
299
+ udpsocket.write(request_body)
300
+ udpsocket.close
301
+ rescue Errno::ECONNREFUSED
302
+ end
303
+ end
304
+
293
305
  def do_post_tcp(statsd_uri, port, request_body)
294
306
  begin
295
307
  timeout(10) do
@@ -1,3 +1,3 @@
1
1
  module Echo_cli
2
- VERSION = "0.6.32"
2
+ VERSION = "0.6.33"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: echo_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.32
4
+ version: 0.6.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Raphael
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2017-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -96,7 +96,7 @@ dependencies:
96
96
  version: '5.0'
97
97
  description:
98
98
  email:
99
- - brandonraphael1@gmail.com
99
+ - braphael@email.arizona.edu
100
100
  executables:
101
101
  - console
102
102
  - echo_cli
@@ -121,6 +121,11 @@ files:
121
121
  - lib/echo_cli.rb
122
122
  - lib/echo_cli/cli.rb
123
123
  - lib/echo_cli/version.rb
124
+ - vendor/cache/colorize-0.8.1.gem
125
+ - vendor/cache/highline-1.7.8.gem
126
+ - vendor/cache/minitest-5.10.1.gem
127
+ - vendor/cache/rake-10.1.0.gem
128
+ - vendor/cache/thor-0.19.4.gem
124
129
  homepage: https://www.github.allstate.com
125
130
  licenses:
126
131
  - MIT