garru-ruby_scribe_client 0.0.5 → 0.0.6

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
+ v0.0.6 fb303: added host option. moved client to module namespace
1
2
  v0.0.5 wrote fb303 client for scribe mgmt
2
3
  v0.0.4 removing flush because framed transport doesn't need it
3
4
  v0.0.3 flush instead of open/close each time
data/Manifest CHANGED
@@ -1,6 +1,7 @@
1
1
  CHANGELOG
2
2
  etc/scribe_cat.rb
3
- etc/scribe_munin_plugin.rb
3
+ etc/scribe_munin.rb
4
+ etc/scribe_net
4
5
  etc/test.rb
5
6
  lib/ruby_scribe_client/FacebookService.rb
6
7
  lib/ruby_scribe_client/fb303_client.rb
@@ -14,7 +15,6 @@ LICENSE
14
15
  Manifest
15
16
  Rakefile
16
17
  README
17
- ruby_scribe_client.gemspec
18
18
  vendor/thrift/client.rb
19
19
  vendor/thrift/deprecation.rb
20
20
  vendor/thrift/exceptions.rb
@@ -10,7 +10,7 @@ class ScribeStats
10
10
  CATEGORY = 'scribe'
11
11
 
12
12
  def initialize(host, port)
13
- @scribe = FB303.new("#{host}:#{port}")
13
+ @scribe = FB303.new(host, port)
14
14
  @category = 'scribe'
15
15
  end
16
16
 
@@ -74,7 +74,7 @@ else
74
74
  $stderr.puts "can't find chart name"
75
75
  end
76
76
 
77
- starling = StarlingStats.new(HOST, PORT)
77
+ starling = ScribeStats.new(HOST, PORT)
78
78
 
79
79
  command = "#{chart_name}_munin"
80
80
 
data/etc/scribe_net ADDED
@@ -0,0 +1 @@
1
+ scribe_munin.rb
@@ -1,68 +1,72 @@
1
- class FB303
2
- attr_accessor :client
1
+ require File.join([File.dirname(__FILE__), '..', '..', 'vendor','thrift'])
2
+ require File.join([File.dirname(__FILE__) ,'FacebookService'])
3
+ require File.join([File.dirname(__FILE__), 'scribe_types'])
4
+ module FB303
5
+ class Client
6
+ attr_accessor :client
3
7
 
4
- COMMAND_MAP = { :reload => 'reinitialize',
5
- :stop => 'shutdown',
6
- :version => 'getVersion',
7
- :name => 'getName',
8
- :alive => 'aliveSince'
9
- }
8
+ COMMAND_MAP = { :reload => 'reinitialize',
9
+ :stop => 'shutdown',
10
+ :version => 'getVersion',
11
+ :name => 'getName',
12
+ :alive => 'aliveSince'
13
+ }
10
14
 
11
- STATUS = {
12
- Fb_status::DEAD => "DEAD",
13
- Fb_status::STARTING => "STARTING",
14
- Fb_status::ALIVE => "ALIVE",
15
- Fb_status::STOPPING => "STOPPING",
16
- Fb_status::STOPPED => "STOPPED",
17
- Fb_status::WARNING => "WARNING"
18
- }
15
+ STATUS = {
16
+ Fb_status::DEAD => "DEAD",
17
+ Fb_status::STARTING => "STARTING",
18
+ Fb_status::ALIVE => "ALIVE",
19
+ Fb_status::STOPPING => "STOPPING",
20
+ Fb_status::STOPPED => "STOPPED",
21
+ Fb_status::WARNING => "WARNING"
22
+ }
19
23
 
20
- def initialize(port)
21
- @transport = Thrift::FramedTransport.new(Thrift::Socket.new('metrics.seriousops.com', port))
22
- @protocol = Thrift::BinaryProtocol.new(@transport, false, false)
23
- @client = FacebookService::Client.new(@protocol)
24
- end
24
+ def initialize(host, port)
25
+ @transport = Thrift::FramedTransport.new(Thrift::Socket.new(host, port))
26
+ @protocol = Thrift::BinaryProtocol.new(@transport, false, false)
27
+ @client = FacebookService::Client.new(@protocol)
28
+ end
25
29
 
