Class: RailsPerformance::SystemMonitor::DiskUsage
- Inherits:
-
ResourceChart
- Object
- Struct
- ResourceChart
- RailsPerformance::SystemMonitor::DiskUsage
- Defined in:
- lib/rails_performance/system_monitor/resource_chart.rb
Instance Attribute Summary
Attributes inherited from ResourceChart
#description, #key, #legend, #server, #subtitle, #type
Instance Method Summary collapse
- #format(measurement) ⇒ Object
-
#initialize(server) ⇒ DiskUsage
constructor
A new instance of DiskUsage.
- #measure ⇒ Object
Methods inherited from ResourceChart
Constructor Details
#initialize(server) ⇒ DiskUsage
Returns a new instance of DiskUsage.
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rails_performance/system_monitor/resource_chart.rb', line 76 def initialize server super( server:, key: :disk, type: "Usage", subtitle: "Storage", description: "Available storage size (local disk size)", legend: "Usage", ) end |
Instance Method Details
#format(measurement) ⇒ Object
87 88 89 |
# File 'lib/rails_performance/system_monitor/resource_chart.rb', line 87 def format measurement measurement["available"].to_f.round(2) end |
#measure ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/rails_performance/system_monitor/resource_chart.rb', line 91 def measure path = "/" stat = Sys::Filesystem.stat(path) { available: stat.blocks_available * stat.block_size, total: stat.blocks * stat.block_size, used: (stat.blocks - stat.blocks_available) * stat.block_size } rescue => e ::Rails.logger.error "Error fetching disk space: #{e.}" {available: 0, total: 0, used: 0} end |