Class: MistApi::StatsMxedgeCpuStat

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/stats_mxedge_cpu_stat.rb

Overview

CPU/core stats list

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(cpus = SKIP, idle = SKIP, interrupt = SKIP, system = SKIP, usage = SKIP, user = SKIP) ⇒ StatsMxedgeCpuStat

Returns a new instance of StatsMxedgeCpuStat.



65
66
67
68
69
70
71
72
73
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 65

def initialize(cpus = SKIP, idle = SKIP, interrupt = SKIP, system = SKIP,
               usage = SKIP, user = SKIP)
  @cpus = cpus unless cpus == SKIP
  @idle = idle unless idle == SKIP
  @interrupt = interrupt unless interrupt == SKIP
  @system = system unless system == SKIP
  @usage = usage unless usage == SKIP
  @user = user unless user == SKIP
end

Instance Attribute Details

#cpusHash[String, CpuStat]

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 14

def cpus
  @cpus
end

#idleInteger

Percentage of Idle, Idle/(Idle + Busy) since last sampling

Returns:

  • (Integer)


18
19
20
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 18

def idle
  @idle
end

#interruptInteger

Percentage of Interrupt, (Irq + SoftIrq)/(Idle + Busy) since last sampling

Returns:

  • (Integer)


22
23
24
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 22

def interrupt
  @interrupt
end

#systemInteger

Percentage of System, System/(Idle + Busy) since last sampling

Returns:

  • (Integer)


26
27
28
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 26

def system
  @system
end

#usageInteger

Percentage of load, Busy/(Idle + Busy) since last sampling

Returns:

  • (Integer)


30
31
32
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 30

def usage
  @usage
end

#userInteger

Percentage of User, User/(Idle + Busy) since last sampling

Returns:

  • (Integer)


34
35
36
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 34

def user
  @user
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 76

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  cpus = CpuStat.from_hash(hash['cpus']) if hash['cpus']

  cpus = SKIP unless hash.key?('cpus')
  idle = hash.key?('idle') ? hash['idle'] : SKIP
  interrupt = hash.key?('interrupt') ? hash['interrupt'] : SKIP
  system = hash.key?('system') ? hash['system'] : SKIP
  usage = hash.key?('usage') ? hash['usage'] : SKIP
  user = hash.key?('user') ? hash['user'] : SKIP

  # Create object from extracted values.
  StatsMxedgeCpuStat.new(cpus,
                         idle,
                         interrupt,
                         system,
                         usage,
                         user)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['cpus'] = 'cpus'
  @_hash['idle'] = 'idle'
  @_hash['interrupt'] = 'interrupt'
  @_hash['system'] = 'system'
  @_hash['usage'] = 'usage'
  @_hash['user'] = 'user'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
58
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 49

def self.optionals
  %w[
    cpus
    idle
    interrupt
    system
    usage
    user
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



106
107
108
109
110
111
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 106

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} cpus: #{@cpus.inspect}, idle: #{@idle.inspect}, interrupt:"\
  " #{@interrupt.inspect}, system: #{@system.inspect}, usage: #{@usage.inspect}, user:"\
  " #{@user.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



99
100
101
102
103
# File 'lib/mist_api/models/stats_mxedge_cpu_stat.rb', line 99

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} cpus: #{@cpus}, idle: #{@idle}, interrupt: #{@interrupt}, system:"\
  " #{@system}, usage: #{@usage}, user: #{@user}>"
end