Class: RailsServerMonitor::Warnings::HighCpuUsageComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/rails_server_monitor/warnings/high_cpu_usage_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctx:) ⇒ HighCpuUsageComponent

Returns a new instance of HighCpuUsageComponent.



7
8
9
# File 'app/components/rails_server_monitor/warnings/high_cpu_usage_component.rb', line 7

def initialize(ctx:)
  @ctx = ctx
end

Instance Attribute Details

#ctxObject (readonly)

Returns the value of attribute ctx.



6
7
8
# File 'app/components/rails_server_monitor/warnings/high_cpu_usage_component.rb', line 6

def ctx
  @ctx
end

Instance Method Details

#configObject



19
20
21
# File 'app/components/rails_server_monitor/warnings/high_cpu_usage_component.rb', line 19

def config
  RailsServerMonitor.config
end

#scopeObject



11
12
13
14
15
16
17
# File 'app/components/rails_server_monitor/warnings/high_cpu_usage_component.rb', line 11

def scope
  @scope ||= RailsServerMonitor::ServerSnapshot
               .includes(:rails_server_monitor_server)
               .where("cpu_usage_percentage >= ?", config.high_cpu_usage_threshold)
               .where("created_at > ?", 3.days.ago)
               .limit(100)
end