Class: OCI::Opsi::Models::HostCpuUsage

Inherits:
HostPerformanceMetricGroup show all
Defined in:
lib/oci/opsi/models/host_cpu_usage.rb

Overview

CPU Usage metric for the host

Constant Summary

Constants inherited from HostPerformanceMetricGroup

OCI::Opsi::Models::HostPerformanceMetricGroup::METRIC_NAME_ENUM

Instance Attribute Summary collapse

Attributes inherited from HostPerformanceMetricGroup

#metric_name, #time_collected

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from HostPerformanceMetricGroup

get_subtype

Constructor Details

#initialize(attributes = {}) ⇒ HostCpuUsage

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 103

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  attributes['metricName'] = 'HOST_CPU_USAGE'

  super(attributes)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.cpu_user_mode_in_percent = attributes[:'cpuUserModeInPercent'] if attributes[:'cpuUserModeInPercent']

  raise 'You cannot provide both :cpuUserModeInPercent and :cpu_user_mode_in_percent' if attributes.key?(:'cpuUserModeInPercent') && attributes.key?(:'cpu_user_mode_in_percent')

  self.cpu_user_mode_in_percent = attributes[:'cpu_user_mode_in_percent'] if attributes[:'cpu_user_mode_in_percent']

  self.cpu_system_mode_in_percent = attributes[:'cpuSystemModeInPercent'] if attributes[:'cpuSystemModeInPercent']

  raise 'You cannot provide both :cpuSystemModeInPercent and :cpu_system_mode_in_percent' if attributes.key?(:'cpuSystemModeInPercent') && attributes.key?(:'cpu_system_mode_in_percent')

  self.cpu_system_mode_in_percent = attributes[:'cpu_system_mode_in_percent'] if attributes[:'cpu_system_mode_in_percent']

  self.cpu_usage_in_sec = attributes[:'cpuUsageInSec'] if attributes[:'cpuUsageInSec']

  raise 'You cannot provide both :cpuUsageInSec and :cpu_usage_in_sec' if attributes.key?(:'cpuUsageInSec') && attributes.key?(:'cpu_usage_in_sec')

  self.cpu_usage_in_sec = attributes[:'cpu_usage_in_sec'] if attributes[:'cpu_usage_in_sec']

  self.cpu_utilization_in_percent = attributes[:'cpuUtilizationInPercent'] if attributes[:'cpuUtilizationInPercent']

  raise 'You cannot provide both :cpuUtilizationInPercent and :cpu_utilization_in_percent' if attributes.key?(:'cpuUtilizationInPercent') && attributes.key?(:'cpu_utilization_in_percent')

  self.cpu_utilization_in_percent = attributes[:'cpu_utilization_in_percent'] if attributes[:'cpu_utilization_in_percent']

  self.cpu_stolen_in_percent = attributes[:'cpuStolenInPercent'] if attributes[:'cpuStolenInPercent']

  raise 'You cannot provide both :cpuStolenInPercent and :cpu_stolen_in_percent' if attributes.key?(:'cpuStolenInPercent') && attributes.key?(:'cpu_stolen_in_percent')

  self.cpu_stolen_in_percent = attributes[:'cpu_stolen_in_percent'] if attributes[:'cpu_stolen_in_percent']

  self.cpu_idle_in_percent = attributes[:'cpuIdleInPercent'] if attributes[:'cpuIdleInPercent']

  raise 'You cannot provide both :cpuIdleInPercent and :cpu_idle_in_percent' if attributes.key?(:'cpuIdleInPercent') && attributes.key?(:'cpu_idle_in_percent')

  self.cpu_idle_in_percent = attributes[:'cpu_idle_in_percent'] if attributes[:'cpu_idle_in_percent']

  self.cpu_load1min = attributes[:'cpuLoad1min'] if attributes[:'cpuLoad1min']

  raise 'You cannot provide both :cpuLoad1min and :cpu_load1min' if attributes.key?(:'cpuLoad1min') && attributes.key?(:'cpu_load1min')

  self.cpu_load1min = attributes[:'cpu_load1min'] if attributes[:'cpu_load1min']

  self.cpu_load5min = attributes[:'cpuLoad5min'] if attributes[:'cpuLoad5min']

  raise 'You cannot provide both :cpuLoad5min and :cpu_load5min' if attributes.key?(:'cpuLoad5min') && attributes.key?(:'cpu_load5min')

  self.cpu_load5min = attributes[:'cpu_load5min'] if attributes[:'cpu_load5min']

  self.cpu_load15min = attributes[:'cpuLoad15min'] if attributes[:'cpuLoad15min']

  raise 'You cannot provide both :cpuLoad15min and :cpu_load15min' if attributes.key?(:'cpuLoad15min') && attributes.key?(:'cpu_load15min')

  self.cpu_load15min = attributes[:'cpu_load15min'] if attributes[:'cpu_load15min']
