statsd-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +32 -0
- data/Rakefile +1 -0
- data/bin/statsd +25 -0
- data/lib/statsd-cli.rb +29 -0
- data/lib/statsd-cli/version.rb +3 -0
- data/statsd-cli.gemspec +25 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Statsd-cli
|
2
|
+
|
3
|
+
Report statsd metrics via command line.
|
4
|
+
You can follow [@jondot](http://twitter.com/jondot) for any questions.
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
Statsd-cli was built in order to provide tooling for out of band systems such as
|
10
|
+
Nagios.
|
11
|
+
|
12
|
+
Here is an example command you can in your shell, or shell out
|
13
|
+
in your Nagios checks, and any other system for that matter.
|
14
|
+
|
15
|
+
$ statsd -h stats.me.com -o count -m mongo.rw.ip-42-42-42-42 -v 31
|
16
|
+
|
17
|
+
Options:
|
18
|
+
|
19
|
+
-h, --host Statsd host
|
20
|
+
-m, --metric Metric to report
|
21
|
+
-o, --operation Statsd operation: increment, decrement, timing, count
|
22
|
+
-v, --value Metric value
|
23
|
+
-s, --sample_rate Sampling rate
|
24
|
+
-h, --help Print this help message
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).
|
29
|
+
|
30
|
+
## Copyright
|
31
|
+
|
32
|
+
Copyright (c) 2011 [Dotan Nahum](http://gplus.to/dotan) [@jondot](http://twitter.com/jondot). See MIT-LICENSE for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/statsd
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'slop'
|
4
|
+
require 'statsd-cli'
|
5
|
+
|
6
|
+
begin
|
7
|
+
opts = Slop.parse(:help => true, :strict => true) do
|
8
|
+
banner "statsd -h host -m metric -o operation -v value -s sample_rate\n" + \
|
9
|
+
"example:\n" + \
|
10
|
+
" statsd -h stats.me.com -o increment -m mongo.rw.ip-42-42-42-42 -v 31"
|
11
|
+
|
12
|
+
on :h, :host=, 'Statsd host'
|
13
|
+
on :m, :metric=, 'Metric to report'
|
14
|
+
on :o, :operation=, 'Statsd operation: increment, decrement, timing, count'
|
15
|
+
on :v, :value=, 'Metric value'
|
16
|
+
on :s, :sample_rate=, 'Sampling rate (optional)', :optional_argument => true
|
17
|
+
end
|
18
|
+
s = StatsdCLI::Runner.new
|
19
|
+
s.run! opts.to_hash
|
20
|
+
rescue => ex
|
21
|
+
puts ex
|
22
|
+
exit!
|
23
|
+
end
|
24
|
+
|
25
|
+
|
data/lib/statsd-cli.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "statsd-cli/version"
|
2
|
+
require 'statsd'
|
3
|
+
|
4
|
+
|
5
|
+
module StatsdCLI
|
6
|
+
class Runner
|
7
|
+
OPS = %w{ increment decrement count timing }
|
8
|
+
def run!(opts)
|
9
|
+
args = resolve(opts)
|
10
|
+
meth = args.shift
|
11
|
+
::Statsd.new(opts[:host]).__send__ meth, *args
|
12
|
+
end
|
13
|
+
|
14
|
+
def resolve(opts)
|
15
|
+
raise "No operation '#{opts[:operation]}'.\nUse any of: #{OPS.inspect}." unless OPS.include? opts[:operation]
|
16
|
+
raise "Please provide a metric." if opts[:metric].nil?
|
17
|
+
|
18
|
+
res = [opts[:operation], opts[:metric]]
|
19
|
+
|
20
|
+
if ["count", "timing"].include? opts[:operation]
|
21
|
+
res << opts[:value].to_i
|
22
|
+
end
|
23
|
+
|
24
|
+
res << opts[:sample_rate].to_i if opts[:sample_rate]
|
25
|
+
res
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
data/statsd-cli.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "statsd-cli/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "statsd-cli"
|
7
|
+
s.version = StatsdCLI::VERSION
|
8
|
+
s.authors = ["Dotan Nahum"]
|
9
|
+
s.email = ["jondotan@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Report statsd metrics with commandline Statsd}
|
12
|
+
s.description = %q{Report statsd metrics with commandline Statsd}
|
13
|
+
|
14
|
+
s.rubyforge_project = "statsd-cli"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
s.add_runtime_dependency "statsd-ruby"
|
24
|
+
s.add_runtime_dependency "slop"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: statsd-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dotan Nahum
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-13 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: statsd-ruby
|
16
|
+
requirement: &81089250 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *81089250
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: slop
|
27
|
+
requirement: &81088970 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *81088970
|
36
|
+
description: Report statsd metrics with commandline Statsd
|
37
|
+
email:
|
38
|
+
- jondotan@gmail.com
|
39
|
+
executables:
|
40
|
+
- statsd
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- bin/statsd
|
49
|
+
- lib/statsd-cli.rb
|
50
|
+
- lib/statsd-cli/version.rb
|
51
|
+
- statsd-cli.gemspec
|
52
|
+
homepage: ''
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project: statsd-cli
|
72
|
+
rubygems_version: 1.8.10
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Report statsd metrics with commandline Statsd
|
76
|
+
test_files: []
|