26
- def method_missing(method)
27
- if COMMAND_MAP.has_key?(method)
28
- if [:version, :alive, :name].include?(method)
29
- result = self.send(COMMAND_MAP[method])
30
- puts result
31
- elsif [:stop, :reload].include?(method)
32
- result = self.send(COMMAND_MAP[method])
33
- puts result
30
+ def method_missing(method)
31
+ if COMMAND_MAP.has_key?(method)
32
+ if [:version, :alive, :name].include?(method)
33
+ result = self.send(COMMAND_MAP[method])
34
+ puts result
35
+ elsif [:stop, :reload].include?(method)
36
+ result = self.send(COMMAND_MAP[method])
37
+ puts result
38
+ end
39
+ elsif @client.respond_to?(method)
40
+ @transport.open
41
+ return @client.send(method)
42
+ @transport.close
43
+ else
44
+ raise NoMethodError.new;
34
45
  end
35
- elsif @client.respond_to?(method)
36
- @transport.open
37
- return @client.send(method)
38
- @transport.close
39
- else
40
- require 'ruby-debug'; debugger
41
- raise NoMethodError.new;
42
46
  end
43
- end
44
47
 
45
- def status
46
- status = self.getStatus
47
- status_details = self.getStatusDetails || ""
48
- msg = fb_status_string(status)
49
- msg += " - %s" % status_details if status_details.size > 0
50
- puts msg
51
- return (status == Fb_status::ALIVE) ? 2 : 3
52
- end
48
+ def status
49
+ status = self.getStatus
50
+ status_details = self.getStatusDetails || ""
51
+ msg = fb_status_string(status)
52
+ msg += " - %s" % status_details if status_details.size > 0
53
+ puts msg
54
+ return (status == Fb_status::ALIVE) ? 2 : 3
55
+ end
53
56
 
54
- def counters
55
- # require 'ruby-debug'; debugger
56
- self.getCounters.each_pair do |key, value|
57
- puts "%s: %d" % [key, value]
57
+ def counters
58
+ # require 'ruby-debug'; debugger
59
+ self.getCounters.each_pair do |key, value|
60
+ puts "%s: %d" % [key, value]
61
+ end
58
62
  end
59
- end
60
63
 
61
- def get_counters
62
- self.getCounters
63
- end
64
+ def get_counters
65
+ self.getCounters
66
+ end
64
67
 
65
- def fb_status_string(status_code)
66
- STATUS[status_code]
68
+ def fb_status_string(status_code)
69
+ STATUS[status_code]
70
+ end
67
71
  end
68
72
  end
@@ -7,7 +7,8 @@
7
7
  require File.join([File.dirname(__FILE__), '..', '..', 'vendor','thrift'])
8
8
  require File.join([File.dirname(__FILE__) ,'FacebookService'])
9
9
  require File.join([File.dirname(__FILE__), 'scribe_types'])
10
- require File.join([File.dirname(__FILE__), 'fb303_client'])
10
+ require File.join([File.dirname(__FILE__), 'ruby_scribe_client', 'fb303_client'])
11
+
11
12
  module Scribe
12
13
  class Client < FacebookService::Client
13
14
  include ::Thrift::Client
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ruby_scribe_client}
5
- s.version = "0.0.5"
5
+ s.version = "0.0.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Gary Tsang"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = %q{Ruby Scribe Client. Package and Wrapper for generated ruby interfaces}
11
11
  s.email = %q{}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "lib/ruby_scribe_client/FacebookService.rb", "lib/ruby_scribe_client/fb303_client.rb", "lib/ruby_scribe_client/fb303_types.rb", "lib/ruby_scribe_client/reflection_limited_types.rb", "lib/ruby_scribe_client/scribe.rb", "lib/ruby_scribe_client/scribe_mgmt.rb", "lib/ruby_scribe_client/scribe_types.rb", "lib/ruby_scribe_client.rb", "LICENSE", "README"]