end

Instance Attribute Details

#cpu_idle_in_percentFloat

Amount of CPU idle time in percentage

Returns:

  • (Float)


35
36
37
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 35

def cpu_idle_in_percent
  @cpu_idle_in_percent
end

#cpu_load15minFloat

Load average in the last 15 minutes

Returns:

  • (Float)


47
48
49
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 47

def cpu_load15min
  @cpu_load15min
end

#cpu_load1minFloat

Load average in the last 1 minute

Returns:

  • (Float)


39
40
41
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 39

def cpu_load1min
  @cpu_load1min
end

#cpu_load5minFloat

Load average in the last 5 minutes

Returns:

  • (Float)


43
44
45
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 43

def cpu_load5min
  @cpu_load5min
end

#cpu_stolen_in_percentFloat

Amount of CPU time stolen in percentage

Returns:

  • (Float)


31
32
33
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 31

def cpu_stolen_in_percent
  @cpu_stolen_in_percent
end

#cpu_system_mode_in_percentFloat

Percentage of CPU time spent in system mode

Returns:

  • (Float)


19
20
21
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 19

def cpu_system_mode_in_percent
  @cpu_system_mode_in_percent
end

#cpu_usage_in_secFloat

Amount of CPU Time spent in seconds

Returns:

  • (Float)


23
24
25
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 23

def cpu_usage_in_sec
  @cpu_usage_in_sec
end

#cpu_user_mode_in_percentFloat

Percentage of CPU time spent in user mode

Returns:

  • (Float)


15
16
17
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 15

def cpu_user_mode_in_percent
  @cpu_user_mode_in_percent
end

#cpu_utilization_in_percentFloat

Amount of CPU Time spent in percentage

Returns:

  • (Float)


27
28
29
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 27

def cpu_utilization_in_percent
  @cpu_utilization_in_percent
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 50

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'metric_name': :'metricName',
    'time_collected': :'timeCollected',
    'cpu_user_mode_in_percent': :'cpuUserModeInPercent',
    'cpu_system_mode_in_percent': :'cpuSystemModeInPercent',
    'cpu_usage_in_sec': :'cpuUsageInSec',
    'cpu_utilization_in_percent': :'cpuUtilizationInPercent',
    'cpu_stolen_in_percent': :'cpuStolenInPercent',
    'cpu_idle_in_percent': :'cpuIdleInPercent',
    'cpu_load1min': :'cpuLoad1min',
    'cpu_load5min': :'cpuLoad5min',
    'cpu_load15min': :'cpuLoad15min'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 69

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'metric_name': :'String',
    'time_collected': :'DateTime',
    'cpu_user_mode_in_percent': :'Float',
    'cpu_system_mode_in_percent': :'Float',
    'cpu_usage_in_sec': :'Float',
    'cpu_utilization_in_percent': :'Float',
    'cpu_stolen_in_percent': :'Float',
    'cpu_idle_in_percent': :'Float',
    'cpu_load1min': :'Float',
    'cpu_load5min': :'Float',
    'cpu_load15min': :'Float'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 175

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    metric_name == other.metric_name &&
    time_collected == other.time_collected &&
    cpu_user_mode_in_percent == other.cpu_user_mode_in_percent &&
    cpu_system_mode_in_percent == other.cpu_system_mode_in_percent &&
    cpu_usage_in_sec == other.cpu_usage_in_sec &&
    cpu_utilization_in_percent == other.cpu_utilization_in_percent &&
    cpu_stolen_in_percent == other.cpu_stolen_in_percent &&
    cpu_idle_in_percent == other.cpu_idle_in_percent &&
    cpu_load1min == other.cpu_load1min &&
    cpu_load5min == other.cpu_load5min &&
    cpu_load15min == other.cpu_load15min
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 215

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


195
196
197
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 195

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



204
205
206
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 204

def hash
  [metric_name, time_collected, cpu_user_mode_in_percent, cpu_system_mode_in_percent, cpu_usage_in_sec, cpu_utilization_in_percent, cpu_stolen_in_percent, cpu_idle_in_percent, cpu_load1min, cpu_load5min, cpu_load15min].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



248
249
250
251
252
253
254
255
256
257
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 248

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



242
243
244
# File 'lib/oci/opsi/models/host_cpu_usage.rb', line 242

def to_s
  to_hash.to_s
end