Class: RorVsWild::Metrics
- Inherits:
-
Object
- Object
- RorVsWild::Metrics
- Defined in:
- lib/rorvswild/metrics.rb,
lib/rorvswild/metrics/cpu.rb,
lib/rorvswild/metrics/memory.rb,
lib/rorvswild/metrics/storage.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#cpu ⇒ Object
readonly
Returns the value of attribute cpu.
-
#memory ⇒ Object
readonly
Returns the value of attribute memory.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#initialize ⇒ Metrics
constructor
A new instance of Metrics.
- #to_h ⇒ Object
- #update ⇒ Object
- #update_every_minute ⇒ Object
Constructor Details
#initialize ⇒ Metrics
Returns a new instance of Metrics.
5 6 7 8 9 10 |
# File 'lib/rorvswild/metrics.rb', line 5 def initialize @updated_at = nil @cpu = RorVsWild::Metrics::Cpu.new @memory = RorVsWild::Metrics::Memory.new @storage = RorVsWild::Metrics::Storage.new end |
Instance Attribute Details
#cpu ⇒ Object (readonly)
Returns the value of attribute cpu.
3 4 5 |
# File 'lib/rorvswild/metrics.rb', line 3 def cpu @cpu end |
#memory ⇒ Object (readonly)
Returns the value of attribute memory.
3 4 5 |
# File 'lib/rorvswild/metrics.rb', line 3 def memory @memory end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
3 4 5 |
# File 'lib/rorvswild/metrics.rb', line 3 def storage @storage end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
3 4 5 |
# File 'lib/rorvswild/metrics.rb', line 3 def updated_at @updated_at end |
Instance Method Details
#to_h ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rorvswild/metrics.rb', line 26 def to_h { hostname: Host.name, os: Host.os, cpu_user: cpu.user, cpu_system: cpu.system, cpu_idle: cpu.idle, cpu_waiting: cpu.waiting, cpu_stolen: cpu.stolen, cpu_count: cpu.count, load_average: cpu.load_average, ram_total: memory.ram_total, ram_free: memory.ram_free, ram_used: memory.ram_used, ram_cached: memory.ram_cached, swap_total: memory.swap_total, swap_used: memory.swap_used, swap_free: memory.swap_free, storage_total: storage.total, storage_used: storage.used, storage_free: storage.free, } end |
#update ⇒ Object
12 13 14 15 16 |
# File 'lib/rorvswild/metrics.rb', line 12 def update cpu.update memory.update storage.update end |
#update_every_minute ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/rorvswild/metrics.rb', line 18 def update_every_minute return unless Host.os.include?("Linux") if !@updated_at || @updated_at.min != Time.now.min @updated_at = Time.now update end end |