Class: RailsPulse::Dashboard::StoragePressure

Inherits:
Object
  • Object
show all
Defined in:
app/models/rails_pulse/dashboard/storage_pressure.rb

Constant Summary collapse

STALE_WARNING_THRESHOLD =
2.hours
STALE_CRITICAL_THRESHOLD =
24.hours

Instance Method Summary collapse

Constructor Details

#initializeStoragePressure

Returns a new instance of StoragePressure.



7
8
9
# File 'app/models/rails_pulse/dashboard/storage_pressure.rb', line 7

def initialize
  @config = RailsPulse.configuration
end

Instance Method Details

#pressure_itemsObject



11
12
13
# File 'app/models/rails_pulse/dashboard/storage_pressure.rb', line 11

def pressure_items
  summary_staleness_items + stuck_records_items + sub_hour_retention_items
end

#storage_countsObject



15
16
17
18
19
20
21
# File 'app/models/rails_pulse/dashboard/storage_pressure.rb', line 15

def storage_counts
  items    = pressure_items
  critical = items.any? { |i| i[:severity] == :critical } ? 1 : 0
  slow     = (critical.zero? && items.any? { |i| i[:severity] == :warning }) ? 1 : 0
  healthy  = (critical.zero? && slow.zero?) ? 1 : 0
  { healthy: healthy, slow: slow, critical: critical }
end