slurry 0.0.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.
- data/README.md +21 -0
- data/bin/clean +10 -0
- data/bin/liaise +11 -0
- data/bin/report +10 -0
- data/bin/slurry +11 -0
- data/etc/slurry.yaml.sample +3 -0
- data/lib/slurry.rb +69 -0
- metadata +52 -0
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Slurry
|
2
|
+
A tool for controlling the flow of data to graphite.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
|
6
|
+
### Getting data into slurry
|
7
|
+
|
8
|
+
while true; do
|
9
|
+
/path/to/my/script | /path/to/bin/slurry;
|
10
|
+
sleep 60;
|
11
|
+
done
|
12
|
+
|
13
|
+
|
14
|
+
### Getting data out of slurry and into graphite
|
15
|
+
|
16
|
+
./bin/liaise
|
17
|
+
|
18
|
+
### Inspecting the state
|
19
|
+
|
20
|
+
./bin/report
|
21
|
+
|
data/bin/clean
ADDED
data/bin/liaise
ADDED
data/bin/report
ADDED
data/bin/slurry
ADDED
data/lib/slurry.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'json'
|
2
|
+
require "redis"
|
3
|
+
require 'json2graphite'
|
4
|
+
#require 'graphite-util'
|
5
|
+
|
6
|
+
module Slurry
|
7
|
+
module_function
|
8
|
+
|
9
|
+
# Pull in new data from STDIN
|
10
|
+
def funnel
|
11
|
+
data = Hash.new
|
12
|
+
|
13
|
+
body = ''
|
14
|
+
body += STDIN.read
|
15
|
+
data[:hash] = JSON.parse(body)
|
16
|
+
data[:time] = Time.now.to_i
|
17
|
+
pipe(data)
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
# Push that data to redis
|
22
|
+
def pipe (hash)
|
23
|
+
redis = Redis.new
|
24
|
+
redis.lpush('slurry',hash.to_json)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Report the contents of the redis server
|
28
|
+
def report
|
29
|
+
r = Redis.new
|
30
|
+
|
31
|
+
data = Hash.new
|
32
|
+
data[:slurry] = Hash.new
|
33
|
+
data[:slurry][:waiting] = r.llen('slurry')
|
34
|
+
|
35
|
+
puts data.to_json
|
36
|
+
end
|
37
|
+
|
38
|
+
# Dump clean out everything from redis
|
39
|
+
def clean
|
40
|
+
r = Redis.new
|
41
|
+
|
42
|
+
while r.llen('slurry') > 0 do
|
43
|
+
r.rpop('slurry')
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
def liaise (server,port,wait=0.1)
|
49
|
+
r = Redis.new
|
50
|
+
|
51
|
+
loop do
|
52
|
+
|
53
|
+
# Pull something off the list
|
54
|
+
popped = r.brpop('slurry')
|
55
|
+
data = JSON.parse(popped[1])
|
56
|
+
|
57
|
+
# Convert the json into graphite useable data
|
58
|
+
processed = Json2Graphite.get_graphite(data["hash"], data["time"])
|
59
|
+
s = TCPSocket.open(server, port)
|
60
|
+
processed.each do |line|
|
61
|
+
s.puts(line)
|
62
|
+
end
|
63
|
+
s.close
|
64
|
+
sleep wait
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slurry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Zach Leslie
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Parses json from the various node states on puppet dashboard and returns
|
15
|
+
those values in a json blob
|
16
|
+
email: xaque208@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/clean
|
22
|
+
- bin/liaise
|
23
|
+
- bin/report
|
24
|
+
- bin/slurry
|
25
|
+
- lib/slurry.rb
|
26
|
+
- etc/slurry.yaml.sample
|
27
|
+
- README.md
|
28
|
+
homepage: https://github.com/xaque208/slurry
|
29
|
+
licenses: []
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 1.8.24
|
49
|
+
signing_key:
|
50
|
+
specification_version: 3
|
51
|
+
summary: A tool to get the highlights from the Puppet Dashboard
|
52
|
+
test_files: []
|