Module: StatsLite::Default

Defined in:
lib/stats_lite/default.rb

Class Method Summary collapse

Class Method Details

._cpu_usageObject



38
39
40
41
42
# File 'lib/stats_lite/default.rb', line 38

def _cpu_usage
  {
    total: fmt_nr(h.command(df_c[:cpu][:usage]))
  }
end

.cpuObject



12
13
14
15
16
17
18
# File 'lib/stats_lite/default.rb', line 12

def cpu
  {
    model: h.command(df_c[:cpu][:model], cache: true),
    cores: h.command(df_c[:cpu][:cores], cache: true),
    usage: _cpu_usage
  }
end

.df_cObject



61
62
63
# File 'lib/stats_lite/default.rb', line 61

def df_c
  StatsLite::DEFAULT_COMMANDS
end

.fmt_nr(number) ⇒ Object



57
58
59
# File 'lib/stats_lite/default.rb', line 57

def fmt_nr(number)
  "#{number.gsub("%", "").to_i}%"
end

.hObject



65
66
67
# File 'lib/stats_lite/default.rb', line 65

def h
  StatsLite::Helper
end

.hddObject



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/stats_lite/default.rb', line 44

def hdd
  result = -> do
    map =  Vidibus::Sysinfo.storage.to_h
    map.map do |k, v|
      map[k] = "#{v}GB"
    end

    map
  end

  { usage: h.fetch(:hdd, result, expires_in: 60) }
end

.hostObject



6
7
8
9
10
11
# File 'lib/stats_lite/default.rb', line 6

def host
  {
    hostname: h.command(df_c[:host][:hostname], cache: true),
    ip: ip
  }
end

.ipObject



20
21
22
23
24
# File 'lib/stats_lite/default.rb', line 20

def ip
  {
    public: h.command(df_c[:host][:ip][:public], cache: true)
  }
end

.ramObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/stats_lite/default.rb', line 26

def ram
  result = -> do
    map = Vidibus::Sysinfo.memory.to_h
    map.map do |k, v|
      map[k] = "#{(v / 1024.to_f).round(2)}GB"
    end
    map
  end

  { usage: h.fetch(:ram, result, expires_in: 10) }
end