Class: WavefrontDisplay::Alert
- Inherits:
-
Base
- Object
- Base
- WavefrontDisplay::Alert
show all
- Defined in:
- lib/wavefront-cli/display/alert.rb
Overview
Format human-readable output for alerts.
Constant Summary
WavefrontCli::Constants::ALL_PAGE_SIZE, WavefrontCli::Constants::DEFAULT_CONFIG, WavefrontCli::Constants::DEFAULT_OPTS, WavefrontCli::Constants::EVENT_STATE_DIR, WavefrontCli::Constants::HUMAN_TIME_FORMAT, WavefrontCli::Constants::HUMAN_TIME_FORMAT_MS, WavefrontCli::Constants::SEARCH_SPLIT
Instance Attribute Summary
Attributes inherited from Base
#data, #options, #raw
Instance Method Summary
collapse
Methods inherited from Base
#_prioritize_keys, #display_brief_freetext_results, #do_delete, #do_import, #do_list_fields, #do_search, #do_search_brief, #do_search_fields, #do_tag_add, #do_tag_clear, #do_tag_delete, #do_tag_pathsearch, #do_tag_set, #do_tags, #do_undelete, #drop_fields, #filter_data, #filter_fields_as_arr, #freetext_keys, #friendly_name, #human_time, #index_of_final_item, #initialize, #key_width, #long_output, #multicolumn, #pagination_line, #prioritize_keys, #priority_keys, #quoted, #readable_time, #readable_time_arr, #run, #run_error, #run_list, #run_search, #search_display_keys, #search_identifier_key, #time_formats
Instance Method Details
#do_affected_hosts ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/wavefront-cli/display/alert.rb', line 78
def do_affected_hosts
if data == [nil]
puts 'Alert event is not attached to any hosts.'
else
long_output
end
end
|
#do_describe ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/wavefront-cli/display/alert.rb', line 30
def do_describe
readable_time(:created, :lastProcessedMillis,
:lastNotificationMillis, :createdEpochMillis,
:updatedEpochMillis, :updated)
drop_fields(:conditionQBEnabled, :displayExpressionQBEnabled,
:displayExpressionQBSerialization)
long_output
end
|
#do_firing ⇒ Object
20
21
22
23
|
# File 'lib/wavefront-cli/display/alert.rb', line 20
def do_firing
readable_time_arr(:time)
multicolumn(:id, :time, :name)
end
|
#do_history ⇒ Object
39
40
41
42
|
# File 'lib/wavefront-cli/display/alert.rb', line 39
def do_history
drop_fields(:inTrash)
long_output
end
|
#do_latest ⇒ Object
53
54
55
|
# File 'lib/wavefront-cli/display/alert.rb', line 53
def do_latest
puts data.max
end
|
#do_list ⇒ Object
10
11
12
13
14
|
# File 'lib/wavefront-cli/display/alert.rb', line 10
def do_list
long_output %i[id minutes target status tags hostsUsed
condition displayExpression severity
additionalInformation]
end
|
#do_list_brief ⇒ Object
16
17
18
|
# File 'lib/wavefront-cli/display/alert.rb', line 16
def do_list_brief
multicolumn(:id, :status, :name)
end
|
#do_queries ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/wavefront-cli/display/alert.rb', line 66
def do_queries
if options[:brief]
multicolumn(:condition)
else
multicolumn(:id, :condition)
end
end
|
#do_snooze ⇒ Object
44
45
46
47
|
# File 'lib/wavefront-cli/display/alert.rb', line 44
def do_snooze
w = options[:time] ? "for #{options[:time]} seconds" : 'indefinitely'
puts "Snoozed alert '#{options[:'<id>']}' #{w}."
end
|
#do_snoozed ⇒ Object
25
26
27
28
|
# File 'lib/wavefront-cli/display/alert.rb', line 25
def do_snoozed
readable_time_arr(:time)
multicolumn(:id, :time, :name)
end
|
#do_summary ⇒ Object
57
58
59
60
61
62
63
64
|
# File 'lib/wavefront-cli/display/alert.rb', line 57
def do_summary
kw = data.keys.map(&:size).max + 2
data.sort.each do |k, v|
next if v.zero? && !options[:all]
puts format("%-#{kw}<key>s%<value>s", key: k, value: v)
end
end
|
#do_unsnooze ⇒ Object
49
50
51
|
# File 'lib/wavefront-cli/display/alert.rb', line 49
def do_unsnooze
puts "Unsnoozed alert '#{options[:'<id>']}'."
end
|
#do_version ⇒ Object
74
75
76
|
# File 'lib/wavefront-cli/display/alert.rb', line 74
def do_version
puts data.max
end
|