module StatsLite::Default
Public Class Methods
_cpu_usage()
click to toggle source
# File lib/stats_lite/default.rb, line 38 def _cpu_usage { total: fmt_nr(h.command(df_c[:cpu][:usage])) } end
cpu()
click to toggle source
# 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_c()
click to toggle source
# File lib/stats_lite/default.rb, line 61 def df_c StatsLite::DEFAULT_COMMANDS end
fmt_nr(number)
click to toggle source
# File lib/stats_lite/default.rb, line 57 def fmt_nr(number) "#{number.gsub("%", "").to_i}%" end
h()
click to toggle source
# File lib/stats_lite/default.rb, line 65 def h StatsLite::Helper end
hdd()
click to toggle source
# 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
host()
click to toggle source
# File lib/stats_lite/default.rb, line 6 def host { hostname: h.command(df_c[:host][:hostname], cache: true), ip: ip } end
ip()
click to toggle source
# File lib/stats_lite/default.rb, line 20 def ip { public: h.command(df_c[:host][:ip][:public], cache: true) } end
ram()
click to toggle source
# 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