stepper-instrument 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/bin/step +56 -0
- data/bin/stepup +56 -0
- data/lib/stepper-instrument.rb +51 -0
- metadata +83 -0
data/bin/step
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'stepper-instrument'
|
6
|
+
|
7
|
+
options = {
|
8
|
+
:si => "step.0",
|
9
|
+
:ms => 1,
|
10
|
+
:host => "localhost:8082",
|
11
|
+
:file => nil
|
12
|
+
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
parser = OptionParser.new do |op|
|
17
|
+
op.separator "== Step == "
|
18
|
+
op.banner = "Usage: Stepper [options]"
|
19
|
+
op.separator ""
|
20
|
+
op.separator "Register Step => Step을 등록합니다. "
|
21
|
+
|
22
|
+
op.on("-s", "--step-id COLLECTIONSNAME.STEP_ID", "DETERMINE COLLECTION NAME AND STEP ID") do |si|
|
23
|
+
options[:si] = si
|
24
|
+
end
|
25
|
+
|
26
|
+
op.on("-m", "--max-step MAX_STEP", "DETERMINE MAX STEP") do |ms|
|
27
|
+
options[:ms] = ms
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
op.on("-H", "--host HOST", "HOST eg)localhost:8082") do |host|
|
32
|
+
options[:host] = host
|
33
|
+
end
|
34
|
+
|
35
|
+
op.on("-f", "--file PATH", "File path to store actions. The host will be ignored. eg)~/log/stepper.log") do |file|
|
36
|
+
options[:file] = file
|
37
|
+
end
|
38
|
+
|
39
|
+
op.on("-h", "--help", "I WANT MOAR HALP") do
|
40
|
+
puts op
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
parser.parse!
|
47
|
+
|
48
|
+
if options[:file]
|
49
|
+
File.open(options[:file], "a") do |f|
|
50
|
+
f.puts("#{options[:si]}:#{options[:ms]}|s")
|
51
|
+
f.close
|
52
|
+
end
|
53
|
+
else
|
54
|
+
Stepper.daemon_hostport = options[:host]
|
55
|
+
Stepper.step(options[:si],options[:ms])
|
56
|
+
end
|
data/bin/stepup
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'stepper-instrument'
|
6
|
+
|
7
|
+
options = {
|
8
|
+
:si => "step",
|
9
|
+
:cs => 1,
|
10
|
+
:host => "localhost:8082",
|
11
|
+
:file => nil
|
12
|
+
|
13
|
+
}
|
14
|
+
|
15
|
+
parser = OptionParser.new do |op|
|
16
|
+
op.separator "== Stepup == "
|
17
|
+
op.banner = "Usage: Steppup [options]"
|
18
|
+
op.separator ""
|
19
|
+
op.separator "Step up => 이미 등록한 Step을 올립니다."
|
20
|
+
|
21
|
+
op.on("-s", "--step-id STEP_ID", "DETERMINE STEP ID") do |si|
|
22
|
+
options[:si] = si
|
23
|
+
end
|
24
|
+
|
25
|
+
op.on("-u", "--step-up STEP_UP", "HOW MANY STEPS ARE YOU CLIMB?") do |cs|
|
26
|
+
options[:cs] = cs
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
op.on("-H", "--host HOST", "HOST eg)localhost:8082") do |host|
|
31
|
+
options[:host] = host
|
32
|
+
end
|
33
|
+
|
34
|
+
op.on("-f", "--file PATH", "File path to store actions. The host will be ignored. eg)~/log/stepper.log") do |file|
|
35
|
+
options[:file] = file
|
36
|
+
end
|
37
|
+
|
38
|
+
op.on("-h", "--help", "I WANT MOAR HALP" ) do
|
39
|
+
puts op
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
parser.parse!
|
46
|
+
|
47
|
+
if options[:file]
|
48
|
+
puts options.to_s
|
49
|
+
File.open(options[:file], "a") do |f|
|
50
|
+
f.puts("#{options[:si]}:#{options[:cs]}|su")
|
51
|
+
f.close
|
52
|
+
end
|
53
|
+
else
|
54
|
+
Stepper.daemon_hostport = options[:host]
|
55
|
+
Stepper.stepup(options[:si],options[:cs])
|
56
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'benchmark'
|
3
|
+
|
4
|
+
module Stepper
|
5
|
+
unless self.respond_to?(:measure)
|
6
|
+
class << self
|
7
|
+
attr_accessor :daemon_host, :daemon_port, :disabled
|
8
|
+
|
9
|
+
def daemon_hostport=(hostport)
|
10
|
+
self.daemon_host, port = hostport.split(':')
|
11
|
+
self.daemon_port = port.to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
def daemon_host
|
15
|
+
@daemon_host || "localhost"
|
16
|
+
end
|
17
|
+
|
18
|
+
def daemon_port
|
19
|
+
@daemon_port || 8889
|
20
|
+
end
|
21
|
+
|
22
|
+
def step(key, value, file = nil)
|
23
|
+
write(key, value, :s, nil, file)
|
24
|
+
end
|
25
|
+
|
26
|
+
def stepup(key, delta = 1, file = nil)
|
27
|
+
write(key, delta, :su, nil, file)
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
def socket
|
33
|
+
@socket ||= UDPSocket.new
|
34
|
+
end
|
35
|
+
|
36
|
+
def write(k, v, op, file = nil)
|
37
|
+
return if self.disabled
|
38
|
+
|
39
|
+
command = "#{k}:#{v}|#{op}"
|
40
|
+
|
41
|
+
if file
|
42
|
+
File.open(file, "a") do |f|
|
43
|
+
f.puts(command)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
socket.send(command, 0, self.daemon_host, self.daemon_port)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stepper-instrument
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- SeongSik, Kim
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2013-01-30 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: remote_syslog
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 6
|
31
|
+
- 13
|
32
|
+
version: 1.6.13
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Instrument your app to send metrics to a Stepper.
|
36
|
+
email: kssminus@gmail.com
|
37
|
+
executables:
|
38
|
+
- step
|
39
|
+
- stepup
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- lib/stepper-instrument.rb
|
46
|
+
- bin/step
|
47
|
+
- bin/stepup
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: https://github.com/kssminus/stepper-instrument.git
|
50
|
+
licenses: []
|
51
|
+
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 1
|
64
|
+
- 9
|
65
|
+
- 2
|
66
|
+
version: 1.9.2
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.7
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Instrument your app to send metrics to a Stepper
|
82
|
+
test_files: []
|
83
|
+
|