stats_lite 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 739259ecd53a5f2618dba89d8a01de419c6e0e8a22c2dacccf95daf027ec3131
4
- data.tar.gz: c947d11640f9d8ec80c77d321a6769cd637435431fbee3dc08deaef95d3c97be
3
+ metadata.gz: 1d7bee183ca83a6e25a161a37b6b6c30e2f296045e3cca56408a0bc349da5324
4
+ data.tar.gz: 054d7553c005db8d2b9afcbfaed7a2e6f3c5c82ae78cbe550c6854958947b867
5
5
  SHA512:
6
- metadata.gz: 102cbda56a8188b1f254bbf89a0ee245cbe7509e99c820ada18c06e96a791a170fe1dd50bc3c07fd224849f1b1382c9f209b9863a6b48c1eded2c190e28b0953
7
- data.tar.gz: e9830509e93db6c9e53e96a931a7e9368304b6aa8b1646a0953f34ed64b76de593e822d68ad051238bb1a21dee5ae4180b07ca99a52b91352a39a38f0d4796b7
6
+ metadata.gz: b0e7d95a9e156333ec2efc28493acd48aa4821d019a3ee81e0eccef526483047eb57f66895a07a1cb5fa081735250c9aa76fcb9a93a7bf69b356596cacdd21c7
7
+ data.tar.gz: 5121f385dc28a929af3bea9c93aa134267e45b9173d75340cd3e24c7a561cf2b75a98687b129642d12f65425bb8a318b93f6741d62ff69e07845a4c3ac5a25dd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stats_lite (0.5.2)
4
+ stats_lite (0.5.3)
5
5
  filewatcher (~> 1.1.1)
6
6
  puma (>= 4.0.0, < 5.0.0)
7
7
  rack (>= 2.0.0, < 3.0.0)
data/README.md CHANGED
@@ -23,7 +23,7 @@ Add to startup, crontab
23
23
  ```shell script
24
24
  crontab -e
25
25
  # then add
26
- @reboot stats-lite
26
+ @reboot /usr/local/bin/stats-lite
27
27
  ```
28
28
 
29
29
  ![demo](https://raw.githubusercontent.com/sebyx07/stats-lite/master/docs/example.png)
@@ -5,21 +5,21 @@ module StatsLite
5
5
  class << self
6
6
  def host
7
7
  {
8
- hostname: h.command("hostname", cache: true),
8
+ hostname: h.command(df_c[:host][:hostname], cache: true),
9
9
  ip: ip
10
10
  }
11
11
  end
12
12
  def cpu
13
13
  {
14
- model: h.command("lscpu | grep 'Model name' | cut -f 2 -d \":\" | awk '{$1=$1}1'", cache: true),
15
- cores: h.command("nproc", cache: true),
14
+ model: h.command(df_c[:cpu][:model], cache: true),
15
+ cores: h.command(df_c[:cpu][:cores], cache: true),
16
16
  usage: _cpu_usage
17
17
  }
18
18
  end
19
19
 
20
20
  def ip
21
21
  {
22
- public: h.command("curl -s ifconfig.me", cache: true)
22
+ public: h.command(df_c[:host][:ip][:public], cache: true)
23
23
  }
24
24
  end
25
25
 
@@ -36,11 +36,8 @@ module StatsLite
36
36
  end
37
37
 
38
38
  def _cpu_usage
39
- total = <<-CMD
40
- (grep 'cpu ' /proc/stat;sleep 0.1;grep 'cpu ' /proc/stat)|awk -v RS="" '{print ""($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)"%"}'
41
- CMD
42
39
  {
43
- total: fmt_nr(h.command(total))
40
+ total: fmt_nr(h.command(df_c[:cpu][:usage]))
44
41
  }
45
42
  end
46
43
 
@@ -61,6 +58,10 @@ module StatsLite
61
58
  "#{number.gsub("%", "").to_i}%"
62
59
  end
63
60
 
61
+ def df_c
62
+ StatsLite::DEFAULT_COMMANDS
63
+ end
64
+
64
65
  def h
65
66
  StatsLite::Helper
66
67
  end
@@ -0,0 +1,17 @@
1
+ module StatsLite
2
+ DEFAULT_COMMANDS = {
3
+ host: {
4
+ hostname: "hostname",
5
+ ip: {
6
+ public: "curl -s ifconfig.me"
7
+ }
8
+ },
9
+ cpu: {
10
+ model: "lscpu | grep 'Model name' | cut -f 2 -d \":\" | awk '{$1=$1}1'",
11
+ cores: "nproc",
12
+ usage: <<-CMD
13
+ (grep 'cpu ' /proc/stat;sleep 0.1;grep 'cpu ' /proc/stat)|awk -v RS="" '{print ""($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)"%"}'
14
+ CMD
15
+ }
16
+ }
17
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StatsLite
4
- VERSION = "0.5.2"
4
+ VERSION = "0.5.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stats_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sebi
@@ -183,6 +183,7 @@ files:
183
183
  - lib/stats_lite/cache.rb
184
184
  - lib/stats_lite/configure.rb
185
185
  - lib/stats_lite/default.rb
186
+ - lib/stats_lite/default_commands.rb
186
187
  - lib/stats_lite/helper.rb
187
188
  - lib/stats_lite/log.rb
188
189
  - lib/stats_lite/version.rb