linux_stat 0.8.0 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f24315a14357e71327614a2ec812f052ff71973af21e34e6a14f3a24f537083a
4
- data.tar.gz: f2c18ac10d00092ead72522700cf97d58b599890b6c6a0fd076e4ffd88ebf6b6
3
+ metadata.gz: d2b9ce6001721fb53594609195cab131b1012257ecc8ec8705d80bbfad10e930
4
+ data.tar.gz: 0aeb2d9b11d871ffd82cd48ee8ca08b94620db5fd6e59c1d2b450c906b7da589
5
5
  SHA512:
6
- metadata.gz: 06ec57333b02c7cf239ed0f2e2cd889f95110523e642807d534ec71c9761b9f58066326ed01291871b4f7d9b692adc778db743f2c275f4485c2779ea320b1253
7
- data.tar.gz: b577d7ed448d1c5f474ab70c0fda4fd333f43049f27978cf9970032f15c05f2b2f3040d248108393bde474324b6e1d83694d7054a6f2d1f0eaba466d2c7c2b8b
6
+ metadata.gz: 5d0f539696f3b58aa068c97636517c3f813b3359e8f45ac4a7f08f642d2c3478be5ca8998f2a293919b703900f3e5a8ea7a7b57b72ee0f58e2c6d783760c30cb
7
+ data.tar.gz: 769195f4ea410fb4a856344632cd5fd0f191d40e3fb022ce0868c31723cdb203797c20357b9c022e1bb3e21f6c33b3a3275a852ed8abf78dc1cf7b6b1b9c6d80
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # LinuxStat [![Ruby Gem](https://badge.fury.io/rb/linux_stat.svg)](https://rubygems.org/gems/linux_stat) ![Workflow Status](https://github.com/souravgoswami/linux_stat/workflows/LinuxStat%20Test/badge.svg)
2
2
 
