btw 0.1.1
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 +7 -0
- data/bin/btw +79 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e8b387830ff4d1925ae45d7fb089b133fe7b91dc
|
4
|
+
data.tar.gz: 09de9fe52023f22e1e90384330daf1ff75a5f95a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: af3a43e4d5baf0c765e9521edd7747915d888b60dc606fdcbb25ddc6fb5badf5968b82fa865f0330181e8dd0d3f8a65f64ecd04af71f899991d89100684f73b6
|
7
|
+
data.tar.gz: 9c783a883a005b0a10b68160a5fbf6161c8a28ba8d853b3c141c7da7882b578bc1c164a93d33ccfd747e3684203082fd5f0714d9ca78b6fce0ac44773f0ed87b
|
data/bin/btw
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
require 'chronic'
|
5
|
+
require 'pp'
|
6
|
+
require 'multi_json'
|
7
|
+
|
8
|
+
config = {
|
9
|
+
:debug => false,
|
10
|
+
:service => 'btw-change-control',
|
11
|
+
:host => 'localhost',
|
12
|
+
:port => '5600',
|
13
|
+
:user => 'nobody'
|
14
|
+
}
|
15
|
+
|
16
|
+
config_file = File.expand_path('~/.btw.conf')
|
17
|
+
if File.exist?(config_file)
|
18
|
+
config.merge!(MultiJson.load(File.read(config_file), :symbolize_names => true))
|
19
|
+
end
|
20
|
+
|
21
|
+
# The basics
|
22
|
+
input = ARGV.join(" ")
|
23
|
+
output = { "message" => "#{input}", "user" => config[:user], "service" => config[:service] }
|
24
|
+
|
25
|
+
# Key values
|
26
|
+
input.scan(/([a-zA-Z]+)\:([^\: ]+)/).each do |(k,v)|
|
27
|
+
output[k] = v
|
28
|
+
input.gsub!("#{k}:#{v}","")
|
29
|
+
end
|
30
|
+
|
31
|
+
# Time hacks
|
32
|
+
input.gsub!(/an hour/, 'one hour')
|
33
|
+
input.gsub!(/a minute/, 'one minute')
|
34
|
+
input.gsub!(/ on /, ' ')
|
35
|
+
input.gsub!(/test/, '')
|
36
|
+
|
37
|
+
timestamp = nil
|
38
|
+
if m = /\/(?<timestamp>.+)\//.match(input) and t = Chronic.parse(m[1])
|
39
|
+
timestamp = t
|
40
|
+
end
|
41
|
+
|
42
|
+
unless timestamp
|
43
|
+
words = input.split(" ")
|
44
|
+
i = 0
|
45
|
+
while i < words.size do
|
46
|
+
puts words[0..i].join(" ") if config[:debug]
|
47
|
+
t = Chronic.parse(words[0..i].join(" "), :endian_precedence => [:little, :middle])
|
48
|
+
puts "timestamp '#{timestamp}' found '#{t}'" if config[:debug]
|
49
|
+
if timestamp and t.nil?
|
50
|
+
break
|
51
|
+
elsif t
|
52
|
+
timestamp = t
|
53
|
+
end
|
54
|
+
i += 1
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
unless timestamp
|
59
|
+
timestamp = Time.now
|
60
|
+
end
|
61
|
+
|
62
|
+
output['timestamp'] = timestamp
|
63
|
+
|
64
|
+
print "Going to send the following data:\n\n"
|
65
|
+
pp output
|
66
|
+
print "\nSend this? [yes] "
|
67
|
+
answer = STDIN.gets.chomp
|
68
|
+
|
69
|
+
case answer.downcase
|
70
|
+
when 'yes','y', ''
|
71
|
+
sock = TCPSocket.new(config[:host], config[:port])
|
72
|
+
if sock.send(MultiJson.dump(output), 0)
|
73
|
+
puts 'Sent'
|
74
|
+
else
|
75
|
+
puts 'Could not send'
|
76
|
+
end
|
77
|
+
else
|
78
|
+
puts 'Not sent'
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: btw
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fraser Scott
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: chronic
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.10'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.10'
|
27
|
+
description: A quick and lightweight tool for creating searchable change control logs.
|
28
|
+
Writes to logstash using json over TCP
|
29
|
+
email: fraser.scott@gmail.com
|
30
|
+
executables:
|
31
|
+
- btw
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- bin/btw
|
36
|
+
homepage: https://github.com/zeroXten/btw
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.2.2
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Send change control messages to logstash (elasticsearch, kibana)
|
60
|
+
test_files: []
|
61
|
+
has_rdoc:
|