Module: StatsLite::Default
- Defined in:
- lib/stats_lite/default.rb
Class Method Summary collapse
- ._cpu_usage ⇒ Object
- .cpu ⇒ Object
- .df_c ⇒ Object
- .fmt_nr(number) ⇒ Object
- .h ⇒ Object
- .hdd ⇒ Object
- .host ⇒ Object
- .ip ⇒ Object
- .ram ⇒ Object
Class Method Details
._cpu_usage ⇒ Object
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 |
.cpu ⇒ Object
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_c ⇒ Object
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 |
.hdd ⇒ Object
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 |
.host ⇒ Object
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 |
.ip ⇒ Object
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 |
.ram ⇒ Object
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 |