nosey 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nosey/eventmachine.rb +12 -6
- data/lib/nosey/munin.rb +1 -2
- data/lib/nosey/version.rb +1 -1
- data/spec/lib/eventmachine_spec.rb +3 -3
- metadata +20 -20
data/lib/nosey/eventmachine.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'eventmachine'
|
2
|
+
require 'strscan'
|
2
3
|
|
3
4
|
module EventMachine
|
4
5
|
module Nosey
|
5
6
|
class SocketServer < EventMachine::Connection
|
6
7
|
Host = '/tmp/nosey.socket'
|
7
8
|
Port = nil
|
9
|
+
CommandPattern = /[A-Z]+\n/
|
8
10
|
|
9
11
|
attr_accessor :report
|
10
12
|
|
@@ -15,21 +17,25 @@ module EventMachine
|
|
15
17
|
|
16
18
|
def receive_data(data)
|
17
19
|
buffer << data
|
18
|
-
#
|
19
|
-
|
20
|
+
# Look for commands in the buffer and process them
|
21
|
+
# TODO - For higher performance, queue this in a Em::Queue
|
22
|
+
while command = buffer.scan(CommandPattern)
|
23
|
+
process_command command
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
def process_command(command)
|
23
|
-
case command
|
28
|
+
case command.strip
|
24
29
|
when 'READ' # This is for more normal uses cases where you want to watch stats
|
25
30
|
send_data report.to_s
|
26
31
|
when 'RESET' # This is used primarly by munin, or other tools that can't track state.
|
27
32
|
send_data report.to_s
|
28
33
|
report.reset
|
34
|
+
when 'QUIT'
|
35
|
+
close_connection_after_writing
|
29
36
|
else
|
30
|
-
send_data "No Comprende.
|
37
|
+
send_data "No Comprende. READ, RESET, o QUIT."
|
31
38
|
end
|
32
|
-
close_connection_after_writing
|
33
39
|
end
|
34
40
|
|
35
41
|
# A nice short-cut for peeps who aren't familar with EM to fire up
|
@@ -40,7 +46,7 @@ module EventMachine
|
|
40
46
|
|
41
47
|
private
|
42
48
|
def buffer
|
43
|
-
@buffer ||= ""
|
49
|
+
@buffer ||= StringScanner.new("")
|
44
50
|
end
|
45
51
|
end
|
46
52
|
end
|
data/lib/nosey/munin.rb
CHANGED
@@ -122,7 +122,7 @@ module Nosey
|
|
122
122
|
# We use this command to read Nosey data from the socket, but more
|
123
123
|
# importantly, reset it so that when we come back around the next time
|
124
124
|
# we can grab all the data that's occured since that time.
|
125
|
-
ResetCommand = "RESET\n"
|
125
|
+
ResetCommand = "RESET\nQUIT\n"
|
126
126
|
|
127
127
|
# Default munin category. Zie app!
|
128
128
|
Category = 'App'
|
@@ -188,7 +188,6 @@ module Nosey
|
|
188
188
|
|
189
189
|
# Read the report YAML data from the socket
|
190
190
|
def read_socket
|
191
|
-
p ResetCommand
|
192
191
|
socket = UNIXSocket.new(@host)
|
193
192
|
socket.puts(ResetCommand)
|
194
193
|
socket.gets("\n\n")
|
data/lib/nosey/version.rb
CHANGED
@@ -23,7 +23,7 @@ describe EventMachine::Nosey::SocketServer do
|
|
23
23
|
socket.callback{|data|
|
24
24
|
@resp = data
|
25
25
|
}
|
26
|
-
socket.send_data("READ\n")
|
26
|
+
socket.send_data("READ\nQUIT\n")
|
27
27
|
|
28
28
|
ly{2}.test{|count| YAML.load(@resp)['Group 0']['hit'] == count }
|
29
29
|
end
|
@@ -36,10 +36,10 @@ describe EventMachine::Nosey::SocketServer do
|
|
36
36
|
s1 = Nosey::Test::ReadSocket.start('/tmp/nosey.socket')
|
37
37
|
s2 = Nosey::Test::ReadSocket.start('/tmp/nosey.socket')
|
38
38
|
|
39
|
-
s1.send_data("RESET\n")
|
39
|
+
s1.send_data("RESET\nQUIT\n")
|
40
40
|
s1.callback{|data|
|
41
41
|
@r1 = data
|
42
|
-
s2.send_data("READ\n")
|
42
|
+
s2.send_data("READ\nQUIT\n")
|
43
43
|
s2.callback{|data|
|
44
44
|
@r2 = data
|
45
45
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nosey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
16
|
-
requirement: &
|
16
|
+
requirement: &70198108041380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70198108041380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thor
|
27
|
-
requirement: &
|
27
|
+
requirement: &70198108040880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70198108040880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70198108040120 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70198108040120
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: guard-rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70198108039680 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70198108039680
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard-bundler
|
60
|
-
requirement: &
|
60
|
+
requirement: &70198108039160 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70198108039160
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: growl
|
71
|
-
requirement: &
|
71
|
+
requirement: &70198108038680 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70198108038680
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rb-fsevent
|
82
|
-
requirement: &
|
82
|
+
requirement: &70198108038200 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70198108038200
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: em-ventually
|
93
|
-
requirement: &
|
93
|
+
requirement: &70198108037700 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70198108037700
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: ruby-debug19
|
104
|
-
requirement: &
|
104
|
+
requirement: &70198108037280 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70198108037280
|
113
113
|
description: Nosey is a way to instrument your Evented Ruby applications to track
|
114
114
|
counts, aggregates, etc. It was built a Poll Everywhere because we need a way to
|
115
115
|
peer into our Evented apps and grab some basic statistics so that we could graph
|