hutils 0.2.3 → 0.3.0
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.
- checksums.yaml +4 -4
- data/bin/ltap +21 -11
- data/lib/hutils/ltap.rb +1 -0
- data/lib/hutils/ltap/conf.rb +15 -10
- data/lib/hutils/ltap/lvat_drainer.rb +28 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae97daa9f753f4d2ca5e40dac56ae46403d49f13
|
4
|
+
data.tar.gz: ede5236d2a555615a6e4cf90f5386074f403326a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eda70d9d6e3defea2d158964a9a9c78014d0afadbd19b22d928e40089bc4623ac2cb710b561b112d094abca8cc18264eea0c9e6c9d441050d0a4dd9071c185bd
|
7
|
+
data.tar.gz: 09ef57610dd6dd8edf8ed516f96a5bbc4da8adbda33c2ce6903746d7e4846039df1ee0b8227ed9044994f7265647568ccf5b5b674718d9a85db6a2f4030487d8
|
data/bin/ltap
CHANGED
@@ -30,8 +30,12 @@ end
|
|
30
30
|
opts.parse!
|
31
31
|
|
32
32
|
# load a profile from ~/.ltap if one was specified
|
33
|
-
|
34
|
-
conf.
|
33
|
+
begin
|
34
|
+
if conf.profile
|
35
|
+
conf.load_section(conf.profile)
|
36
|
+
end
|
37
|
+
rescue Hutils::Ltap::Conf::SectionNotFound
|
38
|
+
abort("No such section: #{conf.profile}")
|
35
39
|
end
|
36
40
|
|
37
41
|
unless conf.type
|
@@ -50,6 +54,8 @@ if !(earliest = parser.parse(conf.earliest, from: Time.now.getutc))
|
|
50
54
|
end
|
51
55
|
|
52
56
|
drainer = case conf.type
|
57
|
+
when "lvat"
|
58
|
+
Hutils::Ltap::LvatDrainer
|
53
59
|
when "papertrail"
|
54
60
|
Hutils::Ltap::PaperTrailDrainer
|
55
61
|
when "splunk"
|
@@ -58,15 +64,19 @@ else
|
|
58
64
|
abort("Unknown type: #{conf.type}")
|
59
65
|
end
|
60
66
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
begin
|
68
|
+
drainer = drainer.new(
|
69
|
+
earliest: earliest,
|
70
|
+
key: conf.key,
|
71
|
+
query: ARGV.first,
|
72
|
+
timeout: conf.timeout,
|
73
|
+
timestamps: conf.timestamps,
|
74
|
+
url: conf.url,
|
75
|
+
verbose: conf.verbose
|
76
|
+
)
|
77
|
+
rescue ArgumentError
|
78
|
+
abort($!.message)
|
79
|
+
end
|
70
80
|
|
71
81
|
thread = Thread.start do
|
72
82
|
$stdout.puts drainer.run
|
data/lib/hutils/ltap.rb
CHANGED
data/lib/hutils/ltap/conf.rb
CHANGED
@@ -24,16 +24,21 @@ module Hutils::Ltap
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def load_section(name)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
return unless @ini
|
28
|
+
raise SectionNotFound unless @ini.has_section?(name)
|
29
|
+
|
30
|
+
section = @ini[name]
|
31
|
+
load_value(section, :earliest)
|
32
|
+
load_value(section, :key)
|
33
|
+
load_value(section, :profile)
|
34
|
+
load_value(section, :timeout)
|
35
|
+
load_value(section, :timestamps)
|
36
|
+
load_value(section, :type)
|
37
|
+
load_value(section, :url)
|
38
|
+
load_value(section, :verbose)
|
39
|
+
end
|
40
|
+
|
41
|
+
class SectionNotFound < StandardError
|
37
42
|
end
|
38
43
|
|
39
44
|
private
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
module Hutils::Ltap
|
4
|
+
class LvatDrainer
|
5
|
+
def initialize(earliest:, key:, timeout:, query:, timestamps:, url:, verbose:)
|
6
|
+
@query = query
|
7
|
+
|
8
|
+
if timestamps
|
9
|
+
raise ArgumentError, "lvat does not supported `timestamps` option"
|
10
|
+
end
|
11
|
+
|
12
|
+
@api = Excon.new(url, read_timeout: timeout)
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
resp = @api.get(
|
17
|
+
path: "/messages",
|
18
|
+
expects: [200, 404],
|
19
|
+
query: {
|
20
|
+
query: @query
|
21
|
+
})
|
22
|
+
|
23
|
+
return [] if resp.status == 404
|
24
|
+
|
25
|
+
JSON.parse(resp.body)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- "./lib/hutils/curses_visualizer.rb"
|
85
85
|
- "./lib/hutils/ltap.rb"
|
86
86
|
- "./lib/hutils/ltap/conf.rb"
|
87
|
+
- "./lib/hutils/ltap/lvat_drainer.rb"
|
87
88
|
- "./lib/hutils/ltap/paper_trail_drainer.rb"
|
88
89
|
- "./lib/hutils/ltap/splunk_drainer.rb"
|
89
90
|
- "./lib/hutils/ltap/time_bound_parser.rb"
|