13
- s.files = ["CHANGELOG", "etc/scribe_cat.rb", "etc/scribe_munin_plugin.rb", "etc/test.rb", "lib/ruby_scribe_client/FacebookService.rb", "lib/ruby_scribe_client/fb303_client.rb", "lib/ruby_scribe_client/fb303_types.rb", "lib/ruby_scribe_client/reflection_limited_types.rb", "lib/ruby_scribe_client/scribe.rb", "lib/ruby_scribe_client/scribe_mgmt.rb", "lib/ruby_scribe_client/scribe_types.rb", "lib/ruby_scribe_client.rb", "LICENSE", "Manifest", "Rakefile", "README", "ruby_scribe_client.gemspec", "vendor/thrift/client.rb", "vendor/thrift/deprecation.rb", "vendor/thrift/exceptions.rb", "vendor/thrift/processor.rb", "vendor/thrift/protocol/binaryprotocol.rb", "vendor/thrift/protocol/binaryprotocolaccelerated.rb", "vendor/thrift/protocol/tbinaryprotocol.rb", "vendor/thrift/protocol/tprotocol.rb", "vendor/thrift/protocol.rb", "vendor/thrift/serializer.rb", "vendor/thrift/server/httpserver.rb", "vendor/thrift/server/nonblockingserver.rb", "vendor/thrift/server/thttpserver.rb", "vendor/thrift/server/tserver.rb", "vendor/thrift/server.rb", "vendor/thrift/struct.rb", "vendor/thrift/thrift.rb", "vendor/thrift/transport/httpclient.rb", "vendor/thrift/transport/socket.rb", "vendor/thrift/transport/thttpclient.rb", "vendor/thrift/transport/tsocket.rb", "vendor/thrift/transport/ttransport.rb", "vendor/thrift/transport/unixsocket.rb", "vendor/thrift/transport.rb", "vendor/thrift/types.rb", "vendor/thrift.rb"]
13
+ s.files = ["CHANGELOG", "etc/scribe_cat.rb", "etc/scribe_munin.rb", "etc/scribe_net", "etc/test.rb", "lib/ruby_scribe_client/FacebookService.rb", "lib/ruby_scribe_client/fb303_client.rb", "lib/ruby_scribe_client/fb303_types.rb", "lib/ruby_scribe_client/reflection_limited_types.rb", "lib/ruby_scribe_client/scribe.rb", "lib/ruby_scribe_client/scribe_mgmt.rb", "lib/ruby_scribe_client/scribe_types.rb", "lib/ruby_scribe_client.rb", "LICENSE", "Manifest", "Rakefile", "README", "vendor/thrift/client.rb", "vendor/thrift/deprecation.rb", "vendor/thrift/exceptions.rb", "vendor/thrift/processor.rb", "vendor/thrift/protocol/binaryprotocol.rb", "vendor/thrift/protocol/binaryprotocolaccelerated.rb", "vendor/thrift/protocol/tbinaryprotocol.rb", "vendor/thrift/protocol/tprotocol.rb", "vendor/thrift/protocol.rb", "vendor/thrift/serializer.rb", "vendor/thrift/server/httpserver.rb", "vendor/thrift/server/nonblockingserver.rb", "vendor/thrift/server/thttpserver.rb", "vendor/thrift/server/tserver.rb", "vendor/thrift/server.rb", "vendor/thrift/struct.rb", "vendor/thrift/thrift.rb", "vendor/thrift/transport/httpclient.rb", "vendor/thrift/transport/socket.rb", "vendor/thrift/transport/thttpclient.rb", "vendor/thrift/transport/tsocket.rb", "vendor/thrift/transport/ttransport.rb", "vendor/thrift/transport/unixsocket.rb", "vendor/thrift/transport.rb", "vendor/thrift/types.rb", "vendor/thrift.rb", "ruby_scribe_client.gemspec"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://github.com/garru/ruby_scribe_client}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ruby_scribe_client", "--main", "README"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garru-ruby_scribe_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Tsang
@@ -34,7 +34,8 @@ extra_rdoc_files:
34
34
  files:
35
35
  - CHANGELOG
36
36
  - etc/scribe_cat.rb
37
- - etc/scribe_munin_plugin.rb
37
+ - etc/scribe_munin.rb
38
+ - etc/scribe_net
38
39
  - etc/test.rb
39
40
  - lib/ruby_scribe_client/FacebookService.rb
40
41
  - lib/ruby_scribe_client/fb303_client.rb
@@ -48,7 +49,6 @@ files:
48
49
  - Manifest
49
50
  - Rakefile
50
51
  - README
51
- - ruby_scribe_client.gemspec
52
52
  - vendor/thrift/client.rb
53
53
  - vendor/thrift/deprecation.rb
54
54
  - vendor/thrift/exceptions.rb
@@ -75,6 +75,7 @@ files:
75
75
  - vendor/thrift/transport.rb
76
76
  - vendor/thrift/types.rb
77
77
  - vendor/thrift.rb
78
+ - ruby_scribe_client.gemspec
78
79
  has_rdoc: true
79
80
  homepage: http://github.com/garru/ruby_scribe_client
80
81
  post_install_message: