linux_stat 1.2.3 → 1.3.0
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 +24 -0
- data/lib/linux_stat.rb +1 -0
- data/lib/linux_stat/battery.rb +2 -0
- data/lib/linux_stat/bios.rb +2 -0
- data/lib/linux_stat/cpu.rb +2 -0
- data/lib/linux_stat/filesystem.rb +2 -0
- data/lib/linux_stat/kernel.rb +2 -0
- data/lib/linux_stat/memory.rb +2 -0
- data/lib/linux_stat/mounts.rb +2 -0
- data/lib/linux_stat/net.rb +2 -0
- data/lib/linux_stat/os.rb +2 -0
- data/lib/linux_stat/pci.rb +2 -0
- data/lib/linux_stat/prettify_bytes.rb +7 -0
- data/lib/linux_stat/process.rb +3 -0
- data/lib/linux_stat/process_info.rb +7 -0
- data/lib/linux_stat/swap.rb +2 -0
- data/lib/linux_stat/thermal.rb +122 -0
- data/lib/linux_stat/usb.rb +2 -0
- data/lib/linux_stat/user.rb +2 -0
- data/lib/linux_stat/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58652553450c8570d4e9d1137256e8b27155bf7f61f2bd89f423f3eb3e6fd907
|
4
|
+
data.tar.gz: d90289e14f856823d2370d7a0629769d874d8f630043c1cce0fd3c357ca12f1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ee5142e8a10b2f4171aac6901b9cb98d9ca9ef74738e39f7b4dfca15381ee6c4a40c0815bb957476250958d207d21e8759266c3c7229af510b189d4ec7d758f
|
7
|
+
data.tar.gz: 454c9d051de0a49156e421a1c866e4b690fd6d98bdcb714acabb18d6b5e13c1ae29b1bb1035b75962e1e47f9a7094b6a5bde46742e54212aac427103f56308d4
|
data/README.md
CHANGED
@@ -854,6 +854,30 @@ LinuxStat::Sysconf.tty_name_max()
|
|
854
854
|
|
855
855
|
```
|
856
856
|
|
857
|
+
### LinuxStat::Thermal
|
858
|
+
```
|
859
|
+
# File: thermal.rb | Line: 57
|
860
|
+
# Definition: def count_fans
|
861
|
+
LinuxStat::Thermal.count_fans()
|
862
|
+
=> 1
|
863
|
+
|
864
|
+
# File: thermal.rb | Line: 49
|
865
|
+
# Definition: def count_sensors
|
866
|
+
LinuxStat::Thermal.count_sensors()
|
867
|
+
=> 8
|
868
|
+
|
869
|
+
# File: thermal.rb | Line: 41
|
870
|
+
# Definition: def fans
|
871
|
+
LinuxStat::Thermal.fans()
|
872
|
+
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Processor Fan", :rpm=>0}]
|
873
|
+
|
874
|
+
# File: thermal.rb | Line: 23
|
875
|
+
# Definition: def temperatures
|
876
|
+
LinuxStat::Thermal.temperatures()
|
877
|
+
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"SODIMM", :temperature=>36.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"CPU", :temperature=>46.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Ambi...
|
878
|
+
|
879
|
+
```
|
880
|
+
|
857
881
|
### LinuxStat::USB
|
858
882
|
```
|
859
883
|
# File: usb.rb | Line: 135
|
data/lib/linux_stat.rb
CHANGED
data/lib/linux_stat/battery.rb
CHANGED
data/lib/linux_stat/bios.rb
CHANGED
data/lib/linux_stat/cpu.rb
CHANGED
data/lib/linux_stat/kernel.rb
CHANGED
data/lib/linux_stat/memory.rb
CHANGED
data/lib/linux_stat/mounts.rb
CHANGED
data/lib/linux_stat/net.rb
CHANGED
data/lib/linux_stat/os.rb
CHANGED
data/lib/linux_stat/pci.rb
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
module LinuxStat
|
2
|
+
# Helps you convert bytes to a unit like:
|
3
|
+
#
|
4
|
+
# 1. kilobyte, megabyte, gigabyte, terabyte, petabyte, exabyte, zettabyte, yottabyte
|
5
|
+
# 2. kibibyte, mebibyte, gibibyte, tebibyte, pebibyte, exbibyte, zebibyte, yobibyte
|
6
|
+
# 3. kB, MB, GB, TB, PB, EB, ZB, YB
|
7
|
+
# 4. kiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB
|
8
|
+
|
2
9
|
module PrettifyBytes
|
3
10
|
class << self
|
4
11
|
##
|
data/lib/linux_stat/process.rb
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
module LinuxStat
|
2
|
+
# Shows various information about a process that is either
|
3
|
+
# running, sleeping, idle or a zombie.
|
4
|
+
# Most methods can take a PID, but some uses polling to calculate
|
5
|
+
# something, they can accept options instead of arguments.
|
6
|
+
# Consult the documentation on the specific methods
|
7
|
+
# for more details on that.
|
8
|
+
|
2
9
|
module ProcessInfo
|
3
10
|
class << self
|
4
11
|
##
|
data/lib/linux_stat/swap.rb
CHANGED
@@ -0,0 +1,122 @@
|
|
1
|
+
module LinuxStat
|
2
|
+
# Sensors are available to /sys/class/hwmon
|
3
|
+
# This module just reads the files inside them to get the sensor information.
|
4
|
+
#
|
5
|
+
# https://www.kernel.org/doc/Documentation/thermal/sysfs-api.txt
|
6
|
+
|
7
|
+
module Thermal
|
8
|
+
class << self
|
9
|
+
##
|
10
|
+
# Get temperatures from all sensors.
|
11
|
+
#
|
12
|
+
# The return value is an Array of Hashes.
|
13
|
+
#
|
14
|
+
# It opens various files from /sys/, and it should be
|
15
|
+
# considered very slow.
|
16
|
+
#
|
17
|
+
# Each hash may contain information including:
|
18
|
+
#
|
19
|
+
# path, name, label
|
20
|
+
# temperature, temp_crit, temp_max
|
21
|
+
#
|
22
|
+
# But if the info isn't available, it will return an empty Array.
|
23
|
+
def temperatures
|
24
|
+
query_hwmon('temp'.freeze, :temperature, true)
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Get RPM from all fans.
|
29
|
+
#
|
30
|
+
# The return value is an Array of Hashes.
|
31
|
+
#
|
32
|
+
# It opens various files from /sys/, and it should be
|
33
|
+
# considered very slow.
|
34
|
+
#
|
35
|
+
# Each hash may contain information including:
|
36
|
+
#
|
37
|
+
# path, name, label
|
38
|
+
# rpm, temp_crit, temp_max
|
39
|
+
#
|
40
|
+
# But if the info isn't available, it will return an empty Array.
|
41
|
+
def fans
|
42
|
+
query_hwmon('fan'.freeze, :rpm)
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# Counts the number of sensors (fans are not counted)
|
47
|
+
#
|
48
|
+
# The return type is an Integer.
|
49
|
+
def count_sensors
|
50
|
+
return 0 unless hwmon_readable?
|
51
|
+
|
52
|
+
Dir["/sys/class/hwmon/hwmon[0-9]*/temp[0-9]*_input".freeze].size
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Counts the number of fans (sensors are not counted)
|
57
|
+
#
|
58
|
+
# The return type is an Integer.
|
59
|
+
def count_fans
|
60
|
+
return 0 unless hwmon_readable?
|
61
|
+
|
62
|
+
Dir["/sys/class/hwmon/hwmon[0-9]*/fan[0-9]*_input".freeze].size
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def hwmon_readable?
|
67
|
+
@@hwmon_readable ||= File.readable?("/sys/class/hwmon/")
|
68
|
+
end
|
69
|
+
|
70
|
+
def query_hwmon(mon, key, div = false)
|
71
|
+
return [] unless hwmon_readable?
|
72
|
+
|
73
|
+
name = dir = ''.freeze
|
74
|
+
|
75
|
+
files = Dir["/sys/class/hwmon/hwmon[0-9]*/#{mon}[0-9]*_input".freeze]
|
76
|
+
i = -1
|
77
|
+
ret = []
|
78
|
+
|
79
|
+
while x = files[i += 1]
|
80
|
+
splitted = File.split(x)
|
81
|
+
path = File.join(splitted[0..-2])
|
82
|
+
|
83
|
+
n = splitted[-1][/.*_/]
|
84
|
+
|
85
|
+
label_f = "#{path}/#{n}label"
|
86
|
+
label = File.readable?(label_f) ? IO.read(label_f, encoding: 'ASCII-8BIT'.freeze).strip : nil
|
87
|
+
|
88
|
+
temp_crit_f = "#{path}/#{n}crit"
|
89
|
+
temp_crit = File.readable?(temp_crit_f) ? IO.read(temp_crit_f, encoding: 'ASCII-8BIT'.freeze).to_i : nil
|
90
|
+
|
91
|
+
temp_max_f = "#{path}/#{n}max"
|
92
|
+
temp_max = File.readable?(temp_max_f) ? IO.read(temp_max_f, encoding: 'ASCII-8BIT'.freeze).to_i : nil
|
93
|
+
|
94
|
+
value = File.readable?(x) ? IO.read(x).to_i : nil
|
95
|
+
|
96
|
+
if dir != path
|
97
|
+
dir = path
|
98
|
+
name_f = "#{path}/name"
|
99
|
+
name = File.readable?(name_f) ? IO.read(name_f, encoding: 'ASCII-8BIT'.freeze).tap(&:strip!) : ''.freeze
|
100
|
+
end
|
101
|
+
|
102
|
+
if div
|
103
|
+
value /= 1000.0
|
104
|
+
temp_max /= 1000.0 if temp_max
|
105
|
+
temp_crit /= 1000.0 if temp_crit
|
106
|
+
end
|
107
|
+
|
108
|
+
h = {path: path, name: name}
|
109
|
+
|
110
|
+
h.merge!(label: label) if label
|
111
|
+
h.merge!(key => value)
|
112
|
+
h.merge!(temp_crit: temp_crit) if temp_crit
|
113
|
+
h.merge!(temp_crit: temp_max) if temp_max
|
114
|
+
|
115
|
+
ret.push(h)
|
116
|
+
end
|
117
|
+
|
118
|
+
ret
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
data/lib/linux_stat/usb.rb
CHANGED
data/lib/linux_stat/user.rb
CHANGED
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: 1.
|
4
|
+
version: 1.3.0
|
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-12-
|
11
|
+
date: 2020-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Linux only, efficient linux system utilization reporting and system monitoring
|
14
14
|
gem
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/linux_stat/process.rb
|
53
53
|
- lib/linux_stat/process_info.rb
|
54
54
|
- lib/linux_stat/swap.rb
|
55
|
+
- lib/linux_stat/thermal.rb
|
55
56
|
- lib/linux_stat/usb.rb
|
56
57
|
- lib/linux_stat/user.rb
|
57
58
|
- lib/linux_stat/version.rb
|