Class: Adminix::Entities::SysloadStamp

Inherits:
Object
  • Object
show all
Defined in:
lib/adminix/entities/sysload_stamp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSysloadStamp

Returns a new instance of SysloadStamp.



8
9
10
11
# File 'lib/adminix/entities/sysload_stamp.rb', line 8

def initialize
  create_stamp
  @created_at = Time.now
end

Instance Attribute Details

#cpu_load_percentsObject (readonly)

Returns the value of attribute cpu_load_percents.



5
6
7
# File 'lib/adminix/entities/sysload_stamp.rb', line 5

def cpu_load_percents
  @cpu_load_percents
end

#created_atObject (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/adminix/entities/sysload_stamp.rb', line 5

def created_at
  @created_at
end

#disk_usage_mbObject (readonly)

Returns the value of attribute disk_usage_mb.



5
6
7
# File 'lib/adminix/entities/sysload_stamp.rb', line 5

def disk_usage_mb
  @disk_usage_mb
end

#memory_usage_mbObject (readonly)

Returns the value of attribute memory_usage_mb.



5
6
7
# File 'lib/adminix/entities/sysload_stamp.rb', line 5

def memory_usage_mb
  @memory_usage_mb
end

#temperatureObject (readonly)

Returns the value of attribute temperature.



5
6
7
# File 'lib/adminix/entities/sysload_stamp.rb', line 5

def temperature
  @temperature
end

Instance Method Details

#create_stampObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/adminix/entities/sysload_stamp.rb', line 13

def create_stamp
  case Adminix.os
  when 'linux'
    @memory_usage_mb, = Helpers::Command.debian_memory_load
    @cpu_load_percents = Helpers::Command.debian_cpu_load
    @disk_usage_mb, = Helpers::Command.debian_disk_usage
    @temperature = Helpers::Command.debian_temperature
  when 'mac'
    @cpu_load_percents = Helpers::Command.darwin_cpu_load
    @disk_usage_mb, = Helpers::Command.darwin_disk_usage
  end
end

#to_apiObject



26
27
28
29
30
31
32
33
34
# File 'lib/adminix/entities/sysload_stamp.rb', line 26

def to_api
  {
    memory: memory_usage_mb,
    cpu: cpu_load_percents,
    disk: disk_usage_mb,
    temperature: temperature,
    created_at: created_at
  }
end