linux_stat 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/ext/fs_stat/extconf.rb +5 -2
- data/lib/linux_stat/cpu.rb +21 -4
- data/lib/linux_stat/filesystem.rb +0 -1
- data/lib/linux_stat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 918383341aa375e1414e08c13b38829373caa174c64769541955180ce9d6e09c
|
4
|
+
data.tar.gz: b821c81eee9bf5c9061057ab653e336adbbeaacf51d9b4141e6a1d72073058b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 580b5af4a00f4b2078e2d7cf9e249ba9648a5ab5965fe26c15f73c0cb843eeae6470e00d28fb096100f7b5445e47fcdce354c713c3aff4139fcb8a53221d68f0
|
7
|
+
data.tar.gz: 6ebaa17fd1aaf45910a297df8b992e495e3f8c594c2b69181bdd1c9536bb2be40a8ad4fb569f4be076aac1eaf70fc0d86d7930eedde79615db6ffcfcb498dc50
|
data/README.md
CHANGED
data/ext/fs_stat/extconf.rb
CHANGED
data/lib/linux_stat/cpu.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module LinuxStat
|
2
2
|
module CPU
|
3
3
|
class << self
|
4
|
-
#
|
4
|
+
# stat(sleep = 0.075)
|
5
|
+
# Where sleep is the delay to gather the data.
|
6
|
+
# This method returns the cpu usage of all threads.
|
5
7
|
#
|
6
8
|
# The first one is aggregated CPU usage reported by the Linux kernel.
|
7
9
|
# And the consecutive ones are the real core usages.
|
@@ -30,7 +32,10 @@ module LinuxStat
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
|
-
#
|
35
|
+
# total_usage(sleep = 0.075)
|
36
|
+
# Where sleep is the delay to gather the data.
|
37
|
+
# This method returns the cpu usage of all threads.
|
38
|
+
#
|
34
39
|
# It's like running LinuxStat::CPU.stat[0] but it's much more efficient and calculates just the aggregated usage which is available at the top of the /proc/stat file.
|
35
40
|
#
|
36
41
|
# If the information is not available, it will return nil.
|
@@ -67,14 +72,26 @@ module LinuxStat
|
|
67
72
|
# If the information isn't available, it will return an empty array.
|
68
73
|
def cur_freq
|
69
74
|
@@cpu_freqs ||= Dir["/sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_cur_freq"]
|
70
|
-
@@
|
75
|
+
@@cur_freqs_readable ||= @@cpu_freqs.all?(&File.method(:readable?))
|
76
|
+
|
77
|
+
if @@cur_freqs_readable
|
78
|
+
@@cpu_freqs.map { |x| IO.read(x).to_i }
|
79
|
+
else
|
80
|
+
[]
|
81
|
+
end
|
71
82
|
end
|
72
83
|
|
73
84
|
# Returns an array with max core frequencies corresponding to the usages.
|
74
85
|
# If the information isn't available, it will return an empty array.
|
75
86
|
def max_freq
|
76
87
|
@@max_freqs ||= Dir["/sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_max_freq"]
|
77
|
-
@@
|
88
|
+
@@max_freqs_readable ||= @@max_freqs.all?(&File.method(:readable?))
|
89
|
+
|
90
|
+
if @@max_freqs_readable
|
91
|
+
@@max_freqs.map { |x| IO.read(x).to_i }
|
92
|
+
else
|
93
|
+
[]
|
94
|
+
end
|
78
95
|
end
|
79
96
|
|
80
97
|
alias usages stat
|
@@ -17,7 +17,6 @@ module LinuxStat
|
|
17
17
|
# {:total=>119981191168, :free=>43155574784, :used=>76825616384, :available=>43155574784}
|
18
18
|
#
|
19
19
|
# If the stat can't be acquired, this method will return an empty Hash.
|
20
|
-
|
21
20
|
def stat(fs = ?/.freeze)
|
22
21
|
s = stat_raw(fs)
|
23
22
|
return {} if s.empty?
|
data/lib/linux_stat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linux_stat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sourav Goswami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Efficient linux system reporting gem. Linux Only | Efficient | Reliable
|
14
14
|
email:
|