Class: Mool::System

Inherits:
Base
  • Object
show all
Defined in:
lib/mool/system.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attrs

Constructor Details

#initializeSystem

Returns a new instance of System.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mool/system.rb', line 15

def initialize
  @kernel = Mool::Command.uname
  load_avg = Mool::Command.loadavg.split(' ')
  @current_loadavg          = load_avg[0].to_f
  @last_5min_loadavg        = load_avg[1].to_f
  @last_15min_loadavg       = load_avg[2].to_f
  # Currently executing kernel scheduling entities
  @thread_entities_exec     = load_avg[3].split('/').first.to_i
  # Number of kernel scheduling entities that currently exist on the system
  @total_thread_entities    = load_avg[3].split('/').last.to_i
  @last_pid_process_created = load_avg[4].to_i
  time = Mool::Command.uptime.split(' ').first.to_f
  mm, ss = time.divmod(60)
  hh, mm = mm.divmod(60)
  dd, hh = hh.divmod(24)
  @uptime_day    = dd.to_i
  @uptime_hour   = hh.to_i
  @uptime_minute = mm.to_i
  @uptime_second = ss.to_i
end

Instance Attribute Details

#current_loadavgObject

Returns the value of attribute current_loadavg.



3
4
5
# File 'lib/mool/system.rb', line 3

def current_loadavg
  @current_loadavg
end

#kernelObject

Returns the value of attribute kernel.



3
4
5
# File 'lib/mool/system.rb', line 3

def kernel
  @kernel
end

#last_15min_loadavgObject

Returns the value of attribute last_15min_loadavg.



3
4
5
# File 'lib/mool/system.rb', line 3

def last_15min_loadavg
  @last_15min_loadavg
end

#last_5min_loadavgObject

Returns the value of attribute last_5min_loadavg.



3
4
5
# File 'lib/mool/system.rb', line 3

def last_5min_loadavg
  @last_5min_loadavg
end

#last_pid_process_createdObject

Returns the value of attribute last_pid_process_created.



3
4
5
# File 'lib/mool/system.rb', line 3

def last_pid_process_created
  @last_pid_process_created
end

#thread_entities_execObject

Returns the value of attribute thread_entities_exec.



3
4
5
# File 'lib/mool/system.rb', line 3

def thread_entities_exec
  @thread_entities_exec
end

#total_thread_entitiesObject

Returns the value of attribute total_thread_entities.



3
4
5
# File 'lib/mool/system.rb', line 3

def total_thread_entities
  @total_thread_entities
end

#uptime_dayObject

Returns the value of attribute uptime_day.



3
4
5
# File 'lib/mool/system.rb', line 3

def uptime_day
  @uptime_day
end

#uptime_hourObject

Returns the value of attribute uptime_hour.



3
4
5
# File 'lib/mool/system.rb', line 3

def uptime_hour
  @uptime_hour
end

#uptime_minuteObject

Returns the value of attribute uptime_minute.



3
4
5
# File 'lib/mool/system.rb', line 3

def uptime_minute
  @uptime_minute
end

#uptime_secondObject

Returns the value of attribute uptime_second.



3
4
5
# File 'lib/mool/system.rb', line 3

def uptime_second
  @uptime_second
end

Instance Method Details

#kernel_versionObject



56
57
58
# File 'lib/mool/system.rb', line 56

def kernel_version
  @kernel
end

#load_averageObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/mool/system.rb', line 36

def load_average
  {
    current_loadavg: @current_loadavg,
    last_5min_loadavg: @last_5min_loadavg,
    last_15min_loadavg: @last_15min_loadavg,
    thread_entities_exec: @thread_entities_exec,
    total_thread_entities: @total_thread_entities,
    last_pid_process_created: @last_pid_process_created
  }
end

#uptimeObject



47
48
49
50
51
52
53
54
# File 'lib/mool/system.rb', line 47

def uptime
  {
    day: @uptime_day,
    hour: @uptime_hour,
    minute: @uptime_minute,
    second:  @uptime_second
  }
end