Class: RailsServerMonitor::Warnings::LowMemoryComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- RailsServerMonitor::Warnings::LowMemoryComponent
- Defined in:
- app/components/rails_server_monitor/warnings/low_memory_component.rb
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(ctx:) ⇒ LowMemoryComponent
constructor
A new instance of LowMemoryComponent.
- #max_memory_usage ⇒ Object
- #scope ⇒ Object
Constructor Details
#initialize(ctx:) ⇒ LowMemoryComponent
Returns a new instance of LowMemoryComponent.
7 8 9 |
# File 'app/components/rails_server_monitor/warnings/low_memory_component.rb', line 7 def initialize(ctx:) @ctx = ctx end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
6 7 8 |
# File 'app/components/rails_server_monitor/warnings/low_memory_component.rb', line 6 def ctx @ctx end |
Instance Method Details
#config ⇒ Object
19 20 21 |
# File 'app/components/rails_server_monitor/warnings/low_memory_component.rb', line 19 def config RailsServerMonitor.config end |
#max_memory_usage ⇒ Object
23 24 25 |
# File 'app/components/rails_server_monitor/warnings/low_memory_component.rb', line 23 def max_memory_usage 100 - config.low_memory_threshold end |
#scope ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/components/rails_server_monitor/warnings/low_memory_component.rb', line 11 def scope @scope ||= RailsServerMonitor::ServerSnapshot .includes(:rails_server_monitor_server) .where("ram_usage_percentage >= ?", max_memory_usage) .where("created_at > ?", 3.days.ago) .limit(100) end |