Class: Xshellz::SandboxStats
- Inherits:
-
Struct
- Object
- Struct
- Xshellz::SandboxStats
- Defined in:
- lib/xshellz/models.rb
Overview
Live resource usage for a running sandbox (+Sandbox#stats+), mirroring
the control plane's wire fields. *_allowed_* fields are the plan
ceilings so used/allowed gauges need no second call.
Instance Attribute Summary collapse
-
#blk_read_mb ⇒ Object
Returns the value of attribute blk_read_mb.
-
#blk_write_mb ⇒ Object
Returns the value of attribute blk_write_mb.
-
#cpu_allowed_vcpus ⇒ Object
Returns the value of attribute cpu_allowed_vcpus.
-
#cpu_percent ⇒ Object
Returns the value of attribute cpu_percent.
-
#cpu_throttled_periods ⇒ Object
Returns the value of attribute cpu_throttled_periods.
-
#disk_allowed_mb ⇒ Object
Returns the value of attribute disk_allowed_mb.
-
#disk_used_mb ⇒ Object
Returns the value of attribute disk_used_mb.
-
#mem_allowed_mb ⇒ Object
Returns the value of attribute mem_allowed_mb.
-
#mem_limit_mb ⇒ Object
Returns the value of attribute mem_limit_mb.
-
#mem_used_mb ⇒ Object
Returns the value of attribute mem_used_mb.
-
#net_rx_mb ⇒ Object
Returns the value of attribute net_rx_mb.
-
#net_tx_mb ⇒ Object
Returns the value of attribute net_tx_mb.
-
#pids_allowed ⇒ Object
Returns the value of attribute pids_allowed.
-
#pids_current ⇒ Object
Returns the value of attribute pids_current.
Class Method Summary collapse
-
.from_api(payload) ⇒ Object
Build a
SandboxStatsfrom the API's JSON payload (tolerant of missing keys).
Instance Attribute Details
#blk_read_mb ⇒ Object
Returns the value of attribute blk_read_mb
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def blk_read_mb @blk_read_mb end |
#blk_write_mb ⇒ Object
Returns the value of attribute blk_write_mb
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def blk_write_mb @blk_write_mb end |
#cpu_allowed_vcpus ⇒ Object
Returns the value of attribute cpu_allowed_vcpus
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def cpu_allowed_vcpus @cpu_allowed_vcpus end |
#cpu_percent ⇒ Object
Returns the value of attribute cpu_percent
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def cpu_percent @cpu_percent end |
#cpu_throttled_periods ⇒ Object
Returns the value of attribute cpu_throttled_periods
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def cpu_throttled_periods @cpu_throttled_periods end |
#disk_allowed_mb ⇒ Object
Returns the value of attribute disk_allowed_mb
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def disk_allowed_mb @disk_allowed_mb end |
#disk_used_mb ⇒ Object
Returns the value of attribute disk_used_mb
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def disk_used_mb @disk_used_mb end |
#mem_allowed_mb ⇒ Object
Returns the value of attribute mem_allowed_mb
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def mem_allowed_mb @mem_allowed_mb end |
#mem_limit_mb ⇒ Object
Returns the value of attribute mem_limit_mb
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def mem_limit_mb @mem_limit_mb end |
#mem_used_mb ⇒ Object
Returns the value of attribute mem_used_mb
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def mem_used_mb @mem_used_mb end |
#net_rx_mb ⇒ Object
Returns the value of attribute net_rx_mb
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def net_rx_mb @net_rx_mb end |
#net_tx_mb ⇒ Object
Returns the value of attribute net_tx_mb
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def net_tx_mb @net_tx_mb end |
#pids_allowed ⇒ Object
Returns the value of attribute pids_allowed
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def pids_allowed @pids_allowed end |
#pids_current ⇒ Object
Returns the value of attribute pids_current
60 61 62 |
# File 'lib/xshellz/models.rb', line 60 def pids_current @pids_current end |
Class Method Details
.from_api(payload) ⇒ Object
Build a SandboxStats from the API's JSON payload (tolerant of
missing keys).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/xshellz/models.rb', line 79 def self.from_api(payload) payload ||= {} new( mem_used_mb: (payload["mem_used_mb"] || 0).to_i, mem_limit_mb: (payload["mem_limit_mb"] || 0).to_i, mem_allowed_mb: (payload["mem_allowed_mb"] || 0).to_i, cpu_percent: (payload["cpu_percent"] || 0.0).to_f, cpu_allowed_vcpus: (payload["cpu_allowed_vcpus"] || 0.0).to_f, cpu_throttled_periods: (payload["cpu_throttled_periods"] || 0).to_i, pids_current: (payload["pids_current"] || 0).to_i, pids_allowed: (payload["pids_allowed"] || 0).to_i, disk_used_mb: (payload["disk_used_mb"] || 0).to_i, disk_allowed_mb: (payload["disk_allowed_mb"] || 0).to_i, net_rx_mb: (payload["net_rx_mb"] || 0).to_i, net_tx_mb: (payload["net_tx_mb"] || 0).to_i, blk_read_mb: (payload["blk_read_mb"] || 0).to_i, blk_write_mb: (payload["blk_write_mb"] || 0).to_i ) end |