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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/stats_lite/default.rb +9 -8
- data/lib/stats_lite/default_commands.rb +17 -0
- data/lib/stats_lite/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d7bee183ca83a6e25a161a37b6b6c30e2f296045e3cca56408a0bc349da5324
|
4
|
+
data.tar.gz: 054d7553c005db8d2b9afcbfaed7a2e6f3c5c82ae78cbe550c6854958947b867
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0e7d95a9e156333ec2efc28493acd48aa4821d019a3ee81e0eccef526483047eb57f66895a07a1cb5fa081735250c9aa76fcb9a93a7bf69b356596cacdd21c7
|
7
|
+
data.tar.gz: 5121f385dc28a929af3bea9c93aa134267e45b9173d75340cd3e24c7a561cf2b75a98687b129642d12f65425bb8a318b93f6741d62ff69e07845a4c3ac5a25dd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/stats_lite/default.rb
CHANGED
@@ -5,21 +5,21 @@ module StatsLite
|
|
5
5
|
class << self
|
6
6
|
def host
|
7
7
|
{
|
8
|
-
hostname: h.command(
|
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(
|
15
|
-
cores: h.command(
|
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(
|
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(
|
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
|
data/lib/stats_lite/version.rb
CHANGED
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.
|
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
|