Class: Sidekiq::TUI::Tabs::Home
Constant Summary
Constants inherited
from BaseTab
BaseTab::NUMERIC_SEPARATORS
Constants included
from Controls
Controls::GLOBAL, Controls::SHARED
Instance Attribute Summary
Attributes inherited from BaseTab
#data, #name
Instance Method Summary
collapse
Methods inherited from BaseTab
#chart_y_axis, #each_selection, #error, #error=, #filtering?, #format_memory, #initialize, #navigate_row, #next_page, #number_with_delimiter, #prev_page, #refresh_data_for_stats, #render_kv_section, #render_stats_section, #render_table, #reset_data, #selected?, #stats_content_split, #striped_rows, #t, #toggle_select
Methods included from Controls
#controls, #features
Instance Method Details
#refresh_data ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/sidekiq/tui/tabs/home.rb', line 7
def refresh_data
refresh_data_for_stats
stats = Sidekiq::Stats.new
@data[:chart] ||= {
previous_stats: {
processed: stats.processed,
failed: stats.failed
},
deltas: {
processed: Array.new(50, 0),
failed: Array.new(50, 0)
}
}
processed_delta = stats.processed - @data[:chart][:previous_stats][:processed]
failed_delta = stats.failed - @data[:chart][:previous_stats][:failed]
@data[:chart][:deltas][:processed].shift
@data[:chart][:deltas][:processed].push(processed_delta)
@data[:chart][:deltas][:failed].shift
@data[:chart][:deltas][:failed].push(failed_delta)
@data[:chart][:previous_stats] = {
processed: stats.processed,
failed: stats.failed
}
redis_info = Sidekiq.default_configuration.redis_info
@data[:redis_info] = {
version: redis_info["redis_version"] || "N/A",
uptime_days: redis_info["uptime_in_days"] || "N/A",
connected_clients: redis_info["connected_clients"] || "N/A",
used_memory: redis_info["used_memory_human"] || "N/A",
peak_memory: redis_info["used_memory_peak_human"] || "N/A"
}
end
|
#render(tui, frame, area) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/sidekiq/tui/tabs/home.rb', line 46
def render(tui, frame, area)
chunks = tui.layout_split(
area,
direction: :vertical,
constraints: [
tui.constraint_length(4), tui.constraint_fill(1), tui.constraint_length(4) ]
)
render_stats_section(tui, frame, chunks[0])
render_chart_section(tui, frame, chunks[1])
render_redis_info_section(tui, frame, chunks[2])
end
|
#render_chart_section(tui, frame, area) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/sidekiq/tui/tabs/home.rb', line 62
def render_chart_section(tui, frame, area)
max_value = [@data[:chart][:deltas][:processed].max, @data[:chart][:deltas][:failed].max, 1].max
y_max = [max_value, 5].max
datasets = {processed: :green, failed: :red}.map { |key, color|
data = @data[:chart][:deltas][key].each_with_index.map { |value, idx| [idx.to_f, value.to_f] }
tui.dataset(
name: "",
data: data,
style: tui.style(fg: color),
marker: :dot,
graph_type: :line
)
}
beacon_pulse = (Time.now.to_i % 2 == 0) ? "●" : " "
chart = tui.chart(
datasets: datasets,
x_axis: tui.axis(
bounds: [0.0, 49.0],
labels: [],
style: tui.style(fg: :white)
),
y_axis: chart_y_axis(tui, y_max),
block: tui.block(
title: "Dashboard #{beacon_pulse}",
borders: [:all]
)
)
frame.render_widget(chart, area)
end
|
#render_redis_info_section(tui, frame, area) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/sidekiq/tui/tabs/home.rb', line 96
def render_redis_info_section(tui, frame, area)
redis_info = @data[:redis_info]
uptime_value = (redis_info[:uptime_days] == "N/A") ? "N/A" : "#{redis_info[:uptime_days]} days"
keys = ["Version", "Uptime", "Connected Clients", "Memory Usage", "Peak Memory"]
values = [
redis_info[:version],
uptime_value,
redis_info[:connected_clients],
redis_info[:used_memory],
redis_info[:peak_memory]
]
render_kv_section(tui, frame, area, title: "Redis Information", keys:, values:, width: 18)
end
|