echo_cli 0.6.17 → 0.6.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/echo_cli/cli.rb +59 -0
- data/lib/echo_cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a234d650ed7a98258fa860242a76555009e6b312
|
4
|
+
data.tar.gz: 9beedfea04e7babafeaea17ad701674a5f16f6eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1826547e8cf2f294a893b56f34b85253ddad6d844e7cf42a4456e5f5050580f7d8a509adf94a1ed5426953ae29422bb19d1041b55cfbd4b3b8a37c058105633
|
7
|
+
data.tar.gz: dc98048eb583be0ed12367123bf9bd2cb0545416afcbe75f3c5e50ed6b738570281a1308367092d53ba66aa55025288813885e3792d58d1a623e16a7463632d7
|
data/README.md
CHANGED
@@ -138,6 +138,8 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
138
138
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
139
139
|
|
140
140
|
```bash
|
141
|
+
$ bundle install
|
142
|
+
|
141
143
|
$ git add .
|
142
144
|
$ git commit -m
|
143
145
|
$ git push
|
data/lib/echo_cli/cli.rb
CHANGED
@@ -101,6 +101,65 @@ module Echo_cli
|
|
101
101
|
Helper.new.unset_envs()
|
102
102
|
end
|
103
103
|
|
104
|
+
desc "cpost", "Continuously post metrics to Echo. Use \"echo_cli cpost <URL> '<metric>' {frequency}\""
|
105
|
+
|
106
|
+
option :z
|
107
|
+
|
108
|
+
long_desc <<-LONGDESC
|
109
|
+
`echo_cli cpost` will continuously post a metric directly to Echo's StatsD server.
|
110
|
+
|
111
|
+
You can optionally specify a third integer parameter, which will post the metric to Echo at a frequency equal to the integer, in seconds. This value is set to '10 seconds' as the default continuous post frequency.
|
112
|
+
|
113
|
+
Ensure single-quotes surround the metric.
|
114
|
+
|
115
|
+
With -z (zombie) option, cpost will continuously send posts to Echo in the background, and return its PID for future removal.
|
116
|
+
|
117
|
+
> $ echo_cli cpost https://localhost:8125/metrix 'example.post:1|c' {1} {-z}
|
118
|
+
LONGDESC
|
119
|
+
|
120
|
+
def cpost(statsd_uri, metric, num = 0)
|
121
|
+
|
122
|
+
Helper.new.set_envs()
|
123
|
+
|
124
|
+
uri = URI.parse(statsd_uri)
|
125
|
+
request = Net::HTTP::Post.new(uri)
|
126
|
+
request["Token"] = "mySecretToken"
|
127
|
+
request.body = metric.gsub(/'/,"")
|
128
|
+
|
129
|
+
req_options = {
|
130
|
+
use_ssl: uri.scheme == "https",
|
131
|
+
verify_mode: OpenSSL::SSL::VERIFY_NONE,
|
132
|
+
}
|
133
|
+
|
134
|
+
if(num.to_i > 0)
|
135
|
+
s = num.to_i
|
136
|
+
else
|
137
|
+
s = 10
|
138
|
+
end
|
139
|
+
|
140
|
+
if(options[:z])
|
141
|
+
pid = Process.fork do
|
142
|
+
while true do
|
143
|
+
Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
144
|
+
http.request(request)
|
145
|
+
end
|
146
|
+
sleep s
|
147
|
+
end
|
148
|
+
end
|
149
|
+
puts "Process ID: " + pid.to_s
|
150
|
+
else
|
151
|
+
while true do
|
152
|
+
Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
153
|
+
http.request(request)
|
154
|
+
end
|
155
|
+
sleep s
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
Helper.new.unset_envs()
|
160
|
+
|
161
|
+
end
|
162
|
+
|
104
163
|
desc "query", "Query metrics on Echo. Use \"echo_cli query <URL> '<metric>' <time_start> <time_end> {-v}\""
|
105
164
|
|
106
165
|
option :v
|
data/lib/echo_cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: echo_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Raphael
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|