riemann-cli 0.1.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/riemann-cli +64 -0
  3. metadata +73 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: be192b67fa3f73227270cdad5b78c6db80e3c872
4
+ data.tar.gz: 439daff8288b5ec6fbae8e96938b9abb253fc613
5
+ SHA512:
6
+ metadata.gz: 8290f7b5968699d5d5d27fbedcd391879e8447b32b8dd0a7f1421cb749a794da762b9e675116b4b092c47c43463982bf0e65a443851c9b7478e8c886a999d919
7
+ data.tar.gz: c63062817fc9bbd2e164c5595becf8cfb5db0bed15faadee89a48f2bdc58f688888f7d1a1870e1abd63407f7b9eed00712ac198b0f204c90e3579817ffc53aed
data/bin/riemann-cli ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'riemann/client'
5
+
6
+ class MyCLI < Thor
7
+ class_option :server, :desc => 'Server address', :default => 'localhost'
8
+ class_option :port, :type => :numeric, :desc => 'Riemann server port', :default => 5555
9
+ class_option :timeout, :type => :numeric, :desc => 'Connection timeout', :default => 5
10
+ class_option :verbose, :type => :boolean, :aliases => ['-v']
11
+
12
+ desc 'send', 'Sends a metric to Riemann'
13
+ option :tcp, :type => :boolean , :desc => 'Use TCP transport'
14
+ option :host, :desc => 'Host that produces the metric. Default is gethostbyname()'
15
+ option :service , :desc=> 'Service that produced the event'
16
+ option :state, :desc => 'Service state'
17
+ option :time, :type => :numeric, :desc => 'Time of the event in unix epoch seconds. Default is current time'
18
+ option :description, :desc => 'Event description'
19
+ option :tags, :type => :array, :desc => 'List of tags'
20
+ option :metric, :type => :numeric, :desc => 'Value of the metric'
21
+ option :ttl, :type => :numeric, :desc => 'Floating-point number of seconds this event is considered valid for'
22
+ def send()
23
+ puts options if options[:verbose]
24
+ c = connect(options[:host], options[:port], options[:timeout])
25
+ event_fields = [:host, :service, :state, :time, :description, :tags, :metric, :ttl]
26
+ event = {}
27
+ event_fields.each do |f|
28
+ unless options[f].nil?
29
+ event[f] = options[f]
30
+ end
31
+ end
32
+ if options[:tcp]
33
+ puts "Sending using tcp" if options[:verbose]
34
+ c.tcp << event
35
+ else
36
+ puts "Sending using udp" if options[:verbose]
37
+ c.udp << event
38
+ end
39
+ end
40
+
41
+ desc 'query', 'Queries the index. The output can be controlled by the `--format` argument. The format string can contain placeholders of the form `%{name}` which will be substituted with the corresponding value. By default, query returns everything contained in the index'
42
+ option :string, :desc => 'Query string in Riemann query format', :default => 'true'
43
+ option :format, :desc => 'Format string for the output', :default => "{host:\"%{host}\", service:\"%{service}\", state:\"%{state}\", time:%{time}, description:\"%{description}\", tags:%{tags}, metric_f:%{metric_f}, metric_d:%{metric_d}, metric_sint64:%{metric_sint64}, ttl:%{ttl}}"
44
+ def query()
45
+ puts options if options[:verbose]
46
+ c = connect(options[:host], options[:port], options[:timeout])
47
+ c[options[:string]].each do |r|
48
+ values_hash = r.to_hash()
49
+ puts options[:format].gsub(/%{(.*?)}/) { |m|
50
+ values_hash[$1.to_sym]
51
+ }
52
+ end
53
+ end
54
+
55
+ no_commands do
56
+ def connect(host, port, timeout)
57
+ return Riemann::Client.new host: host, port: port, timeout: timeout
58
+ end
59
+ end
60
+ end
61
+
62
+ MyCLI.start(ARGV)
63
+
64
+ # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riemann-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Paul Goldbaum
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: riemann-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.18.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.18.0
41
+ description: A simple command-line tool to send events to Riemann
42
+ email: paul.goldbaum@gmail.com
43
+ executables:
44
+ - riemann-cli
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - bin/riemann-cli
49
+ homepage: http://github.com/paulgoldbaum/riemann-cli
50
+ licenses:
51
+ - MIT
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 2.0.3
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Command-line Riemann client
73
+ test_files: []