linux_stat 1.6.0 → 2.2.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 +160 -126
- data/bin/console +7 -1
- data/exe/linuxstat.rb +6 -0
- data/ext/procfs/extconf.rb +11 -0
- data/ext/procfs/loadavg_pid.h +11 -0
- data/ext/procfs/procfs.c +43 -0
- data/ext/procfs/stat.h +119 -0
- data/ext/procfs/statm.h +109 -0
- data/ext/procfs/uptime.h +12 -0
- data/lib/linux_stat.rb +4 -1
- data/lib/linux_stat/battery.rb +8 -1
- data/lib/linux_stat/net.rb +5 -5
- data/lib/linux_stat/os.rb +16 -15
- data/lib/linux_stat/process.rb +17 -27
- data/lib/linux_stat/process_info.rb +124 -158
- data/lib/linux_stat/swap.rb +23 -7
- data/lib/linux_stat/version.rb +1 -1
- metadata +11 -4
data/lib/linux_stat/swap.rb
CHANGED
|
@@ -35,7 +35,10 @@ module LinuxStat
|
|
|
35
35
|
return {} unless swaps_readable?
|
|
36
36
|
values_t = read_usage
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
_total, _used = values_t[0], values_t[-1]
|
|
39
|
+
return {} if _total.empty? || _used.empty?
|
|
40
|
+
|
|
41
|
+
total, used = _total.reduce(:+), _used.reduce(:+)
|
|
39
42
|
available = total - used
|
|
40
43
|
percent_used = total == 0 ? 0.0 : used.*(100).fdiv(total).round(2)
|
|
41
44
|
percent_available = total == 0.0 ? 0 : available.*(100).fdiv(total).round(2)
|
|
@@ -81,7 +84,9 @@ module LinuxStat
|
|
|
81
84
|
def available
|
|
82
85
|
return nil unless swaps_readable?
|
|
83
86
|
values_t = read_usage
|
|
84
|
-
|
|
87
|
+
t = values_t[0].reduce(:+)
|
|
88
|
+
u = values_t[1].reduce(:+)
|
|
89
|
+
(t && u) ? t - u : nil
|
|
85
90
|
end
|
|
86
91
|
|
|
87
92
|
##
|
|
@@ -92,7 +97,7 @@ module LinuxStat
|
|
|
92
97
|
# The return type is a Integer but if the info isn't available, it will return nil.
|
|
93
98
|
def used
|
|
94
99
|
return nil unless swaps_readable?
|
|
95
|
-
read_usage[-1].
|
|
100
|
+
read_usage[-1].reduce(:+)
|
|
96
101
|
end
|
|
97
102
|
|
|
98
103
|
##
|
|
@@ -103,10 +108,16 @@ module LinuxStat
|
|
|
103
108
|
return nil unless swaps_readable?
|
|
104
109
|
values_t = read_usage
|
|
105
110
|
|
|
106
|
-
|
|
111
|
+
_total = values_t[0]
|
|
112
|
+
_used = values_t[-1]
|
|
113
|
+
return nil if _total.empty? || _used.empty?
|
|
114
|
+
|
|
115
|
+
total = _total.reduce(:+)
|
|
116
|
+
used = _used.reduce(:+)
|
|
117
|
+
|
|
107
118
|
return 0.0 if total == 0
|
|
108
119
|
|
|
109
|
-
|
|
120
|
+
used.*(100).fdiv(total).round(2)
|
|
110
121
|
end
|
|
111
122
|
|
|
112
123
|
##
|
|
@@ -117,10 +128,15 @@ module LinuxStat
|
|
|
117
128
|
return nil unless swaps_readable?
|
|
118
129
|
values_t = read_usage
|
|
119
130
|
|
|
120
|
-
|
|
131
|
+
_total = values_t[0]
|
|
132
|
+
_used = values_t[-1]
|
|
133
|
+
return nil if _total.empty? || _used.empty?
|
|
134
|
+
|
|
135
|
+
total, used = _total.reduce(:+), _used.reduce(:+)
|
|
136
|
+
|
|
121
137
|
return 0.0 if total == 0
|
|
122
138
|
|
|
123
|
-
total.-(
|
|
139
|
+
total.-(used).*(100).fdiv(total).round(2)
|
|
124
140
|
end
|
|
125
141
|
|
|
126
142
|
private
|
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:
|
|
4
|
+
version: 2.2.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: 2021-
|
|
11
|
+
date: 2021-02-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Linux only, efficient linux system utilization reporting and system monitoring
|
|
14
14
|
gem
|
|
@@ -19,6 +19,7 @@ executables:
|
|
|
19
19
|
extensions:
|
|
20
20
|
- ext/fs_stat/extconf.rb
|
|
21
21
|
- ext/nproc/extconf.rb
|
|
22
|
+
- ext/procfs/extconf.rb
|
|
22
23
|
- ext/sysconf/extconf.rb
|
|
23
24
|
- ext/sysinfo/extconf.rb
|
|
24
25
|
- ext/utsname/extconf.rb
|
|
@@ -34,6 +35,12 @@ files:
|
|
|
34
35
|
- ext/fs_stat/fs_stat.c
|
|
35
36
|
- ext/nproc/extconf.rb
|
|
36
37
|
- ext/nproc/nproc.c
|
|
38
|
+
- ext/procfs/extconf.rb
|
|
39
|
+
- ext/procfs/loadavg_pid.h
|
|
40
|
+
- ext/procfs/procfs.c
|
|
41
|
+
- ext/procfs/stat.h
|
|
42
|
+
- ext/procfs/statm.h
|
|
43
|
+
- ext/procfs/uptime.h
|
|
37
44
|
- ext/sysconf/extconf.rb
|
|
38
45
|
- ext/sysconf/sysconf.c
|
|
39
46
|
- ext/sysinfo/extconf.rb
|
|
@@ -71,14 +78,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
71
78
|
requirements:
|
|
72
79
|
- - ">="
|
|
73
80
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: 2.
|
|
81
|
+
version: 2.3.0
|
|
75
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
83
|
requirements:
|
|
77
84
|
- - ">="
|
|
78
85
|
- !ruby/object:Gem::Version
|
|
79
86
|
version: '0'
|
|
80
87
|
requirements: []
|
|
81
|
-
rubygems_version: 3.
|
|
88
|
+
rubygems_version: 3.2.7
|
|
82
89
|
signing_key:
|
|
83
90
|
specification_version: 4
|
|
84
91
|
summary: Efficient linux system reporting gem
|