Class: RailsServerMonitor::Warnings::LowDiskSpaceComponent

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#ctxObject (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

#configObject



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

def config
  RailsServerMonitor.config
end

#max_space_usageObject



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

#scopeObject



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