wavefront-cli 0.0.2
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.
- checksums.yaml +7 -0
- data/.codeclimate.yml +20 -0
- data/.gitignore +4 -0
- data/.travis.yml +16 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +65 -0
- data/README.md +221 -0
- data/Rakefile +18 -0
- data/bin/wavefront +14 -0
- data/lib/wavefront-cli/alert.rb +60 -0
- data/lib/wavefront-cli/base.rb +320 -0
- data/lib/wavefront-cli/cloudintegration.rb +12 -0
- data/lib/wavefront-cli/commands/alert.rb +38 -0
- data/lib/wavefront-cli/commands/base.rb +105 -0
- data/lib/wavefront-cli/commands/dashboard.rb +29 -0
- data/lib/wavefront-cli/commands/event.rb +44 -0
- data/lib/wavefront-cli/commands/integration.rb +33 -0
- data/lib/wavefront-cli/commands/link.rb +34 -0
- data/lib/wavefront-cli/commands/message.rb +23 -0
- data/lib/wavefront-cli/commands/metric.rb +20 -0
- data/lib/wavefront-cli/commands/proxy.rb +25 -0
- data/lib/wavefront-cli/commands/query.rb +32 -0
- data/lib/wavefront-cli/commands/savedsearch.rb +32 -0
- data/lib/wavefront-cli/commands/source.rb +27 -0
- data/lib/wavefront-cli/commands/user.rb +24 -0
- data/lib/wavefront-cli/commands/webhook.rb +25 -0
- data/lib/wavefront-cli/commands/window.rb +33 -0
- data/lib/wavefront-cli/commands/write.rb +35 -0
- data/lib/wavefront-cli/constants.rb +17 -0
- data/lib/wavefront-cli/controller.rb +134 -0
- data/lib/wavefront-cli/dashboard.rb +27 -0
- data/lib/wavefront-cli/display/alert.rb +44 -0
- data/lib/wavefront-cli/display/base.rb +304 -0
- data/lib/wavefront-cli/display/cloudintegration.rb +18 -0
- data/lib/wavefront-cli/display/dashboard.rb +21 -0
- data/lib/wavefront-cli/display/event.rb +19 -0
- data/lib/wavefront-cli/display/externallink.rb +13 -0
- data/lib/wavefront-cli/display/maintenancewindow.rb +19 -0
- data/lib/wavefront-cli/display/message.rb +8 -0
- data/lib/wavefront-cli/display/metric.rb +22 -0
- data/lib/wavefront-cli/display/proxy.rb +13 -0
- data/lib/wavefront-cli/display/query.rb +69 -0
- data/lib/wavefront-cli/display/savedsearch.rb +17 -0
- data/lib/wavefront-cli/display/source.rb +26 -0
- data/lib/wavefront-cli/display/user.rb +16 -0
- data/lib/wavefront-cli/display/webhook.rb +24 -0
- data/lib/wavefront-cli/display/write.rb +19 -0
- data/lib/wavefront-cli/event.rb +162 -0
- data/lib/wavefront-cli/exception.rb +5 -0
- data/lib/wavefront-cli/externallink.rb +16 -0
- data/lib/wavefront-cli/maintenancewindow.rb +16 -0
- data/lib/wavefront-cli/message.rb +19 -0
- data/lib/wavefront-cli/metric.rb +24 -0
- data/lib/wavefront-cli/opt_handler.rb +62 -0
- data/lib/wavefront-cli/proxy.rb +22 -0
- data/lib/wavefront-cli/query.rb +74 -0
- data/lib/wavefront-cli/savedsearch.rb +24 -0
- data/lib/wavefront-cli/source.rb +20 -0
- data/lib/wavefront-cli/user.rb +25 -0
- data/lib/wavefront-cli/version.rb +1 -0
- data/lib/wavefront-cli/webhook.rb +8 -0
- data/lib/wavefront-cli/write.rb +244 -0
- data/spec/spec_helper.rb +197 -0
- data/spec/wavefront-cli/alert_spec.rb +44 -0
- data/spec/wavefront-cli/base_spec.rb +47 -0
- data/spec/wavefront-cli/cli_help_spec.rb +47 -0
- data/spec/wavefront-cli/cloudintegration_spec.rb +24 -0
- data/spec/wavefront-cli/dashboard_spec.rb +37 -0
- data/spec/wavefront-cli/event_spec.rb +19 -0
- data/spec/wavefront-cli/externallink_spec.rb +18 -0
- data/spec/wavefront-cli/maintanancewindow_spec.rb +19 -0
- data/spec/wavefront-cli/message_spec.rb +28 -0
- data/spec/wavefront-cli/metric_spec.rb +22 -0
- data/spec/wavefront-cli/proxy_spec.rb +26 -0
- data/spec/wavefront-cli/query_spec.rb +63 -0
- data/spec/wavefront-cli/resources/conf.yaml +10 -0
- data/spec/wavefront-cli/savedsearch_spec.rb +18 -0
- data/spec/wavefront-cli/source_spec.rb +18 -0
- data/spec/wavefront-cli/user_spec.rb +31 -0
- data/spec/wavefront-cli/webhook_spec.rb +17 -0
- data/wavefront-cli.gemspec +36 -0
- metadata +279 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative './base'
|
2
|
+
|
3
|
+
# Define the Alert command
|
4
|
+
#
|
5
|
+
class WavefrontCommandAlert < WavefrontCommandBase
|
6
|
+
def description
|
7
|
+
'view and manage alerts'
|
8
|
+
end
|
9
|
+
|
10
|
+
def _commands
|
11
|
+
["list #{CMN} [-l] [-f format] [-o offset] [-L limit]",
|
12
|
+
"describe #{CMN} [-f format] [-v version] <id>",
|
13
|
+
"delete #{CMN} <id>",
|
14
|
+
"undelete #{CMN} <id>",
|
15
|
+
"history #{CMN} [-f format] [-o offset] [-L limit] <id>",
|
16
|
+
"import #{CMN} <file>",
|
17
|
+
"snooze #{CMN} [-T time] <id>",
|
18
|
+
"update #{CMN} <key=value> <id>",
|
19
|
+
"unsnooze #{CMN} <id>",
|
20
|
+
"tags #{CMN} [-f format] <id>",
|
21
|
+
"tag set #{CMN} <id> <tag>...",
|
22
|
+
"tag clear #{CMN} <id>",
|
23
|
+
"tag add #{CMN} <id> <tag>",
|
24
|
+
"tag delete #{CMN} <id> <tag>",
|
25
|
+
"summary #{CMN} [-a]"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def _options
|
29
|
+
[common_options,
|
30
|
+
'-l, --long list alerts in detail',
|
31
|
+
'-v, --version=INTEGER describe only this version of alert',
|
32
|
+
'-o, --offset=n start from nth alert',
|
33
|
+
'-L, --limit=COUNT number of alerts to list',
|
34
|
+
'-T, --time=SECONDS how long to snooze (default 3600)',
|
35
|
+
'-a, --all list all alerts',
|
36
|
+
'-f, --format=STRING output format']
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
CMN = '[-DnV] [-c file] [-P profile] [-E endpoint] [-t token]'.freeze
|
2
|
+
|
3
|
+
# A base class which all command classes extend.
|
4
|
+
#
|
5
|
+
class WavefrontCommandBase
|
6
|
+
# All commands have these options
|
7
|
+
#
|
8
|
+
def global_options
|
9
|
+
['-c, --config=FILE path to configuration file',
|
10
|
+
'-P, --profile=NAME profile in configuration file',
|
11
|
+
'-D, --debug enable debug mode',
|
12
|
+
'-n, --noop do not perform API calls',
|
13
|
+
'-V, --verbose be verbose',
|
14
|
+
'-h, --help show this message']
|
15
|
+
end
|
16
|
+
|
17
|
+
# Many commands have these options
|
18
|
+
#
|
19
|
+
def common_options
|
20
|
+
['-E, --endpoint=URI cluster endpoint',
|
21
|
+
'-t, --token=TOKEN Wavefront authentication token']
|
22
|
+
end
|
23
|
+
|
24
|
+
# Anything which takes tags provides the same interface
|
25
|
+
#
|
26
|
+
def tag_commands
|
27
|
+
["tags #{CMN} [-f format] <id>",
|
28
|
+
"tag set #{CMN} <id> <tag>...",
|
29
|
+
"tag clear #{CMN} <id>",
|
30
|
+
"tag add #{CMN} <id> <tag>",
|
31
|
+
"tag delete #{CMN} <id> <tag>"]
|
32
|
+
end
|
33
|
+
|
34
|
+
# The command keyword
|
35
|
+
#
|
36
|
+
def word
|
37
|
+
self.class.name.sub(/WavefrontCommand/, '').downcase
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns the name of the SDK class which does the work for this
|
41
|
+
# command.
|
42
|
+
#
|
43
|
+
def sdk_class
|
44
|
+
word.capitalize
|
45
|
+
end
|
46
|
+
|
47
|
+
def sdk_file
|
48
|
+
word
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns a string describing the subcommands the command offers.
|
52
|
+
#
|
53
|
+
def commands
|
54
|
+
_commands.flatten.each_with_object("Usage:\n") do |cmd, ret|
|
55
|
+
ret.<< ' ' + "#{CMD} #{word} #{cmd}\n".cmd_fold + "\n"
|
56
|
+
end + " #{CMD} #{word} --help"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns a string describing the options the command understands.
|
60
|
+
#
|
61
|
+
def options
|
62
|
+
width = column_widths
|
63
|
+
ret = "Global options:\n"
|
64
|
+
global_options.each { |o| ret.<< opt_row(o, width) }
|
65
|
+
ret.<< "\nOptions:\n"
|
66
|
+
_options.flatten.each { |o| ret.<< opt_row(o, width) }
|
67
|
+
ret
|
68
|
+
end
|
69
|
+
|
70
|
+
def opt_row(opt, width)
|
71
|
+
format(" %s %-#{width}s %s\n", *opt.split(/\s+/, 3))
|
72
|
+
end
|
73
|
+
|
74
|
+
def column_widths
|
75
|
+
(global_options + _options).flatten.map do |o|
|
76
|
+
o.split(/\s+/, 3)[0..1].join(' ').size
|
77
|
+
end.max
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns a string which will be printed underneath the options.
|
81
|
+
#
|
82
|
+
def postscript
|
83
|
+
''
|
84
|
+
end
|
85
|
+
|
86
|
+
# Returns a full options string which docopt understands
|
87
|
+
#
|
88
|
+
def docopt
|
89
|
+
commands + "\n\n" + options + "\n" + postscript
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Extensions to the String class to help with formatting.
|
94
|
+
#
|
95
|
+
class String
|
96
|
+
|
97
|
+
# Fold long command lines. We can't break on a space inside
|
98
|
+
# [square brackets] or it confuses docopt.
|
99
|
+
#
|
100
|
+
def cmd_fold(width = TW, indent = 10)
|
101
|
+
gsub(/\s(?=\w+\])/, '^').
|
102
|
+
scan(/\S.{0,#{width - 8}}\S(?=\s|$)|\S+/).join("\n" + ' ' * indent).
|
103
|
+
gsub('^', ' ')
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative './base'
|
2
|
+
|
3
|
+
# Define the dashboard command.
|
4
|
+
#
|
5
|
+
class WavefrontCommandDashboard < WavefrontCommandBase
|
6
|
+
def description
|
7
|
+
'view and manage dashboards'
|
8
|
+
end
|
9
|
+
|
10
|
+
def _commands
|
11
|
+
["list #{CMN} [-l] [-f format] [-o offset] [-L limit]",
|
12
|
+
"describe #{CMN} [-f format] [-v version] <id>",
|
13
|
+
"import #{CMN} [-f format] [-F] <file>",
|
14
|
+
"update #{CMN} <key=value> <id>",
|
15
|
+
"delete #{CMN} <id>",
|
16
|
+
"undelete #{CMN} <id>",
|
17
|
+
"history #{CMN} [-b] [-f format] [-o offset] [-L limit] <id>",
|
18
|
+
tag_commands]
|
19
|
+
end
|
20
|
+
|
21
|
+
def _options
|
22
|
+
[common_options,
|
23
|
+
'-l, --long list dashboards in detail',
|
24
|
+
'-o, --offset=n start list from nth dashboard or revision',
|
25
|
+
'-L, --limit=COUNT number of dashboards or revisions to list',
|
26
|
+
'-v, --version=INTEGER version of dashboard',
|
27
|
+
'-f, --format=STRING output format']
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative './base'
|
2
|
+
|
3
|
+
# Define the event command.
|
4
|
+
#
|
5
|
+
class WavefrontCommandEvent < WavefrontCommandBase
|
6
|
+
def description
|
7
|
+
'open, close, view, and manage events'
|
8
|
+
end
|
9
|
+
|
10
|
+
def _commands
|
11
|
+
["list #{CMN} [-l] [-f format] [-s start] [-e end] [-L limit] " \
|
12
|
+
'[-o offset]',
|
13
|
+
"describe #{CMN} [-f format] <id>",
|
14
|
+
"create #{CMN} [-d description] [-s time] [-i | -e time] " \
|
15
|
+
'[-S severity] [-T type] [-H host...] [-N] <event>',
|
16
|
+
"close #{CMN} [<id>]",
|
17
|
+
"delete #{CMN} <id>",
|
18
|
+
"update #{CMN} <key=value> <id>",
|
19
|
+
tag_commands,
|
20
|
+
'show [-D]']
|
21
|
+
end
|
22
|
+
|
23
|
+
def _options
|
24
|
+
[common_options,
|
25
|
+
'-l, --long list events in detail',
|
26
|
+
'-o, --offset=n start list from nth event',
|
27
|
+
'-L, --limit=COUNT number of events to list',
|
28
|
+
'-s, --start=TIME time at which event/window begins',
|
29
|
+
'-e, --end=TIME time at which even/window ends',
|
30
|
+
'-S, --severity=SEVERITY severity of event',
|
31
|
+
'-i, --instant create an instantaneous event',
|
32
|
+
'-T, --type=TYPE type of event',
|
33
|
+
'-d, --desc=STRING description of event',
|
34
|
+
'-H, --host=STRING source to which event applies',
|
35
|
+
'-N, --nostate do not create a local file recording ' \
|
36
|
+
'the event',
|
37
|
+
'-f, --format=STRING output format']
|
38
|
+
end
|
39
|
+
|
40
|
+
def postscript
|
41
|
+
"View events in detail using the 'query' command with the " \
|
42
|
+
"'events()' function."
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative './base'
|
2
|
+
|
3
|
+
# Define the cloud integration command.
|
4
|
+
#
|
5
|
+
class WavefrontCommandIntegration < WavefrontCommandBase
|
6
|
+
def description
|
7
|
+
'view and manage cloud integrations'
|
8
|
+
end
|
9
|
+
|
10
|
+
def sdk_file
|
11
|
+
'cloudintegration'
|
12
|
+
end
|
13
|
+
|
14
|
+
def sdk_class
|
15
|
+
'CloudIntegration'
|
16
|
+
end
|
17
|
+
|
18
|
+
def _commands
|
19
|
+
["list #{CMN} [-l] [-f format] [-o offset] [-L limit]",
|
20
|
+
"describe #{CMN} [-f format] <id>",
|
21
|
+
"delete #{CMN} <id>",
|
22
|
+
"undelete #{CMN} <id>",
|
23
|
+
"import #{CMN} <file>"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def _options
|
27
|
+
[common_options,
|
28
|
+
'-l, --long list integrations in detail',
|
29
|
+
'-o, --offset=n start from nth integration',
|
30
|
+
'-L, --limit=COUNT number of integrations to list',
|
31
|
+
'-f, --format=STRING output format']
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative './base'
|
2
|
+
|
3
|
+
# Define the external link command.
|
4
|
+
#
|
5
|
+
class WavefrontCommandLink < WavefrontCommandBase
|
6
|
+
def description
|
7
|
+
'view and manage external links'
|
8
|
+
end
|
9
|
+
|
10
|
+
def sdk_file
|
11
|
+
'externallink'
|
12
|
+
end
|
13
|
+
|
14
|
+
def sdk_class
|
15
|
+
'ExternalLink'
|
16
|
+
end
|
17
|
+
|
18
|
+
def _commands
|
19
|
+
["list #{CMN} [-l] [-f format] [-o offset] [-L limit]",
|
20
|
+
"describe #{CMN} [-f format] <id>",
|
21
|
+
"delete #{CMN} <id>",
|
22
|
+
"import #{CMN} <file>",
|
23
|
+
"update #{CMN} <key=value> <id>"
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
def _options
|
28
|
+
[common_options,
|
29
|
+
'-l, --long list external links in detail',
|
30
|
+
'-o, --offset=n start from nth external link',
|
31
|
+
'-L, --limit=COUNT number of external link to list',
|
32
|
+
'-f, --format=STRING output format']
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative './base'
|
2
|
+
|
3
|
+
# Define the message command.
|
4
|
+
#
|
5
|
+
class WavefrontCommandMessage < WavefrontCommandBase
|
6
|
+
def description
|
7
|
+
'read and mark user messages'
|
8
|
+
end
|
9
|
+
|
10
|
+
def _commands
|
11
|
+
["list #{CMN} [-l] [-f format] [-o offset] [-L limit] [-a]",
|
12
|
+
"mark #{CMN} [-f format] <id>"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def _options
|
16
|
+
[common_options,
|
17
|
+
'-l, --long list messages in detail',
|
18
|
+
'-o, --offset=n start from nth message',
|
19
|
+
'-L, --limit=COUNT number of messages to list',
|
20
|
+
'-a, --all list all messages, not just unread',
|
21
|
+
'-f, --format=STRING output format']
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative './base'
|
2
|
+
|
3
|
+
# Define the metric command.
|
4
|
+
#
|
5
|
+
class WavefrontCommandMetric < WavefrontCommandBase
|
6
|
+
def description
|
7
|
+
'view metrics'
|
8
|
+
end
|
9
|
+
|
10
|
+
def _commands
|
11
|
+
["describe #{CMN} [-f format] [-o offset] [-g glob...] <metric>"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def _options
|
15
|
+
[common_options,
|
16
|
+
'-o, --offset=STRING value to start from if results > 1000',
|
17
|
+
'-g, --glob=STRING return sources matching this pattern',
|
18
|
+
'-f, --format=STRING output format']
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative './base'
|
2
|
+
|
3
|
+
# Define the proxy command.
|
4
|
+
#
|
5
|
+
class WavefrontCommandProxy < WavefrontCommandBase
|
6
|
+
def description
|
7
|
+
'view and manage Wavefront proxies'
|
8
|
+
end
|
9
|
+
|
10
|
+
def _commands
|
11
|
+
["list #{CMN} [-l] [-f format] [-o offset] [-L limit]",
|
12
|
+
"describe #{CMN} [-f format] <id>",
|
13
|
+
"delete #{CMN} <id>",
|
14
|
+
"undelete #{CMN} <id>",
|
15
|
+
"rename #{CMN} <id> <name>"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def _options
|
19
|
+
[common_options,
|
20
|
+
'-l, --long list proxies in detail',
|
21
|
+
'-o, --offset=n start from nth proxy',
|
22
|
+
'-f, --format=STRING output format',
|
23
|
+
'-L, --limit=COUNT number of proxies to list']
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative './base'
|
2
|
+
|
3
|
+
# Define the query command.
|
4
|
+
#
|
5
|
+
class WavefrontCommandQuery < WavefrontCommandBase
|
6
|
+
def description
|
7
|
+
'query the Wavefront API'
|
8
|
+
end
|
9
|
+
|
10
|
+
def _commands
|
11
|
+
["#{CMN} [-g granularity] [-s time] [-e time] [-f format] " \
|
12
|
+
'[-ivO] [-S mode] [-N name] [-p points] <query>',
|
13
|
+
"raw #{CMN} [-H host] [-s time] [-e time] [-f format] <metric>"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def _options
|
17
|
+
[common_options,
|
18
|
+
'-g, --granularity=STRING query granularity (d, h, m, or s)',
|
19
|
+
'-s, --start=TIME start of query window',
|
20
|
+
'-e, --end=TIME end of query window',
|
21
|
+
'-N, --name=STRING name identifying query',
|
22
|
+
'-p, --points=INTEGER maximum number of points to return',
|
23
|
+
'-i, --inclusive include matching series with no ' \
|
24
|
+
'points inside the query window',
|
25
|
+
'-v, --events include events for matching series',
|
26
|
+
'-S, --summarize=STRING summarization strategy for bucketing ' \
|
27
|
+
'points (mean, median, min, max, sum, count, last, first)',
|
28
|
+
'-O, --obsolete include metrics unreported for > 4 weeks',
|
29
|
+
'-H, --host=STRING host or source to query on',
|
30
|
+
'-f, --format=STRING output format']
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative './base'
|
2
|
+
|
3
|
+
# Define the saved search command.
|
4
|
+
#
|
5
|
+
class WavefrontCommandSavedsearch < WavefrontCommandBase
|
6
|
+
def description
|
7
|
+
'view and manage saved searches'
|
8
|
+
end
|
9
|
+
|
10
|
+
def sdk_file
|
11
|
+
'savedsearch'
|
12
|
+
end
|
13
|
+
|
14
|
+
def sdk_class
|
15
|
+
'SavedSearch'
|
16
|
+
end
|
17
|
+
|
18
|
+
def _commands
|
19
|
+
["list #{CMN} [-l] [-f format] [-o offset] [-L limit]",
|
20
|
+
"describe #{CMN} [-f format] <id>",
|
21
|
+
"delete #{CMN} <id>",
|
22
|
+
"import #{CMN} <file>"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def _options
|
26
|
+
[common_options,
|
27
|
+
'-l, --long list saved searches in detail',
|
28
|
+
'-o, --offset=n start from nth saved search',
|
29
|
+
'-L, --limit=COUNT number of saved searches to list',
|
30
|
+
'-f, --format=STRING output format']
|
31
|
+
end
|
32
|
+
end
|