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