3
+ ---
4
+
3
5
  ![logo](https://raw.githubusercontent.com/Souravgoswami/linux_stat/master/images/logo.jpg)
4
6
 
5
7
  For reading the eyecandy HTML version, visit [linux_stat](https://souravgoswami.github.io/linux_stat/).
@@ -8,13 +10,9 @@ LinuxStat lets you read status of a Linux system. It can show you cpu stats and
8
10
 
9
11
  It only works for Linux, and detecting the OS is upto the user of this gem.
10
12
 
11
- ---
12
-
13
- ## Source LOC (no comments / blank lines are counted):
13
+ Programming Languages Used:
14
14
 
15
- <div style="text-align:center">
16
- <img src="https://linuxstatloc.herokuapp.com/badge.svg" width="360px">
17
- </div>
15
+ <img src="https://linuxstatloc.herokuapp.com/badge.svg" width="260px">
18
16
 
19
17
  ---
20
18
 
@@ -56,25 +54,30 @@ Or install it yourself as:
56
54
  $ gem install linux_stat
57
55
 
58
56
  ## Usage
57
+ Following are the LinuxStat modules and module functions.
58
+ It's generated by linuxstat.rb command, which is available after the installation.
59
+
60
+ For ease of use, LinuxStat is also assigned to the LS constant.
61
+
59
62
  ### LinuxStat::BIOS
60
63
  ```
61
- # File: bios.rb | Line: 56
62
- # Definition: def date
64
+ # File: bios.rb | Line: 56
65
+ # Definition: def date
63
66
  LinuxStat::BIOS.date()
64
67
  => "04/10/2017"
65
68
 
66
- # File: bios.rb | Line: 10
67
- # Definition: def model
69
+ # File: bios.rb | Line: 10
70
+ # Definition: def model
68
71
  LinuxStat::BIOS.model()
69
72
  => "Inspiron 5567"
70
73
 
71
- # File: bios.rb | Line: 27
72
- # Definition: def vendor
74
+ # File: bios.rb | Line: 27
75
+ # Definition: def vendor
73
76
  LinuxStat::BIOS.vendor()
74
77
  => "Dell Inc."
75
78
 
76
- # File: bios.rb | Line: 42
77
- # Definition: def version
79
+ # File: bios.rb | Line: 42
80
+ # Definition: def version
78
81
  LinuxStat::BIOS.version()
79
82
  => "1.1.2"
80
83
 
@@ -82,197 +85,242 @@ LinuxStat::BIOS.version()
82
85
 
83
86
  ### LinuxStat::Battery
84
87
  ```
85
- # File: battery.rb | Line: 100
86
- # Definition: def charge
88
+ # File: battery.rb | Line: 105
89
+ # Definition: def charge
87
90
  LinuxStat::Battery.charge()
88
91
  => 100.0
89
92
 
90
- # File: battery.rb | Line: 73
91
- # Definition: def charging?
93
+ # File: battery.rb | Line: 122
94
+ # Definition: def charge_full_design_wh
95
+ LinuxStat::Battery.charge_full_design_wh()
96
+ => 42.0
97
+
98
+ # File: battery.rb | Line: 141
99
+ # Definition: def charge_full_wh
100
+ LinuxStat::Battery.charge_full_wh()
101
+ => 23.79
102
+
103
+ # File: battery.rb | Line: 78
104
+ # Definition: def charging?
92
105
  LinuxStat::Battery.charging?()
93
106
  => true
94
107
 
95
- # File: battery.rb | Line: 82
96
- # Definition: def discharging?
108
+ # File: battery.rb | Line: 184
109
+ # Definition: def devices_stat
110
+ LinuxStat::Battery.devices_stat()
111
+ => {:AC=>{:type=>"Mains", :online=>1}, :BAT0=>{:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :type=>"Battery", :status=>"Full", :capacity=>100, :voltage_min_design=>11.4, :charge_full_design=>3.684, :charge_full_design_wh=>42.0, :voltage_now=>12....
112
+
113
+ # File: battery.rb | Line: 87
114
+ # Definition: def discharging?
97
115
  LinuxStat::Battery.discharging?()
98
116
  => false
99
117
 
100
- # File: battery.rb | Line: 91
101
- # Definition: def full?
118
+ # File: battery.rb | Line: 96
119
+ # Definition: def full?
102
120
  LinuxStat::Battery.full?()
103
121
  => true
104
122
 
105
- # File: battery.rb | Line: 45
106
- # Definition: def manufacturer
123
+ # File: battery.rb | Line: 47
124
+ # Definition: def manufacturer
107
125
  LinuxStat::Battery.manufacturer()
108
126
  => "Samsung SDI"
109
127
 
110
- # File: battery.rb | Line: 36
111
- # Definition: def model
128
+ # File: battery.rb | Line: 36
129
+ # Definition: def model
112
130
  LinuxStat::Battery.model()
113
131
  => "DELL CYMGM77"
114
132
 
115
- # File: battery.rb | Line: 8
116
- # Definition: def present?
133
+ # File: battery.rb | Line: 8
134
+ # Definition: def present?
117
135
  LinuxStat::Battery.present?()
118
136
  => true
119
137
 
120
- # File: battery.rb | Line: 16
121
- # Definition: def stat
138
+ # File: battery.rb | Line: 16
139
+ # Definition: def stat
122
140
  LinuxStat::Battery.stat()
123
141
  => {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Full", :charge=>100.0, :charging=>true, :discharging=>false, :full=>true}
124
142
 
125
- # File: battery.rb | Line: 64
126
- # Definition: def status
143
+ # File: battery.rb | Line: 68
144
+ # Definition: def status
127
145
  LinuxStat::Battery.status()
128
146
  => "Full"
129
147
 
130
- # File: battery.rb | Line: 54
131
- # Definition: def technology
148
+ # File: battery.rb | Line: 57
149
+ # Definition: def technology
132
150
  LinuxStat::Battery.technology()
133
151
  => "Li-ion"
134
152
 
153
+ # File: battery.rb | Line: 160
154
+ # Definition: def voltage_now
155
+ LinuxStat::Battery.voltage_now()
156
+ => 12.453
157
+
135
158
  ```
136
159
 
137
160
  ### LinuxStat::CPU
138
161
  ```
139
- # File: cpu.rb | Line: 95
140
- # Definition: def count
162
+ # File: cpu.rb | Line: 287
163
+ # Definition: def available_governors
164
+ LinuxStat::CPU.available_governors()
165
+ => {"cpu0"=>["performance", "powersave"], "cpu1"=>["performance", "powersave"], "cpu2"=>["performance", "powersave"], "cpu3"=>["performance", "powersave"]}
166
+
167
+ # File: cpu.rb | Line: 86
168
+ # Definition: def count
141
169
  LinuxStat::CPU.count()
142
170
  => 4
143
171
 
144
- # File: cpu.rb | Line: 116
145
- # Definition: def cur_freq
172
+ # File: cpu.rb | Line: 103
173
+ # Definition: def count_online
174
+ LinuxStat::CPU.count_online()
175
+ => 4
176
+
177
+ # File: cpu.rb | Line: 197
178
+ # Definition: def cur_freq
146
179
  LinuxStat::CPU.cur_freq()
147
- => [2000141, 2000023, 1999435, 2000128]
180
+ => {"cpu0"=>1971347, "cpu1"=>2000253, "cpu2"=>1916631, "cpu3"=>2000064}
181
+
182
+ # File: cpu.rb | Line: 265
183
+ # Definition: def governor
184
+ LinuxStat::CPU.governor()
185
+ => {"cpu0"=>"performance", "cpu1"=>"performance", "cpu2"=>"performance", "cpu3"=>"performance"}
148
186
 
149
- # File: cpu.rb | Line: 131
150
- # Definition: def max_freq
187
+ # File: cpu.rb | Line: 241
188
+ # Definition: def max_freq
151
189
  LinuxStat::CPU.max_freq()
152
- => [2000000, 2000000, 2000000, 2000000]
190
+ => {"cpu0"=>2000000, "cpu1"=>2000000, "cpu2"=>2000000, "cpu3"=>2000000}
191
+
192
+ # File: cpu.rb | Line: 219
193
+ # Definition: def min_freq
194
+ LinuxStat::CPU.min_freq()
195
+ => {"cpu0"=>2000000, "cpu1"=>2000000, "cpu2"=>2000000, "cpu3"=>2000000}
153
196
 
154
- # File: cpu.rb | Line: 108
155
- # Definition: def model
197
+ # File: cpu.rb | Line: 184
198
+ # Definition: def model
156
199
  LinuxStat::CPU.model()
157
200
  => "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
158
201
 
159
- # File: cpu.rb | Line: 84
160
- # Definition: def online
202
+ # File: cpu.rb | Line: 163
203
+ # Definition: def offline
204
+ LinuxStat::CPU.offline()
205
+ => []
206
+
207
+ # File: cpu.rb | Line: 132
208
+ # Definition: def online
161
209
  LinuxStat::CPU.online()
162
- => 4
210
+ => [0, 1, 2, 3]
163
211
 
164
- # File: cpu.rb | Line: 21
165
- # Definition: def stat(sleep = ticks_to_ms_t5)
212
+ # File: cpu.rb | Line: 23
213
+ # Definition: def stat(sleep = ticks_to_ms_t5)
166
214
  LinuxStat::CPU.stat(sleep)
167
- => {0=>5.26, 1=>0.0, 2=>0.0, 3=>0.0, 4=>16.67}
215
+ => {0=>5.0, 1=>16.67, 2=>0.0, 3=>0.0, 4=>16.67}
168
216
 
169
- # File: cpu.rb | Line: 63
170
- # Definition: def total_usage(sleep = ticks_to_ms_t5)
217
+ # File: cpu.rb | Line: 63
218
+ # Definition: def total_usage(sleep = ticks_to_ms_t5)
171
219
  LinuxStat::CPU.total_usage(sleep)
172
- => 15.0
220
+ => 5.26
173
221
 
174
- # File: cpu.rb | Line: 63
175
- # Definition: def total_usage(sleep = ticks_to_ms_t5)
222
+ # File: cpu.rb | Line: 63
223
+ # Definition: def total_usage(sleep = ticks_to_ms_t5)
176
224
  LinuxStat::CPU.usage(sleep)
177
- => 10.0
225
+ => 9.52
178
226
 
179
- # File: cpu.rb | Line: 21
180
- # Definition: def stat(sleep = ticks_to_ms_t5)
227
+ # File: cpu.rb | Line: 23
228
+ # Definition: def stat(sleep = ticks_to_ms_t5)
181
229
  LinuxStat::CPU.usages(sleep)
182
- => {0=>15.0, 1=>20.0, 2=>0.0, 3=>20.0, 4=>20.0}
230
+ => {0=>5.26, 1=>16.67, 2=>0.0, 3=>0.0, 4=>0.0}
183
231
 
184
232
  ```
185
233
 
186
234
  ### LinuxStat::FS
187
235
  ```
188
236
  LinuxStat::FS.stat(arg = "/")
189
- => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>12798990, :block_avail_unpriv=>12798990, :inodes=>58612160, :free_inodes=>56966374, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
237
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>11703573, :block_avail_unpriv=>11703573, :inodes=>58612160, :free_inodes=>56863418, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
190
238
 
191
239
  ```
192
240
 
193
241
  ### LinuxStat::Filesystem
194
242
  ```
195
- # File: filesystem.rb | Line: 92
196
- # Definition: def available(fs = ?/.freeze)
243
+ # File: filesystem.rb | Line: 92
244
+ # Definition: def available(fs = ?..freeze)
197
245
  LinuxStat::Filesystem.available(fs)
198
- => 52424663040
246
+ => 47937835008
199
247
 
200
- # File: filesystem.rb | Line: 58
201
- # Definition: def free(fs = ?/.freeze)
248
+ # File: filesystem.rb | Line: 58
249
+ # Definition: def free(fs = ?..freeze)
202
250
  LinuxStat::Filesystem.free(fs)
203
- => 52424663040
251
+ => 47937835008
204
252
 
205
- # File: filesystem.rb | Line: 19
206
- # Definition: def stat(fs = ?/.freeze)
253
+ # File: filesystem.rb | Line: 19
254
+ # Definition: def stat(fs = ?..freeze)
207
255
  LinuxStat::Filesystem.stat(fs)
208
- => {:total=>119981191168, :free=>52424663040, :used=>67556528128}
256
+ => {:total=>119981191168, :free=>47937835008, :used=>72043356160}
209
257
 
210
- # File: filesystem.rb | Line: 108
211
- # Definition: def stat_raw(fs = ?/.freeze)
258
+ # File: filesystem.rb | Line: 108
259
+ # Definition: def stat_raw(fs = ?..freeze)
212
260
  LinuxStat::Filesystem.stat_raw(fs)
213
- => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>12798990, :block_avail_unpriv=>12798990, :inodes=>58612160, :free_inodes=>56966374, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
261
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>11703573, :block_avail_unpriv=>11703573, :inodes=>58612160, :free_inodes=>56863418, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
214
262
 
215
- # File: filesystem.rb | Line: 39
216
- # Definition: def total(fs = ?/.freeze)
263
+ # File: filesystem.rb | Line: 39
264
+ # Definition: def total(fs = ?..freeze)
217
265
  LinuxStat::Filesystem.total(fs)
218
266
  => 119981191168
219
267
 
220
- # File: filesystem.rb | Line: 73
221
- # Definition: def used(fs = ?/.freeze)
268
+ # File: filesystem.rb | Line: 73
269
+ # Definition: def used(fs = ?..freeze)
222
270
  LinuxStat::Filesystem.used(fs)
223
- => 67556528128
271
+ => 72043356160
224
272
 
225
273
  ```
226
274
 
227
275
  ### LinuxStat::Kernel
228
276
  ```
229
- # File: kernel.rb | Line: 86
230
- # Definition: def build_date
277
+ # File: kernel.rb | Line: 86
278
+ # Definition: def build_date
231
279
  LinuxStat::Kernel.build_date()
232
280
  => 2020-11-20 07:44:55 +0000
233
281
 
234
- # File: kernel.rb | Line: 140
235
- # Definition: def build_date_string
282
+ # File: kernel.rb | Line: 140
283
+ # Definition: def build_date_string
236
284
  LinuxStat::Kernel.build_date_string()
237
285
  => "20 Nov 2020 07:44:55 +0000"
238
286
 
239
- # File: kernel.rb | Line: 21
240
- # Definition: def build_user
287
+ # File: kernel.rb | Line: 21
288
+ # Definition: def build_user
241
289
  LinuxStat::Kernel.build_user()
242
290
  => "souravgoswami@archlinux"
243
291
 
244
- # File: kernel.rb | Line: 179
245
- # Definition: def ticks
292
+ # File: kernel.rb | Line: 179
293
+ # Definition: def ticks
246
294
  LinuxStat::Kernel.clk_tck()
247
295
  => 100
248
296
 
249
- # File: kernel.rb | Line: 33
250
- # Definition: def compiler
297
+ # File: kernel.rb | Line: 33
298
+ # Definition: def compiler
251
299
  LinuxStat::Kernel.compiler()
252
300
  => [:gcc, "10.2.0"]
253
301
 
254
- # File: kernel.rb | Line: 55
255
- # Definition: def compiler_version
302
+ # File: kernel.rb | Line: 55
303
+ # Definition: def compiler_version
256
304
  LinuxStat::Kernel.compiler_version()
257
305
  => "10.2.0"
258
306
 
259
- # File: kernel.rb | Line: 10
260
- # Definition: def version
307
+ # File: kernel.rb | Line: 10
308
+ # Definition: def version
261
309
  LinuxStat::Kernel.release()
262
310
  => "5.9.9-xanmod1-1"
263
311
 
264
- # File: kernel.rb | Line: 169
265
- # Definition: def string
312
+ # File: kernel.rb | Line: 169
313
+ # Definition: def string
266
314
  LinuxStat::Kernel.string()
267
315
  => "Linux version 5.9.9-xanmod1-1 (souravgoswami@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Fri, 20 Nov 2020 07:44:55 +0000"
268
316
 
269
- # File: kernel.rb | Line: 179
270
- # Definition: def ticks
317
+ # File: kernel.rb | Line: 179
318
+ # Definition: def ticks
271
319
  LinuxStat::Kernel.ticks()
272
320
  => 100
273
321
 
274
- # File: kernel.rb | Line: 10
275
- # Definition: def version
322
+ # File: kernel.rb | Line: 10
323
+ # Definition: def version
276
324
  LinuxStat::Kernel.version()
277
325
  => "5.9.9-xanmod1-1"
278
326
 
@@ -280,233 +328,233 @@ LinuxStat::Kernel.version()
280
328
 
281
329
  ### LinuxStat::Memory
282
330
  ```
283
- # File: memory.rb | Line: 50
284
- # Definition: def available
331
+ # File: memory.rb | Line: 50
332
+ # Definition: def available
285
333
  LinuxStat::Memory.available()
286
- => 842868
334
+ => 1597312
287
335
 
288
- # File: memory.rb | Line: 81
289
- # Definition: def percent_available
336
+ # File: memory.rb | Line: 81
337
+ # Definition: def percent_available
290
338
  LinuxStat::Memory.percent_available()
291
- => 21.97
339
+ => 41.64
292
340
 
293
- # File: memory.rb | Line: 70
294
- # Definition: def percent_used
341
+ # File: memory.rb | Line: 70
342
+ # Definition: def percent_used
295
343
  LinuxStat::Memory.percent_used()
296
- => 78.03
344
+ => 58.36
297
345
 
298
- # File: memory.rb | Line: 11
299
- # Definition: def stat
346
+ # File: memory.rb | Line: 11
347
+ # Definition: def stat
300
348
  LinuxStat::Memory.stat()
301
- => {:total=>3836236, :used=>2993368, :available=>842868, :percent_used=>78.03, :percent_available=>21.97}
349
+ => {:total=>3836236, :used=>2238924, :available=>1597312, :percent_used=>58.36, :percent_available=>41.64}
302
350
 
303
- # File: memory.rb | Line: 40
304
- # Definition: def total
351
+ # File: memory.rb | Line: 40
352
+ # Definition: def total
305
353
  LinuxStat::Memory.total()
306
354
  => 3836236
307
355
 
308
- # File: memory.rb | Line: 60
309
- # Definition: def used
356
+ # File: memory.rb | Line: 60
357
+ # Definition: def used
310
358
  LinuxStat::Memory.used()
311
- => 2993368
359
+ => 2238924
312
360
 
313
361
  ```
314
362
 
315
363
  ### LinuxStat::Mounts
316
364
  ```
317
- # File: mounts.rb | Line: 179
318
- # Definition: def device_stat(dev = root)
365
+ # File: mounts.rb | Line: 179
366
+ # Definition: def device_stat(dev = root)
319
367
  LinuxStat::Mounts.device_stat(dev)
320
- => {:mountpoint=>"/", :total=>119981191168, :free=>52424663040, :available=>52424663040, :used=>67556528128, :percent_used=>56.31, :percent_free=>43.69, :percent_available=>43.69}
368
+ => {:mountpoint=>"/", :total=>119981191168, :free=>47937835008, :available=>47937835008, :used=>72043356160, :percent_used=>60.05, :percent_free=>39.95, :percent_available=>39.95}
321
369
 
322
- # File: mounts.rb | Line: 137
323
- # Definition: def devices_stat
370
+ # File: mounts.rb | Line: 137
371
+ # Definition: def devices_stat
324
372
  LinuxStat::Mounts.devices_stat()
325
373
  => {"proc"=>{:mountpoint=>"/proc", :total=>0, :free=>0, :available=>0, :used=>0, :percent_used=>NaN, :percent_free=>NaN, :percent_available=>NaN}, "sys"=>{:mountpoint=>"/sys", :total=>0, :free=>0, :available=>0, :used=>0, :percent_used=>NaN, :percent_fre...
326
374
 
327
- # File: mounts.rb | Line: 11
328
- # Definition: def list
375
+ # File: mounts.rb | Line: 11
376
+ # Definition: def list
329
377
  LinuxStat::Mounts.list()
330
378
  => ["proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0", "sys /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0", "dev /dev devtmpfs rw,nosuid,relatime,size=1892904k,nr_inodes=473226,mode=755 0 0", "run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0", "...
331
379
 
332
- # File: mounts.rb | Line: 20
333
- # Definition: def list_devices
380
+ # File: mounts.rb | Line: 20
381
+ # Definition: def list_devices
334
382
  LinuxStat::Mounts.list_devices()
335
383
  => ["proc", "sys", "dev", "run", "/dev/sda2", "securityfs", "tmpfs", "devpts", "tmpfs", "cgroup2", "cgroup", "pstore", "none", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "systemd-1", "tra...
336
384
 
337
- # File: mounts.rb | Line: 109
338
- # Definition: def list_devices_mount_point
385
+ # File: mounts.rb | Line: 109
386
+ # Definition: def list_devices_mount_point
339
387
  LinuxStat::Mounts.list_devices_mount_point()
340
- => {"proc"=>"/proc", "sys"=>"/sys", "dev"=>"/dev", "run"=>"/run", "/dev/sda2"=>"/", "securityfs"=>"/sys/kernel/security", "tmpfs"=>"/run/user/1000", "devpts"=>"/dev/pts", "cgroup2"=>"/sys/fs/cgroup/unified", "cgroup"=>"/sys/fs/cgroup/blkio", "pstore"=>"/...
388
+ => {"proc"=>"/proc", "sys"=>"/sys", "dev"=>"/dev", "run"=>"/run", "/dev/sda2"=>"/", "securityfs"=>"/sys/kernel/security", "tmpfs"=>"/run/user/1000", "devpts"=>"/dev/pts", "cgroup2"=>"/sys/fs/cgroup/unified", "cgroup"=>"/sys/fs/cgroup/memory", "pstore"=>"...
341
389
 
342
- # File: mounts.rb | Line: 80
343
- # Definition: def mount_point(dev = root)
390
+ # File: mounts.rb | Line: 80
391
+ # Definition: def mount_point(dev = root)
344
392
  LinuxStat::Mounts.mount_point(dev)
345
393
  => "/"
346
394
 
347
- # File: mounts.rb | Line: 29
348
- # Definition: def root
395
+ # File: mounts.rb | Line: 29
396
+ # Definition: def root
349
397
  LinuxStat::Mounts.root()
350
398
  => "/dev/sda2"
351
399
 
352
- # File: mounts.rb | Line: 38
353
- # Definition: def root_fs
400
+ # File: mounts.rb | Line: 38
401
+ # Definition: def root_fs
354
402
  LinuxStat::Mounts.root_fs()
355
403
  => "xfs"
356
404
 
357
- # File: mounts.rb | Line: 47
358
- # Definition: def root_mount_options
405
+ # File: mounts.rb | Line: 47
406
+ # Definition: def root_mount_options
359
407
  LinuxStat::Mounts.root_mount_options()
360
408
  => "rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota"
361
409
 
362
- # File: mounts.rb | Line: 56
363
- # Definition: def tmpfs
410
+ # File: mounts.rb | Line: 56
411
+ # Definition: def tmpfs
364
412
  LinuxStat::Mounts.tmpfs()
365
- => {"/dev/shm"=>"tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0", "/sys/fs/cgroup"=>"tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755 0 0", "/cache"=>"tmpfs /cache tmpfs rw,nosuid,nodev,relatime,size=2097152k 0 0", "/tmp"=>"...
413
+ => {"/dev/shm"=>"tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0", "/sys/fs/cgroup"=>"tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755 0 0", "/cache"=>"tmpfs /cache tmpfs rw,nosuid,nodev,relatime,size=2097152k 0 0", "/ramdisk...
366
414
 
367
415
  ```
368
416
 
369
417
  ### LinuxStat::Net
370
418
  ```
371
- # File: net.rb | Line: 80
372
- # Definition: def usage(interval = 0.1)
419
+ # File: net.rb | Line: 80
420
+ # Definition: def usage(interval = 0.1)
373
421
  LinuxStat::Net.current_usage(interval)
374
- => {:received=>61200.0, :transmitted=>1880.0}
422
+ => {:received=>0.0, :transmitted=>0.0}
375
423
 
376
- # File: net.rb | Line: 10
377
- # Definition: def ipv4_private
424
+ # File: net.rb | Line: 10
425
+ # Definition: def ipv4_private
378
426
  LinuxStat::Net.ipv4_private()
379
427
  => "192.168.0.102"
380
428
 
381
- # File: net.rb | Line: 23
382
- # Definition: def total_bytes
429
+ # File: net.rb | Line: 23
430
+ # Definition: def total_bytes
383
431
  LinuxStat::Net.total_bytes()
384
- => {:received=>1112357335, :transmitted=>289215998}
432
+ => {:received=>687677565, :transmitted=>149550163}
385
433
 
386
- # File: net.rb | Line: 41
387
- # Definition: def total_bytes_received
434
+ # File: net.rb | Line: 41
435
+ # Definition: def total_bytes_received
388
436
  LinuxStat::Net.total_bytes_received()
389
- => 1112357335
437
+ => 687677565
390
438
 
391
- # File: net.rb | Line: 54
392
- # Definition: def total_bytes_transmitted
439
+ # File: net.rb | Line: 54
440
+ # Definition: def total_bytes_transmitted
393
441
  LinuxStat::Net.total_bytes_transmitted()
394
- => 289215998
442
+ => 149550163
395
443
 
396
- # File: net.rb | Line: 80
397
- # Definition: def usage(interval = 0.1)
444
+ # File: net.rb | Line: 80
445
+ # Definition: def usage(interval = 0.1)
398
446
  LinuxStat::Net.usage(interval)
399
- => {:received=>61200.0, :transmitted=>1880.0}
447
+ => {:received=>0.0, :transmitted=>0.0}
400
448
 
401
449
  ```
402
450
 
403
451
  ### LinuxStat::OS
404
452
  ```
405
- # File: os.rb | Line: 97
406
- # Definition: def bits
453
+ # File: os.rb | Line: 97
454
+ # Definition: def bits
407
455
  LinuxStat::OS.bits()
408
456
  => 64
409
457
 
410
- # File: os.rb | Line: 42
411
- # Definition: def distribution
458
+ # File: os.rb | Line: 42
459
+ # Definition: def distribution
412
460
  LinuxStat::OS.distribution()
413
461
  => "Arch Linux"
414
462
 
415
- # File: os.rb | Line: 81
416
- # Definition: def hostname
463
+ # File: os.rb | Line: 81
464
+ # Definition: def hostname
417
465
  LinuxStat::OS.hostname()
418
466
  => "archlinux"
419
467
 
420
- # File: os.rb | Line: 30
421
- # Definition: def lsb_release
468
+ # File: os.rb | Line: 30
469
+ # Definition: def lsb_release
422
470
  LinuxStat::OS.lsb_release()
423
471
  => {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
424
472
 
425
- # File: os.rb | Line: 64
426
- # Definition: def machine
473
+ # File: os.rb | Line: 64
474
+ # Definition: def machine
427
475
  LinuxStat::OS.machine()
428
476
  => "x86_64"
429
477
 
430
- # File: os.rb | Line: 72
431
- # Definition: def nodename
478
+ # File: os.rb | Line: 72
479
+ # Definition: def nodename
432
480
  LinuxStat::OS.nodename()
433
481
  => "archlinux"
434
482
 
435
- # File: os.rb | Line: 15
436
- # Definition: def os_release
483
+ # File: os.rb | Line: 15
484
+ # Definition: def os_release
437
485
  LinuxStat::OS.os_release()
438
486
  => {:NAME=>"Arch Linux", :PRETTY_NAME=>"Arch Linux", :ID=>"arch", :BUILD_ID=>"rolling", :ANSI_COLOR=>"38;2;23;147;209", :HOME_URL=>"https://www.archlinux.org/", :DOCUMENTATION_URL=>"https://wiki.archlinux.org/", :SUPPORT_URL=>"https://bbs.archlinux.org/"...
439
487
 
440
- # File: os.rb | Line: 110
441
- # Definition: def uptime
488
+ # File: os.rb | Line: 110
489
+ # Definition: def uptime
442
490
  LinuxStat::OS.uptime()
443
- => {:hour=>10, :minute=>49, :second=>25.48}
491
+ => {:hour=>6, :minute=>50, :second=>39.61}
444
492
 
445
493
  ```
446
494
 
447
495
  ### LinuxStat::PrettifyBytes
448
496
  ```
449
- # File: prettify_bytes.rb | Line: 42
450
- # Definition: def convert_binary(n)
451
- LinuxStat::PrettifyBytes.convert_binary(n = 304432464364884)
452
- => "276.88 tebibytes"
497
+ # File: prettify_bytes.rb | Line: 42
498
+ # Definition: def convert_binary(n)
499
+ LinuxStat::PrettifyBytes.convert_binary(n = 200152828322898)
500
+ => "182.04 tebibytes"
453
501
 
454
- # File: prettify_bytes.rb | Line: 19
455
- # Definition: def convert_decimal(n)
456
- LinuxStat::PrettifyBytes.convert_decimal(n = 49306758655424)
457
- => "49.31 terabytes"
502
+ # File: prettify_bytes.rb | Line: 19
503
+ # Definition: def convert_decimal(n)
504
+ LinuxStat::PrettifyBytes.convert_decimal(n = 434440373786022)
505
+ => "434.44 terabytes"
458
506
 
459
- # File: prettify_bytes.rb | Line: 90
460
- # Definition: def convert_short_binary(n)
461
- LinuxStat::PrettifyBytes.convert_short_binary(n = 361176129377179)
462
- => "328.49 TiB"
507
+ # File: prettify_bytes.rb | Line: 90
508
+ # Definition: def convert_short_binary(n)
509
+ LinuxStat::PrettifyBytes.convert_short_binary(n = 88309228425306)
510
+ => "80.32 TiB"
463
511
 
464
- # File: prettify_bytes.rb | Line: 65
465
- # Definition: def convert_short_decimal(n)
466
- LinuxStat::PrettifyBytes.convert_short_decimal(n = 293690574885959)
467
- => "293.69 TB"
512
+ # File: prettify_bytes.rb | Line: 65
513
+ # Definition: def convert_short_decimal(n)
514
+ LinuxStat::PrettifyBytes.convert_short_decimal(n = 238518247519978)
515
+ => "238.52 TB"
468
516
 
469
517
  ```
470
518
 
471
519
  ### LinuxStat::Process
472
520
  ```
473
- # File: process.rb | Line: 19
474
- # Definition: def count
521
+ # File: process.rb | Line: 19
522
+ # Definition: def count
475
523
  LinuxStat::Process.count()
476
- => 215
524
+ => 195
477
525
 
478
- # File: process.rb | Line: 71
479
- # Definition: def idle
526
+ # File: process.rb | Line: 71
527
+ # Definition: def idle
480
528
  LinuxStat::Process.idle()
481
- => [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 119, 121, 131, 134, 140, 152, 153, 169, 171, 173, 174, 177, 178, 183, 184, 185, 186, 187, 188, 231, 271, 373, 383, 18595, 21393, 21394, 21395, 21396, 21397, 21398,...
529
+ => [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 119, 121, 131, 134, 140, 152, 153, 173, 175, 177, 180, 182, 186, 187, 188, 189, 190, 191, 193, 237, 273, 325, 329, 335, 9051, 9055, 9056, 9057, 9058, 9059, 9060, 13...
482
530
 
483
- # File: process.rb | Line: 8
484
- # Definition: def list
531
+ # File: process.rb | Line: 8
532
+ # Definition: def list
485
533
  LinuxStat::Process.list()
486
- => [1, 2, 3, 4, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 46, 47, 48, 49, 50, 51, 52, 102, 103, 104, 106, 107, 108, 109, 110, 111, 114, 115, 117, 118, 119, 121, 131, 134,...
534
+ => [1, 2, 3, 4, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 46, 47, 48, 49, 50, 51, 52, 102, 103, 104, 106, 107, 108, 109, 110, 112, 114, 115, 117, 118, 119, 121, 131, 134,...
487
535
 
488
- # File: process.rb | Line: 25
489
- # Definition: def names
536
+ # File: process.rb | Line: 25
537
+ # Definition: def names
490
538
  LinuxStat::Process.names()
491
539
  => {1=>"systemd", 2=>"kthreadd", 3=>"rcu_gp", 4=>"rcu_par_gp", 6=>"kworker/0:0H-kblockd", 9=>"mm_percpu_wq", 10=>"ksoftirqd/0", 11=>"rcuc/0", 12=>"rcu_preempt", 13=>"rcub/0", 14=>"migration/0", 15=>"idle_inject/0", 16=>"cpuhp/0", 17=>"cpuhp/1", 18=>"idle...
492
540
 
493
- # File: process.rb | Line: 97
494
- # Definition: def running
541
+ # File: process.rb | Line: 97
542
+ # Definition: def running
495
543
  LinuxStat::Process.running()
496
- => [25641, 33756]
544
+ => [15978]
497
545
 
498
- # File: process.rb | Line: 58
499
- # Definition: def sleeping
546
+ # File: process.rb | Line: 58
547
+ # Definition: def sleeping
500
548
  LinuxStat::Process.sleeping()
501
- => [1, 2, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 38, 40, 41, 42, 46, 47, 48, 50, 51, 52, 111, 114, 115, 168, 170, 189, 218, 235, 301, 305, 309, 310, 311, 314, 315, 316, 317, 331, 334, 337, 403, 407, 409, 410,...
549
+ => [1, 2, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 38, 40, 41, 42, 46, 47, 48, 50, 51, 52, 112, 114, 115, 172, 174, 192, 222, 238, 310, 311, 312, 313, 315, 324, 327, 332, 333, 334, 336, 347, 349, 351, 384, 412,...
502
550
 
503
- # File: process.rb | Line: 37
504
- # Definition: def types
551
+ # File: process.rb | Line: 37
552
+ # Definition: def types
505
553
  LinuxStat::Process.types()
506
554
  => {1=>:sleeping, 2=>:sleeping, 3=>:idle, 4=>:idle, 6=>:idle, 9=>:idle, 10=>:sleeping, 11=>:sleeping, 12=>:idle, 13=>:sleeping, 14=>:sleeping, 15=>:sleeping, 16=>:sleeping, 17=>:sleeping, 18=>:sleeping, 19=>:sleeping, 20=>:sleeping, 21=>:sleeping, 23=>:i...
507
555
 
508
- # File: process.rb | Line: 84
509
- # Definition: def zombie
556
+ # File: process.rb | Line: 84
557
+ # Definition: def zombie
510
558
  LinuxStat::Process.zombie()
511
559
  => []
512
560
 
@@ -514,156 +562,166 @@ LinuxStat::Process.zombie()
514
562
 
515
563
  ### LinuxStat::ProcessInfo
516
564
  ```
517
- # File: process_info.rb | Line: 54
518
- # Definition: def cmdline(pid = $$)
565
+ # File: process_info.rb | Line: 54
566
+ # Definition: def cmdline(pid = $$)
519
567
  LinuxStat::ProcessInfo.cmdline(pid)
520
- => "ruby /usr/bin/linuxstat.rb -md"
568
+ => "/usr/bin/ruby /home/sourav/.gem/ruby/2.7.0/bin/linuxstat.rb -md"
521
569
 
522
- # File: process_info.rb | Line: 78
523
- # Definition: def command_name(pid = $$)
570
+ # File: process_info.rb | Line: 78
571
+ # Definition: def command_name(pid = $$)
524
572
  LinuxStat::ProcessInfo.command_name(pid)
525
573
  => "ruby"
526
574
 
527
- # File: process_info.rb | Line: 247
528
- # Definition: def cpu_stat(pid: $$, sleep: ticks_to_ms_t5)
575
+ # File: process_info.rb | Line: 640
576
+ # Definition: def nproc(pid = $$)
577
+ LinuxStat::ProcessInfo.count_cpu(pid)
578
+ => 4
579
+
580
+ # File: process_info.rb | Line: 247
581
+ # Definition: def cpu_stat(pid: $$, sleep: ticks_to_ms_t5)
529
582
  LinuxStat::ProcessInfo.cpu_stat(pid:, sleep:)
530
- => {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>2}
583
+ => {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>3}
531
584
 
532
- # File: process_info.rb | Line: 301
533
- # Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
585
+ # File: process_info.rb | Line: 307
586
+ # Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
534
587
  LinuxStat::ProcessInfo.cpu_usage(pid:, sleep:)
535
588
  => 0.0
536
589
 
537
- # File: process_info.rb | Line: 454
538
- # Definition: def gid(pid = $$)
590
+ # File: process_info.rb | Line: 470
591
+ # Definition: def gid(pid = $$)
539
592
  LinuxStat::ProcessInfo.gid(pid)
540
593
  => {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
541
594
 
542
- # File: process_info.rb | Line: 417
543
- # Definition: def last_executed_cpu(pid = $$)
595
+ # File: process_info.rb | Line: 433
596
+ # Definition: def last_executed_cpu(pid = $$)
544
597
  LinuxStat::ProcessInfo.last_executed_cpu(pid)
545
- => 2
598
+ => 3
546
599
 
547
- # File: process_info.rb | Line: 114
548
- # Definition: def mem_stat(pid = $$)
600
+ # File: process_info.rb | Line: 114
601
+ # Definition: def mem_stat(pid = $$)
549
602
  LinuxStat::ProcessInfo.mem_stat(pid)
550
- => {:memory=>12292.096, :virtual_memory=>84049.92, :resident_memory=>18128.896}
603
+ => {:memory=>12627.968, :virtual_memory=>84221.952, :resident_memory=>18743.296}
551
604
 
552
- # File: process_info.rb | Line: 147
553
- # Definition: def memory(pid = $$)
605
+ # File: process_info.rb | Line: 147
606
+ # Definition: def memory(pid = $$)
554
607
  LinuxStat::ProcessInfo.memory(pid)
555
- => 12292.096
608
+ => 12627.968
556
609
 
557
- # File: process_info.rb | Line: 588
558
- # Definition: def nice(pid = $$)
610
+ # File: process_info.rb | Line: 607
611
+ # Definition: def nice(pid = $$)
559
612
  LinuxStat::ProcessInfo.nice(pid)
560
613
  => 0
561
614
 
562
- # File: process_info.rb | Line: 475
563
- # Definition: def owner(pid = $$)
615
+ # File: process_info.rb | Line: 640
616
+ # Definition: def nproc(pid = $$)
617
+ LinuxStat::ProcessInfo.nproc(pid)
618
+ => 4
619
+
620
+ # File: process_info.rb | Line: 491
621
+ # Definition: def owner(pid = $$)
564
622
  LinuxStat::ProcessInfo.owner(pid)
565
623
  => "sourav"
566
624
 
567
- # File: process_info.rb | Line: 197
568
- # Definition: def resident_memory(pid = $$)
625
+ # File: process_info.rb | Line: 197
626
+ # Definition: def resident_memory(pid = $$)
569
627
  LinuxStat::ProcessInfo.resident_memory(pid)
570
- => 18128.896
628
+ => 18743.296
571
629
 
572
- # File: process_info.rb | Line: 545
573
- # Definition: def running_time(pid = $$)
630
+ # File: process_info.rb | Line: 563
631
+ # Definition: def running_time(pid = $$)
574
632
  LinuxStat::ProcessInfo.running_time(pid)
575
- => 1.639999999999418
633
+ => 0.8
576
634
 
577
- # File: process_info.rb | Line: 528
578
- # Definition: def start_time(pid = $$)
635
+ # File: process_info.rb | Line: 544
636
+ # Definition: def start_time(pid = $$)
579
637
  LinuxStat::ProcessInfo.start_time(pid)
580
- => 2020-12-17 21:56:57 +0530
638
+ => 2020-12-24 19:05:51 +0530
581
639
 
582
- # File: process_info.rb | Line: 497
583
- # Definition: def start_time_epoch(pid = $$)
640
+ # File: process_info.rb | Line: 513
641
+ # Definition: def start_time_epoch(pid = $$)
584
642
  LinuxStat::ProcessInfo.start_time_epoch(pid)
585
- => 1608222417
643
+ => 1608816951
586
644
 
587
- # File: process_info.rb | Line: 573
588
- # Definition: def state(pid = $$)
645
+ # File: process_info.rb | Line: 592
646
+ # Definition: def state(pid = $$)
589
647
  LinuxStat::ProcessInfo.state(pid)
590
648
  => "R"
591
649
 
592
- # File: process_info.rb | Line: 349
593
- # Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
650
+ # File: process_info.rb | Line: 359
651
+ # Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
594
652
  LinuxStat::ProcessInfo.thread_usage(pid:, sleep:)
595
653
  => 0.0
596
654
 
597
- # File: process_info.rb | Line: 392
598
- # Definition: def threads(pid = $$)
655
+ # File: process_info.rb | Line: 408
656
+ # Definition: def threads(pid = $$)
599
657
  LinuxStat::ProcessInfo.threads(pid)
600
658
  => 1
601
659
 
602
- # File: process_info.rb | Line: 23
603
- # Definition: def total_io(pid = $$)
660
+ # File: process_info.rb | Line: 23
661
+ # Definition: def total_io(pid = $$)
604
662
  LinuxStat::ProcessInfo.total_io(pid)
605
- => {:read_bytes=>253952, :write_bytes=>0}
663
+ => {:read_bytes=>0, :write_bytes=>0}
606
664
 
607
- # File: process_info.rb | Line: 430
608
- # Definition: def uid(pid = $$)
665
+ # File: process_info.rb | Line: 446
666
+ # Definition: def uid(pid = $$)
609
667
  LinuxStat::ProcessInfo.uid(pid)
610
668
  => {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
611
669
 
612
- # File: process_info.rb | Line: 172
613
- # Definition: def virtual_memory(pid = $$)
670
+ # File: process_info.rb | Line: 172
671
+ # Definition: def virtual_memory(pid = $$)
614
672
  LinuxStat::ProcessInfo.virtual_memory(pid)
615
- => 84049.92
673
+ => 84221.952
616
674
 
617
675
  ```
618
676
 
619
677
  ### LinuxStat::Swap
620
678
  ```
621
- # File: swap.rb | Line: 22
622
- # Definition: def any?
679
+ # File: swap.rb | Line: 22
680
+ # Definition: def any?
623
681
  LinuxStat::Swap.any?()
624
682
  => true
625
683
 
626
- # File: swap.rb | Line: 68
627
- # Definition: def available
684
+ # File: swap.rb | Line: 68
685
+ # Definition: def available
628
686
  LinuxStat::Swap.available()
629
- => 3681532
687
+ => 4064380
630
688
 
631
- # File: swap.rb | Line: 8
632
- # Definition: def list
689
+ # File: swap.rb | Line: 8
690
+ # Definition: def list
633
691
  LinuxStat::Swap.list()
634
- => {"/dev/zram0"=>[:partition, 4194300, 512768, -2]}
692
+ => {"/dev/zram0"=>[:partition, 4194300, 129920, -2]}
635
693
 
636
- # File: swap.rb | Line: 103
637
- # Definition: def percent_available
694
+ # File: swap.rb | Line: 103
695
+ # Definition: def percent_available
638
696
  LinuxStat::Swap.percent_available()
639
- => 87.77
697
+ => 96.9
640
698
 
641
- # File: swap.rb | Line: 89
642
- # Definition: def percent_used
699
+ # File: swap.rb | Line: 89
700
+ # Definition: def percent_used
643
701
  LinuxStat::Swap.percent_used()
644
- => 12.23
702
+ => 3.1
645
703
 
646
- # File: swap.rb | Line: 32
647
- # Definition: def stat
704
+ # File: swap.rb | Line: 32
705
+ # Definition: def stat
648
706
  LinuxStat::Swap.stat()
649
- => {:total=>4194300, :used=>512768, :available=>3681532, :percent_used=>12.23, :percent_available=>87.77}
707
+ => {:total=>4194300, :used=>129920, :available=>4064380, :percent_used=>3.1, :percent_available=>96.9}
650
708
 
651
- # File: swap.rb | Line: 57
652
- # Definition: def total
709
+ # File: swap.rb | Line: 57
710
+ # Definition: def total
653
711
  LinuxStat::Swap.total()
654
712
  => 4194300
655
713
 
656
- # File: swap.rb | Line: 80
657
- # Definition: def used
714
+ # File: swap.rb | Line: 80
715
+ # Definition: def used
658
716
  LinuxStat::Swap.used()
659
- => 512768
717
+ => 129920
660
718
 
661
719
  ```
662
720
 
663
721
  ### LinuxStat::Sysconf
664
722
  ```
665
723
  LinuxStat::Sysconf.child_max()
666
- => 2000000
724
+ => nil
667
725
 
668
726
  LinuxStat::Sysconf.expr_nest_max()
669
727
  => 32
@@ -699,7 +757,7 @@ LinuxStat::Sysconf.pagesize()
699
757
  => 4096
700
758
 
701
759
  LinuxStat::Sysconf.posix_version()
702
- => 200809
760
+ => 4201
703
761
 
704
762
  LinuxStat::Sysconf.processor_configured()
705
763
  => 4
@@ -718,6 +776,25 @@ LinuxStat::Sysconf.tty_name_max()
718
776
 
719
777
  ```
720
778
 
779
+ ### LinuxStat::USB
780
+ ```
781
+ # File: usb.rb | Line: 74
782
+ # Definition: def count
783
+ LinuxStat::USB.count()
784
+ => 10
785
+
786
+ # File: usb.rb | Line: 74
787
+ # Definition: def count
788
+ LinuxStat::USB.count_devices()
789
+ => 10
790
+
791
+ # File: usb.rb | Line: 4
792
+ # Definition: def devices_stat(hwdata: true)
793
+ LinuxStat::USB.devices_stat(hwdata:)
794
+ => [{:path=>"/sys/bus/usb/devices/1-1.2/", :id=>"04d9:1203", :vendor_id=>"04d9", :product_id=>"1203", :bus_num=>1, :dev_num=>4, :hwdata=>{:vendor=>"Holtek Semiconductor, Inc.", :product=>"Keyboard"}, :authorized=>true, :b_max_power=>"100mA", :b_max_packe...
795
+
796
+ ```
797
+
721
798
  ### LinuxStat::Uname
722
799
  ```
723
800
  LinuxStat::Uname.machine()
@@ -739,93 +816,93 @@ LinuxStat::Uname.version()
739
816
 
740
817
  ### LinuxStat::User
741
818
  ```
742
- # File: user.rb | Line: 98
743
- # Definition: def get_user
819
+ # File: user.rb | Line: 98
820
+ # Definition: def get_user
744
821
  LinuxStat::User.get_current_user()
745
822
  => "sourav"
746
823
 
747
- # File: user.rb | Line: 137
748
- # Definition: def get_euid
824
+ # File: user.rb | Line: 137
825
+ # Definition: def get_euid
749
826
  LinuxStat::User.get_euid()
750
827
  => 1000
751
828
 
752
- # File: user.rb | Line: 129
753
- # Definition: def get_gid
829
+ # File: user.rb | Line: 129
830
+ # Definition: def get_gid
754
831
  LinuxStat::User.get_gid()
755
832
  => 1000
756
833
 
757
- # File: user.rb | Line: 152
758
- # Definition: def get_login
834
+ # File: user.rb | Line: 152
835
+ # Definition: def get_login
759
836
  LinuxStat::User.get_login()
760
837
  => "sourav"
761
838
 
762
- # File: user.rb | Line: 121
763
- # Definition: def get_uid
839
+ # File: user.rb | Line: 121
840
+ # Definition: def get_uid
764
841
  LinuxStat::User.get_uid()
765
842
  => 1000
766
843
 
767
- # File: user.rb | Line: 98
768
- # Definition: def get_user
844
+ # File: user.rb | Line: 98
845
+ # Definition: def get_user
769
846
  LinuxStat::User.get_user()
770
847
  => "sourav"
771
848
 
772
- # File: user.rb | Line: 215
773
- # Definition: def gid_by_username(username = get_user)
849
+ # File: user.rb | Line: 215
850
+ # Definition: def gid_by_username(username = get_user)
774
851
  LinuxStat::User.gid_by_username(username)
775
852
  => 1000
776
853
 
777
- # File: user.rb | Line: 56
778
- # Definition: def gids
854
+ # File: user.rb | Line: 56
855
+ # Definition: def gids
779
856
  LinuxStat::User.gids()
780
857
  => {:root=>0, :bin=>1, :daemon=>2, :mail=>12, :ftp=>11, :http=>33, :nobody=>65534, :dbus=>81, :"systemd-journal-remote"=>982, :"systemd-network"=>981, :"systemd-resolve"=>980, :"systemd-timesync"=>979, :"systemd-coredump"=>978, :uuidd=>68, :avahi=>977, :...
781
858
 
782
- # File: user.rb | Line: 314
783
- # Definition: def home_by_gid(id = get_gid)
859
+ # File: user.rb | Line: 314
860
+ # Definition: def home_by_gid(id = get_gid)
784
861
  LinuxStat::User.home_by_gid(id)
785
862
  => "/home/sourav"
786
863
 
787
- # File: user.rb | Line: 266
788
- # Definition: def home_by_username(user = get_user)
864
+ # File: user.rb | Line: 266
865
+ # Definition: def home_by_username(user = get_user)
789
866
  LinuxStat::User.home_by_username(user)
790
867
  => "/home/sourav"
791
868
 
792
- # File: user.rb | Line: 72
793
- # Definition: def home_directories
869
+ # File: user.rb | Line: 72
870
+ # Definition: def home_directories
794
871
  LinuxStat::User.home_directories()
795
872
  => {:root=>"/root", :bin=>"/", :daemon=>"/", :mail=>"/var/spool/mail", :ftp=>"/srv/ftp", :http=>"/srv/http", :nobody=>"/", :dbus=>"/", :"systemd-journal-remote"=>"/", :"systemd-network"=>"/", :"systemd-resolve"=>"/", :"systemd-timesync"=>"/", :"systemd-c...
796
873
 
797
- # File: user.rb | Line: 293
798
- # Definition: def homes_by_uid(id = get_uid)
874
+ # File: user.rb | Line: 293
875
+ # Definition: def homes_by_uid(id = get_uid)
799
876
  LinuxStat::User.homes_by_uid(id)
800
877
  => ["/home/sourav"]
801
878
 
802
- # File: user.rb | Line: 23
803
- # Definition: def ids
879
+ # File: user.rb | Line: 23
880
+ # Definition: def ids
804
881
  LinuxStat::User.ids()
805
882
  => {:root=>{:uid=>0, :gid=>0}, :bin=>{:uid=>1, :gid=>1}, :daemon=>{:uid=>2, :gid=>2}, :mail=>{:uid=>8, :gid=>12}, :ftp=>{:uid=>14, :gid=>11}, :http=>{:uid=>33, :gid=>33}, :nobody=>{:uid=>65534, :gid=>65534}, :dbus=>{:uid=>81, :gid=>81}, :"systemd-journal...
806
883
 
807
- # File: user.rb | Line: 11
808
- # Definition: def list
884
+ # File: user.rb | Line: 11
885
+ # Definition: def list
809
886
  LinuxStat::User.list()
810
887
  => ["root", "bin", "daemon", "mail", "ftp", "http", "nobody", "dbus", "systemd-journal-remote", "systemd-network", "systemd-resolve", "systemd-timesync", "systemd-coredump", "uuidd", "avahi", "colord", "git", "lxdm", "polkitd", "rtkit", "usbmux", "sourav...
811
888
 
812
- # File: user.rb | Line: 244
813
- # Definition: def uid_by_username(username = get_user)
889
+ # File: user.rb | Line: 244
890
+ # Definition: def uid_by_username(username = get_user)
814
891
  LinuxStat::User.uid_by_username(username)
815
892
  => 1000
816
893
 
817
- # File: user.rb | Line: 40
818
- # Definition: def uids
894
+ # File: user.rb | Line: 40
895
+ # Definition: def uids
819
896
  LinuxStat::User.uids()
820
897
  => {:root=>0, :bin=>1, :daemon=>2, :mail=>8, :ftp=>14, :http=>33, :nobody=>65534, :dbus=>81, :"systemd-journal-remote"=>982, :"systemd-network"=>981, :"systemd-resolve"=>980, :"systemd-timesync"=>979, :"systemd-coredump"=>978, :uuidd=>68, :avahi=>977, :c...
821
898
 
822
- # File: user.rb | Line: 187
823
- # Definition: def username_by_gid(gid = get_gid)
899
+ # File: user.rb | Line: 187
900
+ # Definition: def username_by_gid(gid = get_gid)
824
901
  LinuxStat::User.username_by_gid(gid)
825
902
  => "sourav"
826
903
 
827
- # File: user.rb | Line: 169
828
- # Definition: def usernames_by_uid(uid = get_uid)
904
+ # File: user.rb | Line: 169
905
+ # Definition: def usernames_by_uid(uid = get_uid)
829
906
  LinuxStat::User.usernames_by_uid(uid)
830
907
  => ["sourav"]
831
908
 
@@ -897,7 +974,120 @@ well as soon as the Linux kernel updates the data and ruby executes the loop.
897
974
 
898
975
  Just run the linuxstat.rb command to test what method takes what time measured in microseconds.
899
976
 
900
- ## Note 2: Filesystem
977
+ ## Note 2: Count CPU
978
+
979
+ There are confusingly 6 different methods to count the number of CPU. But they are here for a reason!
980
+
981
+ Well this section actually demystifies the methods.
982
+
983
+ 1. The good old `LinuxStat::CPU.count()`:
984
+
985
+ It gets the configured CPU for the system. It doesn't count for hotplugged CPU.
986
+ If 3 out of 4 CPU are hotplugged out, it will still show 4. It calles `sysconf(_SC_NPROCESSORS_CONF)`
987
+
988
+ 2. The mysterious `LinuxStat::ProcessInfo.nproc(pid = $$)`:
989
+
990
+ [ Also aliased to `LinuxStat::ProcessInfo.count_cpu()` ]
991
+
992
+ It returns the number of processors, like the other 3 methods.
993
+ Without any arguments, it's like running `require 'etc' ; puts Etc.nprocessors`
994
+
995
+ So there the caveat of checking what the number of processors are actually allocated to the pid.
996
+
997
+ For example:
998
+
999
+ ```
1000
+ $ ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
1001
+ 4
1002
+
1003
+ $ taskset -c 0 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
1004
+ 1
1005
+
1006
+ $ taskset -c 0-1 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
1007
+ 2
1008
+
1009
+ $ taskset -c 0-1,3 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
1010
+ 3
1011
+
1012
+ $ taskset -c 0-1,3 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc "
1013
+ 3
1014
+ ```
1015
+
1016
+ Or with argument:
1017
+
1018
+ ```
1019
+ irb(main):001:0> require 'linux_stat'
1020
+ => true
1021
+
1022
+ irb(main):002:0> LinuxStat::ProcessInfo.command_name 4775
1023
+ => "electron"
1024
+
1025
+ irb(main):003:0> LinuxStat::ProcessInfo.nproc 4775
1026
+ => 4
1027
+ ```
1028
+
1029
+ 3. The `LinuxStat::CPU.online()`:
1030
+
1031
+ This returns the number of online CPU as an Array. It doesn't get affected by taskset or anything.
1032
+
1033
+ For example:
1034
+
1035
+ ```
1036
+ irb(main):001:0> require 'linux_stat'
1037
+ => true
1038
+
1039
+ irb(main):002:0> LinuxStat::CPU.online
1040
+ => [0, 1, 3]
1041
+ ```
1042
+
1043
+ By using `LinuxStat::CPU.online.count` you count the actual online CPU on your system.
1044
+
1045
+ Any n number of CPU can get hotplugged in and out, and this will report that correctly.
1046
+
1047
+ It just gets the info from /proc/stat; but if it fails it will read /sys/devices/system/cpu/online
1048
+ and parse the output to get an array.
1049
+
1050
+ 4. The `LinuxStat::CPU.count_online`
1051
+ It's a more robust method that counts the online CPU. It shouldn't fail in most if not all cases!
1052
+ But if it fails for some really spooky reasons, it will return nil.
1053
+
1054
+ 4. The `LinuxStat::CPU.offline()`:
1055
+
1056
+ This returns the number of offline CPU as an Array. It doesn't get affected by taskset or anything.
1057
+
1058
+ For example:
1059
+
1060
+ ```
1061
+ irb(main):001:0> require 'linux_stat'
1062
+ => true
1063
+
1064
+ irb(main):002:0> LinuxStat::CPU.offline
1065
+ => [2]
1066
+ ```
1067
+
1068
+ Any n number of CPU can get hotplugged in and out, and this will report that correctly.
1069
+
1070
+ It just gets the info from /sys/devices/system/cpu/offline, and parses the output.
1071
+
1072
+ 5. The `LinuxStat::Sysconf.processor_configured()`:
1073
+
1074
+ Sounds repetitive! Actually yes, this is written in C, and it is called by `LinuxStat::CPU.count`.
1075
+
1076
+ The difference is that `LinuxStat::CPU.count` caches the return value, and this method doesn't.
1077
+
1078
+ 6. The `LinuxStat::Sysconf.processor_online()`:
1079
+
1080
+ This may again sound repititive to LinuxStat::CPU.online, but it's actually not!
1081
+
1082
+ If you are using while loops, it might not report the correct number of CPU everytime.
1083
+
1084
+ Worst, it can take a long time to update the total number of CPU.
1085
+
1086
+ The benefit is, it's quite fast!
1087
+
1088
+ It's mostly here just for the sake of completeness to sysconf.
1089
+
1090
+ ## Note 3: Filesystem
901
1091
 
902
1092
  Filesystem can take arguments. By default it's '/' or the root of the system...
903
1093
 
@@ -932,7 +1122,7 @@ irb(main):005:0> LinuxStat::Filesystem.total(thumbdrive).fdiv(1024 ** 3).to_s <<
932
1122
  => "29.305004119873047 GiB"
933
1123
  ```
934
1124
 
935
- ## Note 3: ProcessInfo
1125
+ ## Note 4: ProcessInfo
936
1126
 
937
1127
  All the methods LinuxStat::ProcessInfo can take an argument containing the Process ID of a process.
938
1128
  By default it's $$ or the PID of the current process, ruby, itself.
@@ -984,7 +1174,7 @@ irb(main):002:0> LinuxStat::ProcessInfo.memory(LinuxStat::Process.names.find { |
984
1174
  => "467.51 MiB"
985
1175
  ```
986
1176
 
987
- ## Note 4: FS
1177
+ ## Note 5: FS
988
1178
 
989
1179
  LinuxStat::FS module gives you the raw info in Hash collected from statvfs.
990
1180
 
@@ -1009,7 +1199,7 @@ irb(main):003:0> t = Time.now ; puts LinuxStat::FS.stat('/') ; Time.now - t
1009
1199
 
1010
1200
  To learn more about them, just run ri and the method name. To see all available methods.
1011
1201
 
1012
- ## Note 5: User
1202
+ ## Note 6: User
1013
1203
  Most of the LinuxStat::User supports arguments.
1014
1204
 
1015
1205
  For example, to get a user's home by the username:
@@ -1091,7 +1281,7 @@ irb(main):004:0> LinuxStat::User.get_login
1091
1281
 
1092
1282
  Right, the get_login() can return an empty string. But LinuxStat::User.get_user also aliased as LinuxStat::User.get_current_user shouldn't return an empty string under most circumstances.
1093
1283
 
1094
- ## Note 6: PrettifyBytes
1284
+ ## Note 7: PrettifyBytes
1095
1285
  Often times we need to work with KB, MB GB, TB, or KiB, MiB, GiB, TiB, etc.
1096
1286
  And we need some work to convert bytes to those units.
1097
1287
  Because LinuxStat provides a lot of data in bytes, and kilobytes, it's quite tedious to convert them all the time.
@@ -1231,6 +1421,16 @@ Issues regarding running LinuxStat on termux are also welcomed.
1231
1421
 
1232
1422
  ---
1233
1423
 
1424
+ ## Cloning this Repo
1425
+ Users of this gem are requested to follow the above installation step to install this gem.
1426
+
1427
+ This repo is only for development purpose. It has C extensions that could do worst to your stable app.
1428
+ Cloning, compiling code from this repo for a production app may seg fault and crash the whole app directly.
1429
+
1430
+ Gems on Rubygems are released after various tests.
1431
+
1432
+ So just install the gem, don't clone this repo just because the version is bumped here with new features, and the gem is not out on Rubygems.org.
1433
+
1234
1434
  ## Development
1235
1435
  After checking out the repo, compile and install this gem onto your local machine with `bundle exec rake install`
1236
1436