Class: Railswatch::Widgets::MemoryUsage

Inherits:
ResourceChart show all
Defined in:
lib/railswatch/widgets/resource_chart.rb

Instance Attribute Summary

Attributes inherited from ResourceChart

#key, #server, #type

Attributes inherited from Chart

#description, #legend, #subtitle, #units

Attributes inherited from Base

#datasource

Instance Method Summary collapse

Methods inherited from ResourceChart

#data, #id, #signal

Methods inherited from Chart

#data, #id, #to_partial_path, #type

Methods inherited from Base

#to_partial_path

Constructor Details

#initialize(server) ⇒ MemoryUsage

Returns a new instance of MemoryUsage.



63
64
65
66
67
68
69
70
71
72
# File 'lib/railswatch/widgets/resource_chart.rb', line 63

def initialize(server)
  super(
    server,
    key: :memory,
    type: 'Usage',
    subtitle: 'Memory',
    description: 'App memory usage',
    legend: 'Usage',
  )
end

Instance Method Details

#format(measurement) ⇒ Object



74
75
76
# File 'lib/railswatch/widgets/resource_chart.rb', line 74

def format(measurement)
  measurement.to_f.round(2)
end

#measureObject



78
79
80
81
82
83
# File 'lib/railswatch/widgets/resource_chart.rb', line 78

def measure
  GetProcessMem.new.bytes
rescue StandardError => e
  ::Rails.logger.error "Error fetching memory usage: #{e.message}"
  0
end