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 +1 -0
- data/Manifest +2 -2
- data/etc/{scribe_munin_plugin.rb → scribe_munin.rb} +2 -2
- data/etc/scribe_net +1 -0
- data/lib/ruby_scribe_client/fb303_client.rb +59 -55
- data/lib/ruby_scribe_client/scribe.rb +2 -1
- data/ruby_scribe_client.gemspec +2 -2
- metadata +4 -3
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
etc/scribe_cat.rb
|
3
|
-
etc/
|
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(
|
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 =
|
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
|
-
|
2
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
COMMAND_MAP = { :reload => 'reinitialize',
|
9
|
+
:stop => 'shutdown',
|
10
|
+
:version => 'getVersion',
|
11
|
+
:name => 'getName',
|
12
|
+
:alive => 'aliveSince'
|
13
|
+
}
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
62
|
-
|
63
|
-
|
64
|
+
def get_counters
|
65
|
+
self.getCounters
|
66
|
+
end
|
64
67
|
|
65
|
-
|
66
|
-
|
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
|
data/ruby_scribe_client.gemspec
CHANGED
@@ -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
|
+
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/
|
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.
|
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/
|
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:
|