wavefront-cli 2.18.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +7 -0
  4. data/.travis.yml +4 -5
  5. data/HISTORY.md +20 -1
  6. data/README.md +79 -29
  7. data/lib/wavefront-cli/base.rb +26 -2
  8. data/lib/wavefront-cli/commands/alert.rb +10 -10
  9. data/lib/wavefront-cli/commands/base.rb +15 -2
  10. data/lib/wavefront-cli/commands/cloudintegration.rb +3 -3
  11. data/lib/wavefront-cli/commands/config.rb +2 -1
  12. data/lib/wavefront-cli/commands/dashboard.rb +8 -6
  13. data/lib/wavefront-cli/commands/derivedmetric.rb +5 -5
  14. data/lib/wavefront-cli/commands/event.rb +3 -3
  15. data/lib/wavefront-cli/commands/integration.rb +5 -5
  16. data/lib/wavefront-cli/commands/link.rb +3 -3
  17. data/lib/wavefront-cli/commands/message.rb +2 -2
  18. data/lib/wavefront-cli/commands/metric.rb +1 -1
  19. data/lib/wavefront-cli/commands/notificant.rb +3 -3
  20. data/lib/wavefront-cli/commands/proxy.rb +3 -3
  21. data/lib/wavefront-cli/commands/query.rb +3 -3
  22. data/lib/wavefront-cli/commands/savedsearch.rb +3 -3
  23. data/lib/wavefront-cli/commands/settings.rb +22 -0
  24. data/lib/wavefront-cli/commands/source.rb +3 -3
  25. data/lib/wavefront-cli/commands/user.rb +4 -4
  26. data/lib/wavefront-cli/commands/usergroup.rb +5 -8
  27. data/lib/wavefront-cli/commands/webhook.rb +3 -3
  28. data/lib/wavefront-cli/commands/window.rb +3 -3
  29. data/lib/wavefront-cli/commands/write.rb +6 -4
  30. data/lib/wavefront-cli/config.rb +14 -0
  31. data/lib/wavefront-cli/controller.rb +2 -0
  32. data/lib/wavefront-cli/dashboard.rb +133 -14
  33. data/lib/wavefront-cli/display/base.rb +28 -7
  34. data/lib/wavefront-cli/display/dashboard.rb +32 -8
  35. data/lib/wavefront-cli/display/distribution.rb +4 -1
  36. data/lib/wavefront-cli/display/printer/long.rb +149 -140
  37. data/lib/wavefront-cli/display/printer/terse.rb +19 -42
  38. data/lib/wavefront-cli/display/query.rb +6 -0
  39. data/lib/wavefront-cli/display/settings.rb +21 -0
  40. data/lib/wavefront-cli/display/write.rb +12 -5
  41. data/lib/wavefront-cli/event.rb +1 -1
  42. data/lib/wavefront-cli/exception.rb +1 -0
  43. data/lib/wavefront-cli/settings.rb +37 -0
  44. data/lib/wavefront-cli/stdlib/array.rb +20 -0
  45. data/lib/wavefront-cli/stdlib/string.rb +8 -0
  46. data/lib/wavefront-cli/user.rb +1 -1
  47. data/lib/wavefront-cli/version.rb +1 -1
  48. data/lib/wavefront-cli/write.rb +310 -10
  49. data/spec/.rubocop.yml +3 -0
  50. data/spec/spec_helper.rb +81 -1
  51. data/spec/wavefront-cli/alert_spec.rb +1 -0
  52. data/spec/wavefront-cli/cloudintegration_spec.rb +1 -0
  53. data/spec/wavefront-cli/dashboard_spec.rb +47 -4
  54. data/spec/wavefront-cli/derivedmetric_spec.rb +1 -0
  55. data/spec/wavefront-cli/display/base_spec.rb +16 -9
  56. data/spec/wavefront-cli/display/printer/long_spec.rb +75 -106
  57. data/spec/wavefront-cli/display/printer/terse_spec.rb +33 -21
  58. data/spec/wavefront-cli/event_spec.rb +1 -0
  59. data/spec/wavefront-cli/externallink_spec.rb +1 -0
  60. data/spec/wavefront-cli/integration_spec.rb +1 -0
  61. data/spec/wavefront-cli/maintenancewindow_spec.rb +1 -0
  62. data/spec/wavefront-cli/proxy_spec.rb +2 -0
  63. data/spec/wavefront-cli/query_spec.rb +9 -0
  64. data/spec/wavefront-cli/resources/display/alert-human-long +24 -0
  65. data/spec/wavefront-cli/resources/display/alert-input.json +37 -0
  66. data/spec/wavefront-cli/resources/display/alerts-human-terse +9 -0
  67. data/spec/wavefront-cli/resources/display/alerts-input.json +1 -0
  68. data/spec/wavefront-cli/resources/display/user-human-long +19 -0
  69. data/spec/wavefront-cli/resources/display/user-human-long-no_sep +18 -0
  70. data/spec/wavefront-cli/resources/display/user-input.json +1 -0
  71. data/spec/wavefront-cli/resources/responses/README.md +2 -0
  72. data/spec/wavefront-cli/resources/responses/alert-list.json +1 -0
  73. data/spec/wavefront-cli/resources/responses/backups.json +1 -0
  74. data/spec/wavefront-cli/resources/responses/cloudintegration-list.json +1 -0
  75. data/spec/wavefront-cli/resources/responses/dashboard-list.json +1 -0
  76. data/spec/wavefront-cli/resources/responses/derivedmetric-list.json +1 -0
  77. data/spec/wavefront-cli/resources/responses/event-list.json +1 -0
  78. data/spec/wavefront-cli/resources/responses/integration-list.json +1 -0
  79. data/spec/wavefront-cli/resources/responses/link-list.json +1 -0
  80. data/spec/wavefront-cli/resources/responses/notificant-list.json +1 -0
  81. data/spec/wavefront-cli/resources/responses/proxy-list.json +1 -0
  82. data/spec/wavefront-cli/resources/responses/query-cpu.json +1 -0
  83. data/spec/wavefront-cli/resources/responses/savedsearch-list.json +1 -0
  84. data/spec/wavefront-cli/resources/responses/user-list.json +1 -0
  85. data/spec/wavefront-cli/resources/responses/usergroup-list.json +1 -0
  86. data/spec/wavefront-cli/resources/responses/webhook-list.json +1 -0
  87. data/spec/wavefront-cli/resources/responses/window-list.json +1 -0
  88. data/spec/wavefront-cli/savedsearch_spec.rb +1 -0
  89. data/spec/wavefront-cli/settings_spec.rb +19 -0
  90. data/spec/wavefront-cli/stdlib/array_spec.rb +20 -0
  91. data/spec/wavefront-cli/stdlib/string_spec.rb +13 -1
  92. data/spec/wavefront-cli/user_spec.rb +1 -0
  93. data/spec/wavefront-cli/usergroup_spec.rb +1 -0
  94. data/spec/wavefront-cli/webhook_spec.rb +1 -0
  95. data/spec/wavefront-cli/write_spec.rb +167 -0
  96. data/wavefront-cli.gemspec +3 -4
  97. metadata +65 -31
  98. data/.gitlab-ci.yml +0 -16
  99. data/lib/wavefront-cli/base_write.rb +0 -298
  100. data/lib/wavefront-cli/commands/report.rb +0 -37
  101. data/lib/wavefront-cli/display/printer/base.rb +0 -24
  102. data/lib/wavefront-cli/display/report.rb +0 -17
  103. data/lib/wavefront-cli/report.rb +0 -18
  104. data/spec/wavefront-cli/display/printer/base_spec.rb +0 -20
