norikra-client-jruby 0.0.4.jruby1-java → 0.0.5-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/norikra/client/cli.rb +85 -53
- data/lib/norikra/client/version.rb +1 -1
- data/lib/norikra/client.rb +5 -0
- metadata +32 -43
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 383de04bc8eb474267a7bd76ba92a584fc5315a2
|
4
|
+
data.tar.gz: 01a37951189c7c91b27869d7f7162ee623af8e59
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c9dfd5e5fbde542a1ae4baf975727ed340aad2e3a1fd1a47968495aa5068515a9276050e07fa2a79f3e8b6b61a41b70a5cecbb9c9b216e5da706b3e0515a90f
|
7
|
+
data.tar.gz: 979531d399715d03a34616c4c409b95e90c809266dc9926bcc35fee67fcd7dbfd3708e6f93e2f0179412164338afd969f7112d329b4408bde33d6208eb05504e
|
data/lib/norikra/client/cli.rb
CHANGED
@@ -9,6 +9,16 @@ class Norikra::Client
|
|
9
9
|
def client(options)
|
10
10
|
Norikra::Client.new(options[:host], options[:port])
|
11
11
|
end
|
12
|
+
def wrap
|
13
|
+
begin
|
14
|
+
yield
|
15
|
+
rescue Norikra::RPC::ClientError => e
|
16
|
+
puts "Failed: " + e.message
|
17
|
+
rescue Norikra::RPC::ServerError => e
|
18
|
+
puts "ERROR on norikra server: " + e.message
|
19
|
+
puts " For more details, see norikra server's logs"
|
20
|
+
end
|
21
|
+
end
|
12
22
|
end
|
13
23
|
|
14
24
|
class Target < Thor
|
@@ -17,30 +27,36 @@ class Norikra::Client
|
|
17
27
|
desc "list", "show list of targets"
|
18
28
|
option :simple, :type => :boolean, :default => false, :desc => "suppress header/footer", :aliases => "-s"
|
19
29
|
def list
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
30
|
+
wrap do
|
31
|
+
puts "TARGET" unless options[:simple]
|
32
|
+
targets = client(parent_options).targets
|
33
|
+
targets.each do |t|
|
34
|
+
puts t
|
35
|
+
end
|
36
|
+
puts "#{targets.size} targets found." unless options[:simple]
|
24
37
|
end
|
25
|
-
puts "#{targets.size} targets found." unless options[:simple]
|
26
38
|
end
|
27
39
|
|
28
40
|
desc "open TARGET [fieldname1:type1 [fieldname2:type2 [fieldname3:type3] ...]]", "create new target (and define its fields)"
|
29
41
|
def open(target, *field_defs)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
42
|
+
wrap do
|
43
|
+
fields = nil
|
44
|
+
if field_defs.size > 0
|
45
|
+
fields = {}
|
46
|
+
field_defs.each do |str|
|
47
|
+
fname,ftype = str.split(':')
|
48
|
+
fields[fname] = ftype
|
49
|
+
end
|
36
50
|
end
|
51
|
+
client(parent_options).open(target, fields)
|
37
52
|
end
|
38
|
-
client(parent_options).open(target, fields)
|
39
53
|
end
|
40
54
|
|
41
55
|
desc "close TARGET", "close existing target and all its queries"
|
42
56
|
def close(target)
|
43
|
-
|
57
|
+
wrap do
|
58
|
+
client(parent_options).close(target)
|
59
|
+
end
|
44
60
|
end
|
45
61
|
end
|
46
62
|
|
@@ -50,22 +66,28 @@ class Norikra::Client
|
|
50
66
|
desc "list", "show list of queries"
|
51
67
|
option :simple, :type => :boolean, :default => false, :desc => "suppress header/footer", :aliases => "-s"
|
52
68
|
def list
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
69
|
+
wrap do
|
70
|
+
puts "QUERY_NAME\tTARGETS\tQUERY" unless options[:simple]
|
71
|
+
queries = client(parent_options).queries
|
72
|
+
queries.sort{|a,b| (a['targets'].first <=> b['targets'].first).nonzero? || a['name'] <=> b['name']}.each do |q|
|
73
|
+
puts "#{q['name']}\t#{q['targets'].join(',')}\t#{q['expression']}"
|
74
|
+
end
|
75
|
+
puts "#{queries.size} queries found." unless options[:simple]
|
57
76
|
end
|
58
|
-
puts "#{queries.size} queries found." unless options[:simple]
|
59
77
|
end
|
60
78
|
|
61
79
|
desc "add QUERY_NAME QUERY_EXPRESSION", "register a query"
|
62
80
|
def add(query_name, expression)
|
63
|
-
|
81
|
+
wrap do
|
82
|
+
client(parent_options).register(query_name, expression)
|
83
|
+
end
|
64
84
|
end
|
65
85
|
|
66
86
|
desc "remove QUERY_NAME", "deregister a query"
|
67
87
|
def remove(query_name)
|
68
|
-
|
88
|
+
wrap do
|
89
|
+
client(parent_options).deregister(query_name)
|
90
|
+
end
|
69
91
|
end
|
70
92
|
end
|
71
93
|
|
@@ -75,17 +97,21 @@ class Norikra::Client
|
|
75
97
|
desc "list TARGET", "show list of field definitions of specified target"
|
76
98
|
option :simple, :type => :boolean, :default => false, :desc => "suppress header/footer", :aliases => "-s"
|
77
99
|
def list(target)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
100
|
+
wrap do
|
101
|
+
puts "FIELD\tTYPE\tOPTIONAL" unless options[:simple]
|
102
|
+
fields = client(parent_options).fields(target)
|
103
|
+
fields.each do |f|
|
104
|
+
puts "#{f['name']}\t#{f['type']}\t#{f['optional']}"
|
105
|
+
end
|
106
|
+
puts "#{fields.size} fields found." unless options[:simple]
|
82
107
|
end
|
83
|
-
puts "#{fields.size} fields found." unless options[:simple]
|
84
108
|
end
|
85
109
|
|
86
110
|
desc "add TARGET FIELDNAME TYPE", "reserve fieldname and its type of target"
|
87
111
|
def add(target, field, type)
|
88
|
-
|
112
|
+
wrap do
|
113
|
+
client(parent_options).reserve(target, field, type)
|
114
|
+
end
|
89
115
|
end
|
90
116
|
end
|
91
117
|
|
@@ -96,17 +122,19 @@ class Norikra::Client
|
|
96
122
|
option :format, :type => :string, :default => 'json', :desc => "format of input data per line of stdin [json(default), ltsv]"
|
97
123
|
option :batch_size, :type => :numeric, :default => 10000, :desc => "records sent in once transferring (default: 10000)"
|
98
124
|
def send(target)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
125
|
+
wrap do
|
126
|
+
client = client(parent_options)
|
127
|
+
parser = parser(options[:format])
|
128
|
+
buffer = []
|
129
|
+
$stdin.each_line do |line|
|
130
|
+
buffer.push(parser.parse(line))
|
131
|
+
if buffer.size >= options[:batch_size]
|
132
|
+
client.send(target, buffer)
|
133
|
+
buffer = []
|
134
|
+
end
|
107
135
|
end
|
136
|
+
client.send(target, buffer) if buffer.size > 0
|
108
137
|
end
|
109
|
-
client.send(target, buffer) if buffer.size > 0
|
110
138
|
end
|
111
139
|
|
112
140
|
desc "fetch QUERY_NAME", "fetch events from specified query"
|
@@ -114,12 +142,14 @@ class Norikra::Client
|
|
114
142
|
option :time_key, :type => :string, :default => 'time', :desc => "output key name for event time (default: time)"
|
115
143
|
option :time_format, :type => :string, :default => '%Y/%m/%d %H:%M:%S', :desc => "output time format (default: '2013/05/14 17:57:59')"
|
116
144
|
def fetch(query_name)
|
117
|
-
|
118
|
-
|
145
|
+
wrap do
|
146
|
+
formatter = formatter(options[:format])
|
147
|
+
time_formatter = lambda{|t| Time.at(t).strftime(options[:time_format])}
|
119
148
|
|
120
|
-
|
121
|
-
|
122
|
-
|
149
|
+
client(parent_options).event(query_name).each do |time,event|
|
150
|
+
event = {options[:time_key] => Time.at(time).strftime(options[:time_format])}.merge(event)
|
151
|
+
puts formatter.format(event)
|
152
|
+
end
|
123
153
|
end
|
124
154
|
end
|
125
155
|
|
@@ -129,19 +159,21 @@ class Norikra::Client
|
|
129
159
|
option :time_key, :type => :string, :default => 'time', :desc => "output key name for event time (default: time)"
|
130
160
|
option :time_format, :type => :string, :default => '%Y/%m/%d %H:%M:%S', :desc => "output time format (default: '2013/05/14 17:57:59')"
|
131
161
|
def sweep
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
162
|
+
wrap do
|
163
|
+
formatter = formatter(options[:format])
|
164
|
+
time_formatter = lambda{|t| Time.at(t).strftime(options[:time_format])}
|
165
|
+
|
166
|
+
data = client(parent_options).sweep
|
167
|
+
|
168
|
+
data.keys.sort.each do |queryname|
|
169
|
+
events = data[queryname]
|
170
|
+
events.each do |time,event|
|
171
|
+
event = {
|
172
|
+
options[:time_key] => Time.at(time).strftime(options[:time_format]),
|
173
|
+
options[:query_name_key] => queryname,
|
174
|
+
}.merge(event)
|
175
|
+
puts formatter.format(event)
|
176
|
+
end
|
145
177
|
end
|
146
178
|
end
|
147
179
|
end
|
data/lib/norikra/client.rb
CHANGED
@@ -3,6 +3,11 @@ require "norikra/client/version"
|
|
3
3
|
require 'msgpack-rpc-over-http-jruby'
|
4
4
|
|
5
5
|
module Norikra
|
6
|
+
module RPC
|
7
|
+
class ClientError < MessagePack::RPCOverHTTP::RemoteError; end
|
8
|
+
class ServerError < MessagePack::RPCOverHTTP::RemoteError; end
|
9
|
+
end
|
10
|
+
|
6
11
|
class Client
|
7
12
|
RPC_DEFAULT_PORT = 26571
|
8
13
|
TIMEOUT_OPTIONS = [:connect_timeout, :send_timeout, :receive_timeout]
|
metadata
CHANGED
@@ -1,96 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: norikra-client-jruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.0.4.jruby1
|
4
|
+
version: 0.0.5
|
6
5
|
platform: java
|
7
6
|
authors:
|
8
7
|
- TAGOMORI Satoshi
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: msgpack-rpc-over-http-jruby
|
16
|
-
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
17
16
|
requirements:
|
18
17
|
- - '>='
|
19
18
|
- !ruby/object:Gem::Version
|
20
19
|
version: 0.0.4
|
21
|
-
|
22
|
-
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.0.4
|
27
|
-
none: false
|
28
|
-
prerelease: false
|
29
|
-
type: :runtime
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: thor
|
32
|
-
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
33
30
|
requirements:
|
34
31
|
- - '>='
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: '0'
|
37
|
-
|
38
|
-
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
37
|
requirements:
|
40
38
|
- - '>='
|
41
39
|
- !ruby/object:Gem::Version
|
42
40
|
version: '0'
|
43
|
-
none: false
|
44
|
-
prerelease: false
|
45
|
-
type: :runtime
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: ltsv
|
48
|
-
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
49
44
|
requirements:
|
50
45
|
- - '>='
|
51
46
|
- !ruby/object:Gem::Version
|
52
47
|
version: '0'
|
53
|
-
|
54
|
-
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
51
|
requirements:
|
56
52
|
- - '>='
|
57
53
|
- !ruby/object:Gem::Version
|
58
54
|
version: '0'
|
59
|
-
none: false
|
60
|
-
prerelease: false
|
61
|
-
type: :runtime
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: bundler
|
64
|
-
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
65
58
|
requirements:
|
66
59
|
- - ~>
|
67
60
|
- !ruby/object:Gem::Version
|
68
61
|
version: '1.3'
|
69
|
-
|
70
|
-
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
65
|
requirements:
|
72
66
|
- - ~>
|
73
67
|
- !ruby/object:Gem::Version
|
74
68
|
version: '1.3'
|
75
|
-
none: false
|
76
|
-
prerelease: false
|
77
|
-
type: :development
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rake
|
80
|
-
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
81
72
|
requirements:
|
82
73
|
- - '>='
|
83
74
|
- !ruby/object:Gem::Version
|
84
75
|
version: '0'
|
85
|
-
|
86
|
-
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
79
|
requirements:
|
88
80
|
- - '>='
|
89
81
|
- !ruby/object:Gem::Version
|
90
82
|
version: '0'
|
91
|
-
none: false
|
92
|
-
prerelease: false
|
93
|
-
type: :development
|
94
83
|
description: Client commands and libraries for Norikra
|
95
84
|
email:
|
96
85
|
- tagomoris@gmail.com
|
@@ -115,7 +104,8 @@ files:
|
|
115
104
|
homepage: https://github.com/tagomoris/norikra-client
|
116
105
|
licenses:
|
117
106
|
- APLv2
|
118
|
-
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
119
109
|
rdoc_options: []
|
120
110
|
require_paths:
|
121
111
|
- lib
|
@@ -124,17 +114,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
114
|
- - '>='
|
125
115
|
- !ruby/object:Gem::Version
|
126
116
|
version: '0'
|
127
|
-
none: false
|
128
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
118
|
requirements:
|
130
|
-
- - '
|
119
|
+
- - '>='
|
131
120
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
133
|
-
none: false
|
121
|
+
version: '0'
|
134
122
|
requirements: []
|
135
|
-
rubyforge_project:
|
136
|
-
rubygems_version:
|
137
|
-
signing_key:
|
138
|
-
specification_version:
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.0.2
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
139
127
|
summary: Client commands and libraries for Norikra
|
140
128
|
test_files: []
|
129
|
+
has_rdoc:
|