wavefront-client 3.5.3 → 3.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/README-cli.md +84 -60
- data/bin/wavefront +84 -69
- data/lib/wavefront/alerting.rb +14 -3
- data/lib/wavefront/batch_writer.rb +7 -0
- data/lib/wavefront/cli.rb +15 -17
- data/lib/wavefront/cli/alerts.rb +15 -10
- data/lib/wavefront/cli/batch_write.rb +12 -3
- data/lib/wavefront/cli/events.rb +19 -3
- data/lib/wavefront/cli/sources.rb +22 -12
- data/lib/wavefront/cli/ts.rb +9 -1
- data/lib/wavefront/cli/write.rb +7 -0
- data/lib/wavefront/client.rb +9 -5
- data/lib/wavefront/client/version.rb +1 -1
- data/lib/wavefront/constants.rb +20 -0
- data/lib/wavefront/events.rb +26 -4
- data/lib/wavefront/metadata.rb +23 -6
- data/lib/wavefront/opt_handler.rb +61 -0
- data/spec/cli_spec.rb +584 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/wavefront/alerting_spec.rb +8 -9
- data/spec/wavefront/batch_writer_spec.rb +1 -1
- data/spec/wavefront/cli/alerts_spec.rb +5 -4
- data/spec/wavefront/cli/batch_write_spec.rb +4 -2
- data/spec/wavefront/cli/events_spec.rb +3 -2
- data/spec/wavefront/cli/sources_spec.rb +3 -2
- data/spec/wavefront/cli/write_spec.rb +4 -2
- data/spec/wavefront/cli_spec.rb +11 -43
- data/spec/wavefront/client_spec.rb +2 -2
- data/spec/wavefront/events_spec.rb +1 -1
- data/spec/wavefront/metadata_spec.rb +1 -1
- data/spec/wavefront/mixins_spec.rb +1 -1
- data/spec/wavefront/opt_handler_spec.rb +89 -0
- data/spec/wavefront/resources/conf.yaml +10 -0
- data/spec/wavefront/response_spec.rb +3 -3
- data/spec/wavefront/validators_spec.rb +1 -1
- data/spec/wavefront/writer_spec.rb +1 -1
- metadata +9 -3
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c289e188276ac63035e6acd3ea84ab59721e63b
|
4
|
+
data.tar.gz: eb9d96bae403aa21ed775bf37bb5ad85d8c078c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18b87b4ff437336b124a353fb982bdea69c0a34ed32314a0fad69db6f636cb33c0b529cad6dffa95137ef18a952b1ad0d1066959e01fa25e652bceb04e78b5e8
|
7
|
+
data.tar.gz: c926ec0a4245bba66b92f64daa28cbb300c8abad127d3a2f302b6c05b14e234e0109b6986678bb220c6651886125a716e96a154e75ac5c7ee81fc9a25d0564e1
|
data/.travis.yml
CHANGED
data/README-cli.md
CHANGED
@@ -12,11 +12,18 @@ The following options are valid in almost all contexts.
|
|
12
12
|
```
|
13
13
|
-c, --config=FILE path to configuration file [default: ~/.wavefront]
|
14
14
|
-P, --profile=NAME profile in configuration file [default: default]
|
15
|
-
-t, --token=TOKEN Wavefront authentication token
|
16
15
|
-D, --debug enable debug mode
|
16
|
+
-V, --verbose enable verbose mode
|
17
17
|
-h, --help show help for command
|
18
18
|
```
|
19
19
|
|
20
|
+
Debug mode will show you combined options, and debug output from
|
21
|
+
`rest-client`. It also shows the full stack trace should a command
|
22
|
+
fail.
|
23
|
+
|
24
|
+
In the following usage examples, the global options have been omitted
|
25
|
+
to save space.
|
26
|
+
|
20
27
|
## `ts` Mode: Retrieving Timeseries Data
|
21
28
|
|
22
29
|
The `ts` command is used to submit a standard timeseries query to
|
@@ -26,13 +33,13 @@ query.
|
|
26
33
|
|
27
34
|
```
|
28
35
|
Usage:
|
29
|
-
wavefront ts [-c file] [-P profile] [-E endpoint] [-t token] [-
|
36
|
+
wavefront ts [-c file] [-P profile] [-E endpoint] [-t token] [-ODV]
|
30
37
|
[-S | -m | -H | -d] [-s time] [-e time] [-f format] [-p num]
|
31
38
|
[-X bool] <query>
|
32
39
|
|
33
40
|
Options:
|
34
|
-
-E, --endpoint=URI cluster endpoint [
|
35
|
-
|
41
|
+
-E, --endpoint=URI cluster endpoint [metrics.wavefront.com]
|
42
|
+
-t, --token=TOKEN Wavefront authentication token
|
36
43
|
-S, --seconds query granularity of seconds
|
37
44
|
-m, --minutes query granularity of minutes
|
38
45
|
-H, --hours query granularity of hours
|
@@ -41,13 +48,12 @@ Options:
|
|
41
48
|
strptime parseable format
|
42
49
|
-e, --end=TIME end of query window in epoch seconds or
|
43
50
|
strptime parseable format
|
44
|
-
-f, --format=STRING output format (raw, ruby, graphite,
|
45
|
-
|
46
|
-
[default: raw]
|
51
|
+
-f, --format=STRING output format (raw, ruby, graphite, highcharts, human)
|
52
|
+
[raw]
|
47
53
|
-p, --prefixlength=NUM number of path elements to treat as prefix
|
48
|
-
in schema manipulation. [
|
54
|
+
in schema manipulation. [1]
|
49
55
|
-X, --strict=BOOL Do not return points outside the query
|
50
|
-
window. [
|
56
|
+
window. [true]
|
51
57
|
-O, --includeObsoleteMetrics include metrics unreported for > 4 weeks
|
52
58
|
```
|
53
59
|
|
@@ -106,17 +112,18 @@ formatters.
|
|
106
112
|
|
107
113
|
```
|
108
114
|
Usage:
|
109
|
-
wavefront alerts [-c file] [-P profile] [-E endpoint] [-t token]
|
115
|
+
wavefront alerts [-D] [-c file] [-P profile] [-E endpoint] [-t token] [-V]
|
110
116
|
[-f format] [-p tag] [ -s tag] <state>
|
111
117
|
|
112
118
|
Options:
|
113
|
-
-E, --endpoint=URI
|
114
|
-
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
119
|
+
-E, --endpoint=URI cluster endpoint [metrics.wavefront.com]
|
120
|
+
-t, --token=TOKEN Wavefront authentication token
|
121
|
+
-f, --alertformat=STRING output format (ruby, json, human)
|
122
|
+
[]
|
123
|
+
-p, --private=TAG retrieve only alerts with named private tags,
|
124
|
+
comma delimited.
|
125
|
+
-s, --shared=TAG retrieve only alerts with named shared tags,
|
126
|
+
comma delimited.
|
120
127
|
```
|
121
128
|
|
122
129
|
### Examples
|
@@ -160,26 +167,29 @@ The `event` command is used to open and close Wavefront events.
|
|
160
167
|
|
161
168
|
```
|
162
169
|
Usage:
|
163
|
-
wavefront event create [-
|
164
|
-
[-d description] [-s time] [-i | -e time] [-l level] [-
|
170
|
+
wavefront event create [-DV] [-c file] [-P profile] [-E endpoint] [-t token]
|
171
|
+
[-d description] [-s time] [-i | -e time] [-l level] [-T type]
|
165
172
|
[-H host] [-n] <event>
|
166
|
-
wavefront event close [-
|
173
|
+
wavefront event close [-DV] [-c file] [-P profile] [-E endpoint] [-t token]
|
167
174
|
[<event>] [<timestamp>]
|
168
|
-
wavefront event delete [-
|
175
|
+
wavefront event delete [-DV] [-c file] [-P profile] [-E endpoint] [-t token]
|
176
|
+
<timestamp> <event>
|
169
177
|
wavefront event show
|
170
178
|
wavefront event --help
|
171
179
|
|
172
180
|
Options:
|
173
|
-
-E, --endpoint=URI cluster endpoint [
|
181
|
+
-E, --endpoint=URI cluster endpoint [metrics.wavefront.com]
|
182
|
+
-t, --token=TOKEN Wavefront authentication token
|
174
183
|
-i, --instant create an instantaneous event
|
175
|
-
-V, --verbose be verbose
|
176
184
|
-s, --start=TIME time at which event begins
|
177
185
|
-e, --end=TIME time at which event ends
|
178
186
|
-l, --level=LEVEL level of event (info, smoke, warn, severe)
|
179
187
|
-T, --type=TYPE type of event
|
180
188
|
-d, --desc=STRING description of event
|
181
|
-
-H, --host=STRING list of hosts to tag with
|
189
|
+
-H, --host=STRING list of hosts to tag with event (comma separated)
|
182
190
|
-n, --nostate do not create a local file recording the event
|
191
|
+
|
192
|
+
View events in detail using the 'ts' command with the 'events()' function.
|
183
193
|
```
|
184
194
|
|
185
195
|
To close an event in the Wavefront API it must be identified by its
|
@@ -266,19 +276,31 @@ Usage:
|
|
266
276
|
[-p port] [-H host] [-n] [-T tag...] <metric> <value>
|
267
277
|
wavefront write file [-DV] [-c file] [-P profile] [-E proxy] [-H host]
|
268
278
|
[-p port] [-n] [-F format] [-m metric] [-T tag...] <file>
|
279
|
+
wavefront write --help
|
269
280
|
|
270
|
-
|
271
|
-
-
|
272
|
-
-
|
273
|
-
-
|
274
|
-
-p, --port=INT Wavefront proxy port [default: 2878]
|
275
|
-
-T, --tag=TAG point tag in key=value form
|
276
|
-
-F, --format=STRING format of input file or stdin [default: tmv]
|
277
|
-
-n, --noop show the metric without sending it
|
278
|
-
-m, --metric=STRING the metric path to which contents of a file will be
|
279
|
-
assigned. If the file contains a metric name, the two
|
280
|
-
will be concatenated
|
281
|
+
Global options:
|
282
|
+
-c, --config=FILE path to configuration file [/home/rob/.wavefront]
|
283
|
+
-P, --profile=NAME profile in configuration file [default]
|
284
|
+
-D, --debug enable debug mode
|
281
285
|
-V, --verbose be verbose
|
286
|
+
-h, --help show this message
|
287
|
+
|
288
|
+
Options:
|
289
|
+
-E, --proxy=URI proxy endpoint [wavefront]
|
290
|
+
-t, --time=TIME time of data point (omit to use current time)
|
291
|
+
-H, --host=STRING source host [box]
|
292
|
+
-p, --port=INT Wavefront proxy port [2878]
|
293
|
+
-T, --tag=TAG point tag in key=value form
|
294
|
+
-F, --infileformat=STRING format of input file or stdin [tmv]
|
295
|
+
-n, --noop show the metric without sending it
|
296
|
+
-m, --metric=STRING the metric path to which contents of a
|
297
|
+
file will be assigned. If the file
|
298
|
+
contains a metric name, the two will be
|
299
|
+
concatenated
|
300
|
+
|
301
|
+
Files are whitespace separated, and fields can be defined with the -F
|
302
|
+
option. Use 't' for timestamp; 'm' for metric name; 'v' for value
|
303
|
+
and 'T' for tags. Put 'T' last.
|
282
304
|
```
|
283
305
|
|
284
306
|
`write` has two sub-commands: `write point` and `write file`. Both
|
@@ -364,37 +386,34 @@ sources. Note that source tags are not the same as point tags.
|
|
364
386
|
|
365
387
|
```
|
366
388
|
Usage:
|
367
|
-
wavefront source list [-c file] [-P profile] [-E endpoint] [-t token]
|
368
|
-
[-f format] [-T tag ...] [-
|
369
|
-
wavefront source show [-c file] [-P profile] [-E endpoint] [-t token]
|
389
|
+
wavefront source list [-c file] [-P profile] [-E endpoint] [-t token] [-DV]
|
390
|
+
[-f format] [-T tag ...] [-ag] [-s source] [-l limit] <pattern>
|
391
|
+
wavefront source show [-c file] [-P profile] [-E endpoint] [-t token] [-DV]
|
370
392
|
[-f format] <host> ...
|
371
393
|
wavefront source describe [-c file] [-P profile] [-E endpoint] [-t token]
|
372
|
-
[-H host ... ] <description>
|
394
|
+
[-DV] [-H host ... ] <description>
|
373
395
|
wavefront source undescribe [-c file] [-P profile] [-E endpoint] [-t token]
|
374
|
-
[<host>] ...
|
396
|
+
[-DV] [<host>] ...
|
375
397
|
wavefront source tag add [-c file] [-P profile] [-E endpoint] [-t token]
|
376
|
-
[-H host ... ] <tag> ...
|
398
|
+
[-DV] [-H host ... ] <tag> ...
|
377
399
|
wavefront source tag delete [-c file] [-P profile] [-E endpoint] [-t token]
|
378
|
-
[-H host ... ] <tag> ...
|
379
|
-
wavefront source untag [-c file] [-P profile] [-E endpoint] [-t token]
|
400
|
+
[-DV] [-H host ... ] <tag> ...
|
401
|
+
wavefront source untag [-c file] [-P profile] [-E endpoint] [-t token] [-DV]
|
380
402
|
[<host>] ...
|
381
403
|
wavefront source --help
|
382
404
|
|
383
|
-
Global options:
|
384
|
-
-c, --config=FILE path to configuration file [default: /home/rob/.wavefront]
|
385
|
-
-P, --profile=NAME profile in configuration file [default: default]
|
386
|
-
-D, --debug enable debug mode
|
387
|
-
-h, --help show this message
|
388
|
-
|
389
405
|
Options:
|
390
|
-
-
|
391
|
-
-t, --
|
392
|
-
-
|
393
|
-
-
|
394
|
-
-
|
395
|
-
|
396
|
-
-
|
397
|
-
|
406
|
+
-E, --endpoint=URI cluster endpoint [metrics.wavefront.com]
|
407
|
+
-t, --token=TOKEN Wavefront authentication token
|
408
|
+
-a, --all including hidden sources in 'human' output
|
409
|
+
-g, --tags show tag counts in 'human' output
|
410
|
+
-T, --tagged=STRING only list sources with this tag when using
|
411
|
+
'human' output
|
412
|
+
-s, --start=STRING start the list after the named source
|
413
|
+
-l, --limit=NUMBER only list NUMBER sources
|
414
|
+
-H, --host=STRING source to manipulate
|
415
|
+
-f, --sourceformat=STRING output format (ruby, json, human)
|
416
|
+
[human]
|
398
417
|
```
|
399
418
|
|
400
419
|
Tags and descriptions can be applied to multiple sources by repeated
|
@@ -480,7 +499,9 @@ string.
|
|
480
499
|
Passing tokens and endpoints into the `wavefront` command can become
|
481
500
|
tiresome, so you can put such data into an `ini`-style configuration
|
482
501
|
file. By default this file should be located at `${HOME}/.wavefront`,
|
483
|
-
though you can override the location with the `-c` flag.
|
502
|
+
though you can override the location with the `-c` flag. You can
|
503
|
+
also put a system-wide file at `/etc/wavefront/client.conf`, though
|
504
|
+
the user-specific file will take precedentce.
|
484
505
|
|
485
506
|
You can switch between Wavefront accounts using profile stanzas,
|
486
507
|
selected with the `-P` option. If `-P` is not supplied, the
|
@@ -493,16 +514,19 @@ A configuration file looks like this:
|
|
493
514
|
[default]
|
494
515
|
token = abcdefab-1234-abcd-1234-abcdefabcdef
|
495
516
|
endpoint = companya.wavefront.com
|
496
|
-
format =
|
517
|
+
format = json
|
518
|
+
alertformat = human
|
497
519
|
|
498
520
|
[companyb]
|
499
521
|
token = 12345678-abcd-0123-abcd-123456789abc
|
500
522
|
endpoint = metrics.wavefront.com
|
523
|
+
proxy = wavefront.local
|
524
|
+
sourceformat = json
|
501
525
|
```
|
502
526
|
|
503
527
|
The key for each key-value pair can match any long option show in the
|
504
528
|
command `help`, so you can set, for instance, a default output
|
505
|
-
format, as shown above.
|
529
|
+
format for timeseries, alerts and source commands, as shown above.
|
506
530
|
|
507
531
|
If an option is defined by a command-line switch, and in the
|
508
532
|
configuration file, the config file will win.
|
data/bin/wavefront
CHANGED
@@ -15,17 +15,19 @@
|
|
15
15
|
#
|
16
16
|
|
17
17
|
require 'pathname'
|
18
|
+
|
19
|
+
# uncomment for development
|
20
|
+
$LOAD_PATH.<< Pathname.new(__FILE__).dirname.realpath.parent + 'lib'
|
21
|
+
|
18
22
|
require 'wavefront/client'
|
19
23
|
require 'wavefront/client/version'
|
20
24
|
require 'wavefront/cli'
|
25
|
+
require 'wavefront/opt_handler'
|
21
26
|
require 'docopt'
|
22
|
-
require 'socket'
|
23
27
|
include Wavefront::Constants
|
24
28
|
|
25
29
|
def sanitize_keys(hash)
|
26
|
-
hash.each_with_object({})
|
27
|
-
aggr[k.delete('-').to_sym] = v
|
28
|
-
end
|
30
|
+
hash.each_with_object({}) { |(k, v), aggr| aggr[k.delete('-').to_sym] = v }
|
29
31
|
end
|
30
32
|
|
31
33
|
ME = Pathname.new(__FILE__).basename
|
@@ -33,19 +35,20 @@ ME = Pathname.new(__FILE__).basename
|
|
33
35
|
# If we are a normal user, look for wavefront config in our home
|
34
36
|
# directory; if not, look in /etc
|
35
37
|
#
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
conf_file = if ENV['HOME']
|
39
|
+
Pathname.new(ENV['HOME']) + '.wavefront'
|
40
|
+
else
|
41
|
+
Pathname.new('/etc/wavefront/client.conf')
|
42
|
+
end
|
41
43
|
|
42
44
|
# The global_opts are available in every command.
|
43
45
|
#
|
44
46
|
global_opts = %(
|
45
47
|
Global options:
|
46
|
-
-c, --config=FILE path to configuration file [
|
47
|
-
-P, --profile=NAME profile in configuration file [
|
48
|
+
-c, --config=FILE path to configuration file [#{conf_file}]
|
49
|
+
-P, --profile=NAME profile in configuration file [#{DEFAULT_OPTS[:profile]}]
|
48
50
|
-D, --debug enable debug mode
|
51
|
+
-n, --noop don't perform API calls
|
49
52
|
-V, --verbose be verbose
|
50
53
|
-h, --help show this message
|
51
54
|
)
|
@@ -56,12 +59,12 @@ Global options:
|
|
56
59
|
usage = {
|
57
60
|
ts: %(
|
58
61
|
Usage:
|
59
|
-
#{ME} ts [-c file] [-P profile] [-E endpoint] [-t token] [-
|
62
|
+
#{ME} ts [-c file] [-P profile] [-E endpoint] [-t token] [-ODnV]
|
60
63
|
[-S | -m | -H | -d] [-s time] [-e time] [-f format] [-p num]
|
61
64
|
[-X bool] <query>
|
62
65
|
#{global_opts}
|
63
66
|
Options:
|
64
|
-
-E, --endpoint=URI cluster endpoint [
|
67
|
+
-E, --endpoint=URI cluster endpoint [#{DEFAULT_OPTS[:endpoint]}]
|
65
68
|
-t, --token=TOKEN Wavefront authentication token
|
66
69
|
-S, --seconds query granularity of seconds
|
67
70
|
-m, --minutes query granularity of minutes
|
@@ -72,73 +75,76 @@ Options:
|
|
72
75
|
-e, --end=TIME end of query window in epoch seconds or
|
73
76
|
strptime parseable format
|
74
77
|
-f, --format=STRING output format (#{FORMATS.join(', ')})
|
75
|
-
[
|
78
|
+
[#{DEFAULT_OPTS[:format]}]
|
76
79
|
-p, --prefixlength=NUM number of path elements to treat as prefix
|
77
|
-
in schema manipulation. [
|
80
|
+
in schema manipulation. [#{DEFAULT_OPTS[:prefixlength]}]
|
78
81
|
-X, --strict=BOOL Do not return points outside the query
|
79
|
-
window. [
|
82
|
+
window. [#{DEFAULT_OPTS[:strict]}]
|
80
83
|
-O, --includeObsoleteMetrics include metrics unreported for > 4 weeks
|
81
84
|
),
|
82
85
|
|
83
86
|
alerts: %(
|
84
87
|
Usage:
|
85
|
-
#{ME} alerts [-c file] [-P profile] [-E endpoint] [-t token]
|
88
|
+
#{ME} alerts [-DnV] [-c file] [-P profile] [-E endpoint] [-t token]
|
86
89
|
[-f format] [-p tag] [ -s tag] <state>
|
87
90
|
#{global_opts}
|
88
91
|
Options:
|
89
|
-
-E, --endpoint=URI
|
90
|
-
-t, --token=TOKEN
|
91
|
-
-f, --
|
92
|
-
|
93
|
-
-p, --private=TAG
|
94
|
-
|
95
|
-
-s, --shared=TAG
|
96
|
-
|
92
|
+
-E, --endpoint=URI cluster endpoint [#{DEFAULT_OPTS[:endpoint]}]
|
93
|
+
-t, --token=TOKEN Wavefront authentication token
|
94
|
+
-f, --alertformat=STRING output format (#{ALERT_FORMATS.join(', ')})
|
95
|
+
[#{DEFAULT_OPTS[:aformat]}]
|
96
|
+
-p, --private=TAG retrieve only alerts with named private tags,
|
97
|
+
comma delimited.
|
98
|
+
-s, --shared=TAG retrieve only alerts with named shared tags,
|
99
|
+
comma delimited.
|
97
100
|
),
|
98
101
|
|
99
102
|
event: %(
|
100
103
|
Usage:
|
101
|
-
#{ME} event create [-
|
104
|
+
#{ME} event create [-DnV] [-c file] [-P profile] [-E endpoint] [-t token]
|
102
105
|
[-d description] [-s time] [-i | -e time] [-l level] [-T type]
|
103
|
-
[-H host] [-
|
104
|
-
#{ME} event close [-
|
106
|
+
[-H host] [-N] <event>
|
107
|
+
#{ME} event close [-DnV] [-c file] [-P profile] [-E endpoint] [-t token]
|
105
108
|
[<event>] [<timestamp>]
|
106
|
-
#{ME} event delete [-
|
109
|
+
#{ME} event delete [-DnV] [-c file] [-P profile] [-E endpoint] [-t token]
|
110
|
+
<timestamp> <event>
|
107
111
|
#{ME} event show
|
108
112
|
#{ME} event --help
|
109
113
|
#{global_opts}
|
110
114
|
Options:
|
115
|
+
-E, --endpoint=URI cluster endpoint [#{DEFAULT_OPTS[:endpoint]}]
|
116
|
+
-t, --token=TOKEN Wavefront authentication token
|
111
117
|
-i, --instant create an instantaneous event
|
112
118
|
-s, --start=TIME time at which event begins
|
113
119
|
-e, --end=TIME time at which event ends
|
114
120
|
-l, --level=LEVEL level of event (#{EVENT_LEVELS.join(', ')})
|
115
121
|
-T, --type=TYPE type of event
|
116
122
|
-d, --desc=STRING description of event
|
117
|
-
-H, --host=STRING list of
|
118
|
-
-
|
123
|
+
-H, --host=STRING list of sources to which event applies (comma separated)
|
124
|
+
-N, --nostate do not create a local file recording the event
|
119
125
|
|
120
126
|
View events in detail using the 'ts' command with the 'events()' function.
|
121
127
|
),
|
122
128
|
|
123
129
|
write: %(
|
124
130
|
Usage:
|
125
|
-
#{ME} write point [-
|
131
|
+
#{ME} write point [-DnV] [-c file] [-P profile] [-E proxy] [-t time]
|
126
132
|
[-p port] [-H host] [-n] [-T tag...] <metric> <value>
|
127
|
-
#{ME} write file [-
|
133
|
+
#{ME} write file [-DnV] [-c file] [-P profile] [-E proxy] [-H host]
|
128
134
|
[-p port] [-n] [-F format] [-m metric] [-T tag...] <file>
|
129
135
|
#{ME} write --help
|
130
136
|
#{global_opts}
|
131
137
|
Options:
|
132
|
-
-E, --proxy=URI
|
133
|
-
-t, --time=TIME
|
134
|
-
-H, --host=STRING
|
135
|
-
-p, --port=INT
|
136
|
-
-T, --tag=TAG
|
137
|
-
-F, --
|
138
|
-
-
|
139
|
-
|
140
|
-
|
141
|
-
|
138
|
+
-E, --proxy=URI proxy endpoint [#{DEFAULT_OPTS[:proxy]}]
|
139
|
+
-t, --time=TIME time of data point (omit to use current time)
|
140
|
+
-H, --host=STRING source host [#{DEFAULT_OPTS[:host]}]
|
141
|
+
-p, --port=INT Wavefront proxy port [#{DEFAULT_OPTS[:port]}]
|
142
|
+
-T, --tag=TAG point tag in key=value form
|
143
|
+
-F, --infileformat=STRING format of input file or stdin [#{DEFAULT_OPTS[:infileformat]}]
|
144
|
+
-m, --metric=STRING the metric path to which contents of a
|
145
|
+
file will be assigned. If the file
|
146
|
+
contains a metric name, the two will be
|
147
|
+
concatenated
|
142
148
|
|
143
149
|
Files are whitespace separated, and fields can be defined with the -F
|
144
150
|
option. Use 't' for timestamp; 'm' for metric name; 'v' for value
|
@@ -146,31 +152,33 @@ and 'T' for tags. Put 'T' last.
|
|
146
152
|
),
|
147
153
|
source: %(
|
148
154
|
Usage:
|
149
|
-
#{ME} source list [-c file] [-P profile] [-E endpoint] [-t token] [-
|
150
|
-
[-f format] [-T tag ...] [-
|
151
|
-
#{ME} source show [-c file] [-P profile] [-E endpoint] [-t token] [-
|
155
|
+
#{ME} source list [-c file] [-P profile] [-E endpoint] [-t token] [-DnV]
|
156
|
+
[-f format] [-T tag ...] [-ag] [-s source] [-l limit] <pattern>
|
157
|
+
#{ME} source show [-c file] [-P profile] [-E endpoint] [-t token] [-DnV]
|
152
158
|
[-f format] <host> ...
|
153
159
|
#{ME} source describe [-c file] [-P profile] [-E endpoint] [-t token]
|
154
|
-
[-
|
160
|
+
[-DnV] [-H host ... ] <description>
|
155
161
|
#{ME} source undescribe [-c file] [-P profile] [-E endpoint] [-t token]
|
156
|
-
[-
|
162
|
+
[-DnV] [<host>] ...
|
157
163
|
#{ME} source tag add [-c file] [-P profile] [-E endpoint] [-t token]
|
158
|
-
[-
|
164
|
+
[-DnV] [-H host ... ] <tag> ...
|
159
165
|
#{ME} source tag delete [-c file] [-P profile] [-E endpoint] [-t token]
|
160
|
-
[-
|
161
|
-
#{ME} source untag [-c file] [-P profile] [-E endpoint] [-t token] [-
|
166
|
+
[-DnV] [-H host ... ] <tag> ...
|
167
|
+
#{ME} source untag [-c file] [-P profile] [-E endpoint] [-t token] [-DnV]
|
162
168
|
[<host>] ...
|
163
169
|
#{ME} source --help
|
164
170
|
#{global_opts}
|
165
171
|
Options:
|
166
|
-
-
|
167
|
-
-t, --
|
168
|
-
-
|
169
|
-
-
|
170
|
-
-
|
171
|
-
|
172
|
-
-
|
173
|
-
|
172
|
+
-E, --endpoint=URI cluster endpoint [#{DEFAULT_OPTS[:endpoint]}]
|
173
|
+
-t, --token=TOKEN Wavefront authentication token
|
174
|
+
-a, --all including hidden sources in 'human' output
|
175
|
+
-g, --tags show tag counts in 'human' output
|
176
|
+
-T, --tagged=STRING only list sources with this tag when using
|
177
|
+
'human' output
|
178
|
+
-s, --start=STRING start the list after the named source
|
179
|
+
-l, --limit=NUMBER only list NUMBER sources
|
180
|
+
-H, --host=STRING source to manipulate
|
181
|
+
-f, --sourceformat=STRING output format (#{SOURCE_FORMATS.join(', ')}) [#{DEFAULT_OPTS[:sourceformat]}]
|
174
182
|
),
|
175
183
|
default: %(
|
176
184
|
Wavefront CLI
|
@@ -190,29 +198,33 @@ Commands:
|
|
190
198
|
Use '#{ME} <command> --help' for further information.)
|
191
199
|
}
|
192
200
|
|
193
|
-
# Parse the input.
|
194
|
-
#
|
201
|
+
# Parse the input. The first Docopt.docopt handles the default
|
202
|
+
# options, the second works on the command.
|
195
203
|
#
|
196
204
|
begin
|
197
205
|
opts = Docopt.docopt(usage[:default], version: Wavefront::Client::VERSION)
|
198
206
|
rescue Docopt::Exit => e
|
199
|
-
|
207
|
+
|
208
|
+
cmd = ARGV.empty? ? nil : ARGV.first.to_sym
|
200
209
|
|
201
210
|
if usage.keys.include?(cmd)
|
202
211
|
begin
|
203
212
|
opts = sanitize_keys(Docopt.docopt(usage[cmd]))
|
204
213
|
rescue Docopt::Exit => e
|
205
|
-
abort e.message
|
214
|
+
abort e.message # command help
|
206
215
|
end
|
207
216
|
else
|
208
|
-
abort e.message
|
217
|
+
abort e.message # default help
|
209
218
|
end
|
210
219
|
end
|
211
220
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
221
|
+
opts = Wavefront::OptHandler.new(conf_file, opts).opts
|
222
|
+
|
223
|
+
if opts[:debug]
|
224
|
+
require 'pp'
|
225
|
+
puts 'Combined options:'
|
226
|
+
pp opts
|
227
|
+
end
|
216
228
|
|
217
229
|
case cmd
|
218
230
|
when :ts
|
@@ -238,7 +250,10 @@ when :write
|
|
238
250
|
end
|
239
251
|
|
240
252
|
begin
|
253
|
+
cli.validate_opts
|
241
254
|
cli.run
|
242
255
|
rescue => e
|
243
|
-
|
256
|
+
STDERR.puts "#{cmd} query failed. #{e}"
|
257
|
+
STDERR.puts "Backtrace:\n\t#{e.backtrace.join("\n\t")}" if opts[:debug]
|
258
|
+
exit 1
|
244
259
|
end
|