beanstalkd-stats 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/beanstalkd-stats +34 -27
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4252c3779ac2cfe56f7ab1e2f7c136c567c4303c
4
- data.tar.gz: 79e87d48972aa2aefd947855c5ff074a42f1d0dc
3
+ metadata.gz: dc6f59fdfaf88893e4f77ba1ae253733808656c2
4
+ data.tar.gz: db2032441dcdd942caa22bad14dca1b117694267
5
5
  SHA512:
6
- metadata.gz: 1cf63bfcbeb6479693af1e8be48cdc5af8a8079492ea02e7359b6b9c0b71fa3624f419e70d4652060ebdfb088cae93d5a7e71a3a6de2207c41dd735513d75a5c
7
- data.tar.gz: 43387e5c169611f74254c5441bacce8730c4049df96fe509d59a43ba522fcbfffd0ad4a930b4d18d3a4950ea0c55625c0ab81c9321f2c85ad0e9d7bfba479078
6
+ metadata.gz: ffa25a9fe1bacba8cdce030db5fe3ad4fe95291b27c89aac16a5190a3bf8d6623415e809c3e8edbad2fdb5409b7fc1a89b87873875eb8b80a86e30e7514d6899
7
+ data.tar.gz: b639e3a42717086b1acef12e1cac672a7545797c6622519f53a11245753bb2cd34aa3cce601fadbbd8d609f916a9cb7f4379bad4ac106867a6faddefec4f79e0
data/bin/beanstalkd-stats CHANGED
@@ -9,9 +9,14 @@ require 'rufus-scheduler'
9
9
  require 'json'
10
10
  require 'optparse'
11
11
  require 'stat'
12
+ require 'dante'
12
13
 
13
- options = {}
14
- optparse = OptionParser.new do |opts|
14
+ runner = Dante::Runner.new('beanstalkd-stats')
15
+ runner.description = "beanstalkd-stats -c config_file [-d] [-h host] [-p port] [-i interval]"
16
+
17
+ runner.with_options do |opts|
18
+ # options = {}
19
+ #optparse = OptionParser.new do |opts|
15
20
  # todo: syntax
16
21
  opts.on("-i", "--interval INTERVAL", "interval to query beanstalkd") do |interval|
17
22
  options['interval'] = interval
@@ -32,16 +37,16 @@ optparse = OptionParser.new do |opts|
32
37
  end
33
38
 
34
39
  # Parsing arguments
35
- begin
36
- optparse.parse!
40
+ # begin
41
+ # optparse.parse!
37
42
 
38
- mandatory = []
39
- missing = mandatory.select{}
40
- rescue OptionParser::InvalidOption, OptionParser::MissingArgument
41
- puts $!.to_s
42
- puts optparse
43
- exit 1
44
- end
43
+ # mandatory = []
44
+ # missing = mandatory.select{}
45
+ # rescue OptionParser::InvalidOption, OptionParser::MissingArgument
46
+ # puts $!.to_s
47
+ # puts optparse
48
+ # exit 1
49
+ # end
45
50
 
46
51
  # StackDriver wants an instance_id
47
52
  def instance_id
@@ -52,22 +57,24 @@ rescue
52
57
  end
53
58
 
54
59
  # begin
55
- server = "#{options['host']}:#{options['port']}"
56
- StackDriver.init options['stackdriver_api_key']
57
- scheduler = Rufus::Scheduler.new
58
- scheduler.every options['interval'] do
59
- stats = []
60
- connection = Beanstalk::Connection.new(server)
61
- beanstalkd_stats = connection.stats
60
+ runner.execute do |options|
61
+ server = "#{options['host']}:#{options['port']}"
62
+ StackDriver.init options['stackdriver_api_key']
63
+ scheduler = Rufus::Scheduler.new
64
+ scheduler.every options['interval'] do
65
+ stats = []
66
+ connection = Beanstalk::Connection.new(server)
67
+ beanstalkd_stats = connection.stats
62
68
 
63
- options['stats'].each do |m|
64
- stat = Stat.new instance_id, m
65
- stat.value = beanstalkd_stats[m] || 0
66
- stats << stat.to_hash
67
- end
69
+ options['stats'].each do |m|
70
+ stat = Stat.new instance_id, m
71
+ stat.value = beanstalkd_stats[m] || 0
72
+ stats << stat.to_hash
73
+ end
68
74
 
69
- puts stats.to_json if options['debug']
70
- StackDriver.send_multi_metrics stats
71
- end
75
+ puts stats.to_json if options['debug']
76
+ StackDriver.send_multi_metrics stats
77
+ end
72
78
 
73
- scheduler.join
79
+ scheduler.join
80
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beanstalkd-stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jorge Moratilla
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dante
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.2'
69
83
  description: A simple beanstalkd gem
70
84
  email: jorge@moratilla.com
71
85
  executables:
@@ -76,7 +90,7 @@ files:
76
90
  - bin/beanstalkd-stats
77
91
  - lib/stackdriver.rb
78
92
  - lib/stat.rb
79
- homepage: http://rubygems.org/gems/beanstalkd-stats
93
+ homepage: https://bitbucket.org/jmoratilla/beanstalkd-stats
80
94
  licenses:
81
95
  - MIT
82
96
  metadata: {}