@@ -1,37 +0,0 @@
1
- require_relative 'base'
2
-
3
- # Define the report command.
4
- #
5
- class WavefrontCommandReport < WavefrontCommandBase
6
- def description
7
- 'send data directly to Wavefront'
8
- end
9
-
10
- def _commands
11
- ["point #{CMN} [-s time] [-H host] [-T tag...] [-iq] <metric> <value>",
12
- "file #{CMN} [-H host] [-F format] [-m metric] [-T tag...] " \
13
- '[-iq] <file>']
14
- end
15
-
16
- def _options
17
- [common_options,
18
- '-s, --time=TIME time of data point (omit to use ' \
19
- 'current time)',
20
- '-H, --host=STRING source host', \
21
- '-T, --tag=TAG point tag in key=value form',
22
- '-F, --infileformat=STRING format of input file or stdin',
23
- '-m, --metric=STRING the metric path to which contents of ' \
24
- 'a file will be assigned. If the file contains a metric name, ' \
25
- 'the two will be dot-concatenated, with this value first',
26
- '-i, --delta increment metric by given value',
27
- "-q, --quiet don't report the points sent summary " \
28
- '(unless there were errors)']
29
- end
30
-
31
- def postscript
32
- 'Files are whitespace separated, and fields can be defined ' \
33
- "with the '-F' option. Use 't' for timestamp, 'm' for metric " \
34
- "name, 'v' for value, 's' for source, and 'T' for tags. Put 'T' " \
35
- 'last.'.cmd_fold(TW, 0)
36
- end
37
- end
@@ -1,24 +0,0 @@
1
- module WavefrontDisplayPrinter
2
- #
3
- # Base class for the two printer classes
4
- #
5
- class Base
6
- attr_reader :out
7
-
8
- # Give it a key-value hash, and it will return the size of the first
9
- # column to use when formatting that data.
10
- #
11
- # @param hash [Hash] the data for which you need a column width
12
- # @param pad [Integer] the number of spaces you want between columns
13
- # @return [Integer] length of longest key + pad
14
- #
15
- def key_width(hash = {}, pad = 3)
16
- return 0 if hash.keys.empty?
17
- hash.keys.map(&:size).max + pad
18
- end
19
-
20
- def to_s
21
- out.join("\n")
22
- end
23
- end
24
- end
@@ -1,17 +0,0 @@
1
- require_relative 'base'
2
-
3
- module WavefrontDisplay
4
- #
5
- # Format human-readable output when writing points directly to
6
- # Wavefront.
7
- #
8
- class Report < Base
9
- def do_point
10
- puts 'Point received.' unless options[:quiet]
11
- end
12
-
13
- def do_file
14
- do_point
15
- end
16
- end
17
- end
@@ -1,18 +0,0 @@
1
- require_relative 'base_write'
2
-
3
- module WavefrontCli
4
- #
5
- # Write metrics direct to Wavefront. Sister of WavefrontCli::Write
6
- #
7
- class Report < BaseWrite
8
- def send_point(point)
9
- call_write(point)
10
- rescue Wavefront::Exception::InvalidEndpoint
11
- abort 'could not speak to API'
12
- end
13
-
14
- def open_connection; end
15
-
16
- def close_connection; end
17
- end
18
- end
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../../../../lib/wavefront-cli/display/printer/base'
4
- require_relative '../spec_helper'
5
-
6
- # Test base class
7
- #
8
- class WavefrontDisplayPrinterBase < MiniTest::Test
9
- attr_reader :wf
10
-
11
- def setup
12
- @wf = WavefrontDisplayPrinter::Base.new
13
- end
14
-
15
- def test_key_width
16
- assert_equal(wf.key_width, 0)
17
- assert_equal(wf.key_width(key1: 1, row2: 2, longrow: 3), 10)
18
- assert_equal(wf.key_width({ key1: 1, row2: 2, longrow: 3 }, 3), 10)
19
- end
20
- end