linux_stat 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfecb2c10d06e8e8cc76c1b03df8a518442f63d30fc7d556cb61649d1fc11957
4
- data.tar.gz: beb60db61f4668cf82b4f551de0c08761bd935e91c6f631cf47f79adfc4803aa
3
+ metadata.gz: 15d0c0fba26992b304c1f9983d172e283fe918dedc76eb7f3cfd86a274b974b4
4
+ data.tar.gz: bf5d4b822e2c0ab4f45d677a84172d33aea0d17df509e6000737cac9625c429f
5
5
  SHA512:
6
- metadata.gz: 3812d0d70ce53bfb24df7941252e711c37ff3ae9ecae87009a7f0cab13c82db99bc3dfdfeae02a370e9a8337c08ab13372f33768ee09b3d01e8caf7d3e4dea50
7
- data.tar.gz: b600994a6566b315cb6b2a69563039d203f8a8b563135491978fd0f8c81499ac6dc784f40f3ec745520c4e8e8b787efbf3019150b578842e6be933938ae786fe
6
+ metadata.gz: 725d00aa53ffeb4054389ae9ddf4af843cc57dfda0bcb3128500795c735b6b6e28bba7bd42b1873babc508bbdc5036ae294c105422000305c4e1a8a70247efaa
7
+ data.tar.gz: 88d1f1939e2f7982d3cf6501f62e8974cb09e889dcf5e2c5132ae996a78d096b2ef1138e8be1ebd2cd93b1d6d3f53ade3696ac95a0eecbef6ea306ed1488588d
data/README.md CHANGED
@@ -37,6 +37,32 @@ On Debian based systems:
37
37
 
38
38
  ---
39
39
 
40
+ ## Optional Dependencies
41
+
42
+ You need hwdata to decode vendor and product ids if you use LinuxStat::USB and/or LinuxStat::PCI
43
+
44
+ You can install hwdata simply.
45
+
46
+ + Arch:
47
+
48
+ ```
49
+ sudo pacman -S hwids
50
+ ```
51
+
52
+ + Debian based systems:
53
+
54
+ ```
55
+ sudo apt install hwdata
56
+ ```
57
+
58
+ But without hwdata, it won't show such information.
59
+
60
+ You can also point to a downloaded copy of hwdata (pci.ids / usb.ids) file.
61
+
62
+ Follow [Note 7](https://github.com/Souravgoswami/linux_stat#note-7-hwdata) below for more information on that.
63
+
64
+ ---
65
+
40
66
  ## Installation
41
67
 
42
68
  Add this line to your application's Gemfile:
@@ -88,7 +114,7 @@ LinuxStat::BIOS.version()
88
114
  # File: battery.rb | Line: 105
89
115
  # Definition: def charge
90
116
  LinuxStat::Battery.charge()
91
- => 100.0
117
+ => 95.73550551030186
92
118
 
93
119
  # File: battery.rb | Line: 122
94
120
  # Definition: def charge_full_design_wh
@@ -108,7 +134,7 @@ LinuxStat::Battery.charging?()
108
134
  # File: battery.rb | Line: 184
109
135
  # Definition: def devices_stat
110
136
  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....
137
+ => {:AC=>{:type=>"Mains", :online=>1}, :BAT0=>{:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :type=>"Battery", :status=>"Charging", :capacity=>95, :voltage_min_design=>11.4, :charge_full_design=>3.684, :charge_full_design_wh=>42.0, :voltage_now=>...
112
138
 
113
139
  # File: battery.rb | Line: 87
114
140
  # Definition: def discharging?
@@ -118,7 +144,7 @@ LinuxStat::Battery.discharging?()
118
144
  # File: battery.rb | Line: 96
119
145
  # Definition: def full?
120
146
  LinuxStat::Battery.full?()
121
- => true
147
+ => false
122
148
 
123
149
  # File: battery.rb | Line: 47
124
150
  # Definition: def manufacturer
@@ -138,12 +164,12 @@ LinuxStat::Battery.present?()
138
164
  # File: battery.rb | Line: 16
139
165
  # Definition: def stat
140
166
  LinuxStat::Battery.stat()
141
- => {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Full", :charge=>100.0, :charging=>true, :discharging=>false, :full=>true}
167
+ => {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Charging", :charge=>95.73550551030186, :charging=>true, :discharging=>false, :full=>false}
142
168
 
143
169
  # File: battery.rb | Line: 68
144
170
  # Definition: def status
145
171
  LinuxStat::Battery.status()
146
- => "Full"
172
+ => "Charging"
147
173
 
148
174
  # File: battery.rb | Line: 57
149
175
  # Definition: def technology
@@ -153,7 +179,7 @@ LinuxStat::Battery.technology()
153
179
  # File: battery.rb | Line: 160
154
180
  # Definition: def voltage_now
155
181
  LinuxStat::Battery.voltage_now()
156
- => 12.453
182
+ => 12.887
157
183
 
158
184
  ```
159
185
 
@@ -177,7 +203,7 @@ LinuxStat::CPU.count_online()
177
203
  # File: cpu.rb | Line: 197
178
204
  # Definition: def cur_freq
179
205
  LinuxStat::CPU.cur_freq()
180
- => {"cpu0"=>1971347, "cpu1"=>2000253, "cpu2"=>1916631, "cpu3"=>2000064}
206
+ => {"cpu0"=>2000115, "cpu1"=>2000016, "cpu2"=>2000066, "cpu3"=>2000240}
181
207
 
182
208
  # File: cpu.rb | Line: 265
183
209
  # Definition: def governor
@@ -212,29 +238,29 @@ LinuxStat::CPU.online()
212
238
  # File: cpu.rb | Line: 23
213
239
  # Definition: def stat(sleep = ticks_to_ms_t5)
214
240
  LinuxStat::CPU.stat(sleep)
215
- => {0=>5.0, 1=>16.67, 2=>0.0, 3=>0.0, 4=>16.67}
241
+ => {0=>19.05, 1=>20.0, 2=>16.67, 3=>16.67, 4=>16.67}
216
242
 
217
243
  # File: cpu.rb | Line: 63
218
244
  # Definition: def total_usage(sleep = ticks_to_ms_t5)
219
245
  LinuxStat::CPU.total_usage(sleep)
220
- => 5.26
246
+ => 5.0
221
247
 
222
248
  # File: cpu.rb | Line: 63
223
249
  # Definition: def total_usage(sleep = ticks_to_ms_t5)
224
250
  LinuxStat::CPU.usage(sleep)
225
- => 9.52
251
+ => 0.0
226
252
 
227
253
  # File: cpu.rb | Line: 23
228
254
  # Definition: def stat(sleep = ticks_to_ms_t5)
229
255
  LinuxStat::CPU.usages(sleep)
230
- => {0=>5.26, 1=>16.67, 2=>0.0, 3=>0.0, 4=>0.0}
256
+ => {0=>13.64, 1=>0.0, 2=>16.67, 3=>0.0, 4=>20.0}
231
257
 
232
258
  ```
233
259
 
234
260
  ### LinuxStat::FS
235
261
  ```
236
262
  LinuxStat::FS.stat(arg = "/")
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}
263
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>10866159, :block_avail_unpriv=>10866159, :inodes=>58612160, :free_inodes=>56826110, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
238
264
 
239
265
  ```
240
266
 
@@ -243,22 +269,22 @@ LinuxStat::FS.stat(arg = "/")
243
269
  # File: filesystem.rb | Line: 92
244
270
  # Definition: def available(fs = ?..freeze)
245
271
  LinuxStat::Filesystem.available(fs)
246
- => 47937835008
272
+ => 44507787264
247
273
 
248
274
  # File: filesystem.rb | Line: 58
249
275
  # Definition: def free(fs = ?..freeze)
250
276
  LinuxStat::Filesystem.free(fs)
251
- => 47937835008
277
+ => 44507787264
252
278
 
253
279
  # File: filesystem.rb | Line: 19
254
280
  # Definition: def stat(fs = ?..freeze)
255
281
  LinuxStat::Filesystem.stat(fs)
256
- => {:total=>119981191168, :free=>47937835008, :used=>72043356160}
282
+ => {:total=>119981191168, :free=>44507787264, :used=>75473403904}
257
283
 
258
284
  # File: filesystem.rb | Line: 108
259
285
  # Definition: def stat_raw(fs = ?..freeze)
260
286
  LinuxStat::Filesystem.stat_raw(fs)
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}
287
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>10866159, :block_avail_unpriv=>10866159, :inodes=>58612160, :free_inodes=>56826110, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
262
288
 
263
289
  # File: filesystem.rb | Line: 39
264
290
  # Definition: def total(fs = ?..freeze)
@@ -268,7 +294,7 @@ LinuxStat::Filesystem.total(fs)
268
294
  # File: filesystem.rb | Line: 73
269
295
  # Definition: def used(fs = ?..freeze)
270
296
  LinuxStat::Filesystem.used(fs)
271
- => 72043356160
297
+ => 75473403904
272
298
 
273
299
  ```
274
300
 
@@ -277,12 +303,12 @@ LinuxStat::Filesystem.used(fs)
277
303
  # File: kernel.rb | Line: 86
278
304
  # Definition: def build_date
279
305
  LinuxStat::Kernel.build_date()
280
- => 2020-11-20 07:44:55 +0000
306
+ => 2020-12-24 18:28:16 +0000
281
307
 
282
308
  # File: kernel.rb | Line: 140
283
309
  # Definition: def build_date_string
284
310
  LinuxStat::Kernel.build_date_string()
285
- => "20 Nov 2020 07:44:55 +0000"
311
+ => "24 Dec 2020 18:28:16 +0000"
286
312
 
287
313
  # File: kernel.rb | Line: 21
288
314
  # Definition: def build_user
@@ -307,12 +333,12 @@ LinuxStat::Kernel.compiler_version()
307
333
  # File: kernel.rb | Line: 10
308
334
  # Definition: def version
309
335
  LinuxStat::Kernel.release()
310
- => "5.9.9-xanmod1-1"
336
+ => "5.10.2-xanmod1-cacule-1-cacule"
311
337
 
312
338
  # File: kernel.rb | Line: 169
313
339
  # Definition: def string
314
340
  LinuxStat::Kernel.string()
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"
341
+ => "Linux version 5.10.2-xanmod1-cacule-1-cacule (souravgoswami@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Thu, 24 Dec 2020 18:28:16 +0000"
316
342
 
317
343
  # File: kernel.rb | Line: 179
318
344
  # Definition: def ticks
@@ -322,7 +348,7 @@ LinuxStat::Kernel.ticks()
322
348
  # File: kernel.rb | Line: 10
323
349
  # Definition: def version
324
350
  LinuxStat::Kernel.version()
325
- => "5.9.9-xanmod1-1"
351
+ => "5.10.2-xanmod1-cacule-1-cacule"
326
352
 
327
353
  ```
328
354
 
@@ -331,32 +357,32 @@ LinuxStat::Kernel.version()
331
357
  # File: memory.rb | Line: 50
332
358
  # Definition: def available
333
359
  LinuxStat::Memory.available()
334
- => 1597312
360
+ => 477784
335
361
 
336
362
  # File: memory.rb | Line: 81
337
363
  # Definition: def percent_available
338
364
  LinuxStat::Memory.percent_available()
339
- => 41.64
365
+ => 12.46
340
366
 
341
367
  # File: memory.rb | Line: 70
342
368
  # Definition: def percent_used
343
369
  LinuxStat::Memory.percent_used()
344
- => 58.36
370
+ => 87.54
345
371
 
346
372
  # File: memory.rb | Line: 11
347
373
  # Definition: def stat
348
374
  LinuxStat::Memory.stat()
349
- => {:total=>3836236, :used=>2238924, :available=>1597312, :percent_used=>58.36, :percent_available=>41.64}
375
+ => {:total=>3836036, :used=>3358252, :available=>477784, :percent_used=>87.54, :percent_available=>12.46}
350
376
 
351
377
  # File: memory.rb | Line: 40
352
378
  # Definition: def total
353
379
  LinuxStat::Memory.total()
354
- => 3836236
380
+ => 3836036
355
381
 
356
382
  # File: memory.rb | Line: 60
357
383
  # Definition: def used
358
384
  LinuxStat::Memory.used()
359
- => 2238924
385
+ => 3358252
360
386
 
361
387
  ```
362
388
 
@@ -365,7 +391,7 @@ LinuxStat::Memory.used()
365
391
  # File: mounts.rb | Line: 179
366
392
  # Definition: def device_stat(dev = root)
367
393
  LinuxStat::Mounts.device_stat(dev)
368
- => {:mountpoint=>"/", :total=>119981191168, :free=>47937835008, :available=>47937835008, :used=>72043356160, :percent_used=>60.05, :percent_free=>39.95, :percent_available=>39.95}
394
+ => {:mountpoint=>"/", :total=>119981191168, :free=>44507787264, :available=>44507787264, :used=>75473403904, :percent_used=>62.9, :percent_free=>37.1, :percent_available=>37.1}
369
395
 
370
396
  # File: mounts.rb | Line: 137
371
397
  # Definition: def devices_stat
@@ -375,17 +401,17 @@ LinuxStat::Mounts.devices_stat()
375
401
  # File: mounts.rb | Line: 11
376
402
  # Definition: def list
377
403
  LinuxStat::Mounts.list()
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", "...
404
+ => ["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=1909248k,nr_inodes=477312,mode=755,inode64 0 0", "run /run tmpfs rw,nosuid,nodev,relatime,mode=755...
379
405
 
380
406
  # File: mounts.rb | Line: 20
381
407
  # Definition: def list_devices
382
408
  LinuxStat::Mounts.list_devices()
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...
409
+ => ["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", "hug...
384
410
 
385
411
  # File: mounts.rb | Line: 109
386
412
  # Definition: def list_devices_mount_point
387
413
  LinuxStat::Mounts.list_devices_mount_point()
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"=>"...
414
+ => {"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/cpuset", "pstore"=>"...
389
415
 
390
416
  # File: mounts.rb | Line: 80
391
417
  # Definition: def mount_point(dev = root)
@@ -410,13 +436,13 @@ LinuxStat::Mounts.root_mount_options()
410
436
  # File: mounts.rb | Line: 56
411
437
  # Definition: def tmpfs
412
438
  LinuxStat::Mounts.tmpfs()
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...
439
+ => {"/dev/shm"=>"tmpfs /dev/shm tmpfs rw,nosuid,nodev,inode64 0 0", "/sys/fs/cgroup"=>"tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755,inode64 0 0", "/ramdisk"=>"tmpfs /ramdisk tmpfs rw,nosuid,nodev,relatime,size=6291...
414
440
 
415
441
  ```
416
442
 
417
443
  ### LinuxStat::Net
418
444
  ```
419
- # File: net.rb | Line: 80
445
+ # File: net.rb | Line: 84
420
446
  # Definition: def usage(interval = 0.1)
421
447
  LinuxStat::Net.current_usage(interval)
422
448
  => {:received=>0.0, :transmitted=>0.0}
@@ -426,22 +452,22 @@ LinuxStat::Net.current_usage(interval)
426
452
  LinuxStat::Net.ipv4_private()
427
453
  => "192.168.0.102"
428
454
 
429
- # File: net.rb | Line: 23
455
+ # File: net.rb | Line: 25
430
456
  # Definition: def total_bytes
431
457
  LinuxStat::Net.total_bytes()
432
- => {:received=>687677565, :transmitted=>149550163}
458
+ => {:received=>473253199, :transmitted=>35211379}
433
459
 
434
- # File: net.rb | Line: 41
460
+ # File: net.rb | Line: 43
435
461
  # Definition: def total_bytes_received
436
462
  LinuxStat::Net.total_bytes_received()
437
- => 687677565
463
+ => 473253199
438
464
 
439
- # File: net.rb | Line: 54
465
+ # File: net.rb | Line: 56
440
466
  # Definition: def total_bytes_transmitted
441
467
  LinuxStat::Net.total_bytes_transmitted()
442
- => 149550163
468
+ => 35211379
443
469
 
444
- # File: net.rb | Line: 80
470
+ # File: net.rb | Line: 84
445
471
  # Definition: def usage(interval = 0.1)
446
472
  LinuxStat::Net.usage(interval)
447
473
  => {:received=>0.0, :transmitted=>0.0}
@@ -450,45 +476,84 @@ LinuxStat::Net.usage(interval)
450
476
 
451
477
  ### LinuxStat::OS
452
478
  ```
453
- # File: os.rb | Line: 97
479
+ # File: os.rb | Line: 99
454
480
  # Definition: def bits
455
481
  LinuxStat::OS.bits()
456
482
  => 64
457
483
 
458
- # File: os.rb | Line: 42
484
+ # File: os.rb | Line: 44
459
485
  # Definition: def distribution
460
486
  LinuxStat::OS.distribution()
461
487
  => "Arch Linux"
462
488
 
463
- # File: os.rb | Line: 81
489
+ # File: os.rb | Line: 83
464
490
  # Definition: def hostname
465
491
  LinuxStat::OS.hostname()
466
492
  => "archlinux"
467
493
 
468
- # File: os.rb | Line: 30
494
+ # File: os.rb | Line: 33
469
495
  # Definition: def lsb_release
470
496
  LinuxStat::OS.lsb_release()
471
497
  => {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
472
498
 
473
- # File: os.rb | Line: 64
499
+ # File: os.rb | Line: 66
474
500
  # Definition: def machine
475
501
  LinuxStat::OS.machine()
476
502
  => "x86_64"
477
503
 
478
- # File: os.rb | Line: 72
504
+ # File: os.rb | Line: 74
479
505
  # Definition: def nodename
480
506
  LinuxStat::OS.nodename()
481
507
  => "archlinux"
482
508
 
483
- # File: os.rb | Line: 15
509
+ # File: os.rb | Line: 17
484
510
  # Definition: def os_release
485
511
  LinuxStat::OS.os_release()
486
512
  => {: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/"...
487
513
 
488
- # File: os.rb | Line: 110
514
+ # File: os.rb | Line: 114
489
515
  # Definition: def uptime
490
516
  LinuxStat::OS.uptime()
491
- => {:hour=>6, :minute=>50, :second=>39.61}
517
+ => {:hour=>9, :minute=>25, :second=>50.38}
518
+
519
+ ```
520
+
521
+ ### LinuxStat::PCI
522
+ ```
523
+ # File: pci.rb | Line: 211
524
+ # Definition: def count
525
+ LinuxStat::PCI.count()
526
+ => 13
527
+
528
+ # File: pci.rb | Line: 211
529
+ # Definition: def count
530
+ LinuxStat::PCI.count_devices()
531
+ => 13
532
+
533
+ # File: pci.rb | Line: 52
534
+ # Definition: def devices_info(hwdata: true)
535
+ LinuxStat::PCI.devices_info(hwdata:)
536
+ => [{:id=>"8086:1904", :vendor=>"8086", :device=>"1904", :irq=>0, :kernel_driver=>"skl_uncore", :hwdata=>{:vendor=>"Intel Corporation", :product=>"Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Host Bridge/DRAM Registers"}}, {:id=>"8086:1916", :vendor...
537
+
538
+ # File: pci.rb | Line: 128
539
+ # Definition: def devices_stat(hwdata: true)
540
+ LinuxStat::PCI.devices_stat(hwdata:)
541
+ => [{:path=>"/sys/bus/pci/devices/0000:00:00.0/", :id=>"8086:1904", :vendor=>"8086", :device=>"1904", :sub_vendor=>"1028", :sub_device=>"077d", :kernel_driver=>"skl_uncore", :revision=>"0x08", :irq=>0, :enable=>false, :hwdata=>{:vendor=>"Intel Corporatio...
542
+
543
+ # File: pci.rb | Line: 259
544
+ # Definition: def hwdata_file
545
+ LinuxStat::PCI.hwdata_file()
546
+ => "/usr/share/hwdata/pci.ids"
547
+
548
+ # File: pci.rb | Line: 248
549
+ # Definition: def hwdata_file_set?
550
+ LinuxStat::PCI.hwdata_file_set?()
551
+ => true
552
+
553
+ # File: pci.rb | Line: 275
554
+ # Definition: def initialize_hwdata
555
+ LinuxStat::PCI.initialize_hwdata()
556
+ => false
492
557
 
493
558
  ```
494
559
 
@@ -496,23 +561,23 @@ LinuxStat::OS.uptime()
496
561
  ```
497
562
  # File: prettify_bytes.rb | Line: 42
498
563
  # Definition: def convert_binary(n)
499
- LinuxStat::PrettifyBytes.convert_binary(n = 200152828322898)
500
- => "182.04 tebibytes"
564
+ LinuxStat::PrettifyBytes.convert_binary(n = 419383956999155)
565
+ => "381.43 tebibytes"
501
566
 
502
567
  # File: prettify_bytes.rb | Line: 19
503
568
  # Definition: def convert_decimal(n)
504
- LinuxStat::PrettifyBytes.convert_decimal(n = 434440373786022)
505
- => "434.44 terabytes"
569
+ LinuxStat::PrettifyBytes.convert_decimal(n = 74171973456499)
570
+ => "74.17 terabytes"
506
571
 
507
572
  # File: prettify_bytes.rb | Line: 90
508
573
  # Definition: def convert_short_binary(n)
509
- LinuxStat::PrettifyBytes.convert_short_binary(n = 88309228425306)
510
- => "80.32 TiB"
574
+ LinuxStat::PrettifyBytes.convert_short_binary(n = 992896974803970)
575
+ => "903.03 TiB"
511
576
 
512
577
  # File: prettify_bytes.rb | Line: 65
513
578
  # Definition: def convert_short_decimal(n)
514
- LinuxStat::PrettifyBytes.convert_short_decimal(n = 238518247519978)
515
- => "238.52 TB"
579
+ LinuxStat::PrettifyBytes.convert_short_decimal(n = 448181119260617)
580
+ => "448.18 TB"
516
581
 
517
582
  ```
518
583
 
@@ -521,37 +586,37 @@ LinuxStat::PrettifyBytes.convert_short_decimal(n = 238518247519978)
521
586
  # File: process.rb | Line: 19
522
587
  # Definition: def count
523
588
  LinuxStat::Process.count()
524
- => 195
589
+ => 199
525
590
 
526
591
  # File: process.rb | Line: 71
527
592
  # Definition: def idle
528
593
  LinuxStat::Process.idle()
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...
594
+ => [3, 4, 7, 9, 12, 23, 30, 37, 39, 45, 99, 100, 101, 104, 105, 106, 107, 108, 116, 117, 119, 122, 131, 134, 140, 164, 166, 169, 170, 173, 175, 180, 181, 182, 183, 184, 185, 186, 188, 231, 275, 315, 323, 333, 3142, 3143, 3144, 3145, 3146, 3147, 10193, 11...
530
595
 
531
596
  # File: process.rb | Line: 8
532
597
  # Definition: def list
533
598
  LinuxStat::Process.list()
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,...
599
+ => [1, 2, 3, 4, 7, 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, 43, 44, 45, 46, 47, 48, 99, 100, 101, 104, 105, 106, 107, 108, 109, 113, 114, 116, 117, 119, 122, 131, 134, 140,...
535
600
 
536
601
  # File: process.rb | Line: 25
537
602
  # Definition: def names
538
603
  LinuxStat::Process.names()
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...
604
+ => {1=>"systemd", 2=>"kthreadd", 3=>"rcu_gp", 4=>"rcu_par_gp", 7=>"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...
540
605
 
541
606
  # File: process.rb | Line: 97
542
607
  # Definition: def running
543
608
  LinuxStat::Process.running()
544
- => [15978]
609
+ => [4259, 12094, 13037]
545
610
 
546
611
  # File: process.rb | Line: 58
547
612
  # Definition: def sleeping
548
613
  LinuxStat::Process.sleeping()
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,...
614
+ => [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, 43, 44, 46, 47, 48, 109, 113, 114, 163, 165, 189, 218, 232, 271, 302, 314, 316, 319, 321, 322, 324, 325, 326, 327, 345, 348, 376, 403, 405, 406,...
550
615
 
551
616
  # File: process.rb | Line: 37
552
617
  # Definition: def types
553
618
  LinuxStat::Process.types()
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...
619
+ => {1=>:sleeping, 2=>:sleeping, 3=>:idle, 4=>:idle, 7=>: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...
555
620
 
556
621
  # File: process.rb | Line: 84
557
622
  # Definition: def zombie
@@ -600,12 +665,12 @@ LinuxStat::ProcessInfo.last_executed_cpu(pid)
600
665
  # File: process_info.rb | Line: 114
601
666
  # Definition: def mem_stat(pid = $$)
602
667
  LinuxStat::ProcessInfo.mem_stat(pid)
603
- => {:memory=>12627.968, :virtual_memory=>84221.952, :resident_memory=>18743.296}
668
+ => {:memory=>26685.44, :virtual_memory=>97878.016, :resident_memory=>32849.92}
604
669
 
605
670
  # File: process_info.rb | Line: 147
606
671
  # Definition: def memory(pid = $$)
607
672
  LinuxStat::ProcessInfo.memory(pid)
608
- => 12627.968
673
+ => 26685.44
609
674
 
610
675
  # File: process_info.rb | Line: 607
611
676
  # Definition: def nice(pid = $$)
@@ -625,22 +690,22 @@ LinuxStat::ProcessInfo.owner(pid)
625
690
  # File: process_info.rb | Line: 197
626
691
  # Definition: def resident_memory(pid = $$)
627
692
  LinuxStat::ProcessInfo.resident_memory(pid)
628
- => 18743.296
693
+ => 32849.92
629
694
 
630
695
  # File: process_info.rb | Line: 563
631
696
  # Definition: def running_time(pid = $$)
632
697
  LinuxStat::ProcessInfo.running_time(pid)
633
- => 0.8
698
+ => 1.04
634
699
 
635
700
  # File: process_info.rb | Line: 544
636
701
  # Definition: def start_time(pid = $$)
637
702
  LinuxStat::ProcessInfo.start_time(pid)
638
- => 2020-12-24 19:05:51 +0530
703
+ => 2020-12-28 21:00:34 +0530
639
704
 
640
705
  # File: process_info.rb | Line: 513
641
706
  # Definition: def start_time_epoch(pid = $$)
642
707
  LinuxStat::ProcessInfo.start_time_epoch(pid)
643
- => 1608816951
708
+ => 1609169434
644
709
 
645
710
  # File: process_info.rb | Line: 592
646
711
  # Definition: def state(pid = $$)
@@ -660,7 +725,7 @@ LinuxStat::ProcessInfo.threads(pid)
660
725
  # File: process_info.rb | Line: 23
661
726
  # Definition: def total_io(pid = $$)
662
727
  LinuxStat::ProcessInfo.total_io(pid)
663
- => {:read_bytes=>0, :write_bytes=>0}
728
+ => {:read_bytes=>86016, :write_bytes=>0}
664
729
 
665
730
  # File: process_info.rb | Line: 446
666
731
  # Definition: def uid(pid = $$)
@@ -670,7 +735,7 @@ LinuxStat::ProcessInfo.uid(pid)
670
735
  # File: process_info.rb | Line: 172
671
736
  # Definition: def virtual_memory(pid = $$)
672
737
  LinuxStat::ProcessInfo.virtual_memory(pid)
673
- => 84221.952
738
+ => 98148.352
674
739
 
675
740
  ```
676
741
 
@@ -684,27 +749,27 @@ LinuxStat::Swap.any?()
684
749
  # File: swap.rb | Line: 68
685
750
  # Definition: def available
686
751
  LinuxStat::Swap.available()
687
- => 4064380
752
+ => 2912056
688
753
 
689
754
  # File: swap.rb | Line: 8
690
755
  # Definition: def list
691
756
  LinuxStat::Swap.list()
692
- => {"/dev/zram0"=>[:partition, 4194300, 129920, -2]}
757
+ => {"/dev/zram0"=>[:partition, 4194300, 1282244, -2]}
693
758
 
694
759
  # File: swap.rb | Line: 103
695
760
  # Definition: def percent_available
696
761
  LinuxStat::Swap.percent_available()
697
- => 96.9
762
+ => 69.43
698
763
 
699
764
  # File: swap.rb | Line: 89
700
765
  # Definition: def percent_used
701
766
  LinuxStat::Swap.percent_used()
702
- => 3.1
767
+ => 30.57
703
768
 
704
769
  # File: swap.rb | Line: 32
705
770
  # Definition: def stat
706
771
  LinuxStat::Swap.stat()
707
- => {:total=>4194300, :used=>129920, :available=>4064380, :percent_used=>3.1, :percent_available=>96.9}
772
+ => {:total=>4194300, :used=>1282244, :available=>2912056, :percent_used=>30.57, :percent_available=>69.43}
708
773
 
709
774
  # File: swap.rb | Line: 57
710
775
  # Definition: def total
@@ -714,14 +779,14 @@ LinuxStat::Swap.total()
714
779
  # File: swap.rb | Line: 80
715
780
  # Definition: def used
716
781
  LinuxStat::Swap.used()
717
- => 129920
782
+ => 1282244
718
783
 
719
784
  ```
720
785
 
721
786
  ### LinuxStat::Sysconf
722
787
  ```
723
788
  LinuxStat::Sysconf.child_max()
724
- => nil
789
+ => 14915
725
790
 
726
791
  LinuxStat::Sysconf.expr_nest_max()
727
792
  => 32
@@ -757,7 +822,7 @@ LinuxStat::Sysconf.pagesize()
757
822
  => 4096
758
823
 
759
824
  LinuxStat::Sysconf.posix_version()
760
- => 4201
825
+ => 200809
761
826
 
762
827
  LinuxStat::Sysconf.processor_configured()
763
828
  => 4
@@ -778,20 +843,35 @@ LinuxStat::Sysconf.tty_name_max()
778
843
 
779
844
  ### LinuxStat::USB
780
845
  ```
781
- # File: usb.rb | Line: 74
846
+ # File: usb.rb | Line: 135
782
847
  # Definition: def count
783
848
  LinuxStat::USB.count()
784
849
  => 10
785
850
 
786
- # File: usb.rb | Line: 74
851
+ # File: usb.rb | Line: 135
787
852
  # Definition: def count
788
853
  LinuxStat::USB.count_devices()
789
854
  => 10
790
855
 
791
- # File: usb.rb | Line: 4
856
+ # File: usb.rb | Line: 47
792
857
  # Definition: def devices_stat(hwdata: true)
793
858
  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...
859
+ => [{:path=>"/sys/bus/usb/devices/1-1.2/", :id=>"04d9:1203", :vendor_id=>"04d9", :product_id=>"1203", :bus_num=>1, :dev_num=>7, :hwdata=>{:vendor=>"Holtek Semiconductor, Inc.", :product=>"Keyboard"}, :authorized=>true, :b_max_power=>"100mA", :b_max_packe...
860
+
861
+ # File: usb.rb | Line: 175
862
+ # Definition: def hwdata_file
863
+ LinuxStat::USB.hwdata_file()
864
+ => "/usr/share/hwdata/usb.ids"
865
+
866
+ # File: usb.rb | Line: 164
867
+ # Definition: def hwdata_file_set?
868
+ LinuxStat::USB.hwdata_file_set?()
869
+ => true
870
+
871
+ # File: usb.rb | Line: 191
872
+ # Definition: def initialize_hwdata
873
+ LinuxStat::USB.initialize_hwdata()
874
+ => false
795
875
 
796
876
  ```
797
877
 
@@ -804,13 +884,13 @@ LinuxStat::Uname.nodename()
804
884
  => "archlinux"
805
885
 
806
886
  LinuxStat::Uname.release()
807
- => "5.9.9-xanmod1-1"
887
+ => "5.10.2-xanmod1-cacule-1-cacule"
808
888
 
809
889
  LinuxStat::Uname.sysname()
810
890
  => "Linux"
811
891
 
812
892
  LinuxStat::Uname.version()
813
- => "#1 SMP PREEMPT Fri, 20 Nov 2020 07:44:55 +0000"
893
+ => "#1 SMP PREEMPT Thu, 24 Dec 2020 18:28:16 +0000"
814
894
 
815
895
  ```
816
896
 
@@ -983,11 +1063,11 @@ Well this section actually demystifies the methods.
983
1063
  1. The good old `LinuxStat::CPU.count()`:
984
1064
 
985
1065
  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)`
1066
+ If 3 out of 4 CPU are hotplugged out, it will still show 4. It calls `sysconf(_SC_NPROCESSORS_CONF)`
987
1067
 
988
1068
  2. The mysterious `LinuxStat::ProcessInfo.nproc(pid = $$)`:
989
1069
 
990
- [ Also aliased to `LinuxStat::ProcessInfo.count_cpu()` ]
1070
+ [ Also aliased to `LinuxStat::ProcessInfo.count_cpu()` ]
991
1071
 
992
1072
  It returns the number of processors, like the other 3 methods.
993
1073
  Without any arguments, it's like running `require 'etc' ; puts Etc.nprocessors`
@@ -1051,7 +1131,7 @@ and parse the output to get an array.
1051
1131
  It's a more robust method that counts the online CPU. It shouldn't fail in most if not all cases!
1052
1132
  But if it fails for some really spooky reasons, it will return nil.
1053
1133
 
1054
- 4. The `LinuxStat::CPU.offline()`:
1134
+ 5. The `LinuxStat::CPU.offline()`:
1055
1135
 
1056
1136
  This returns the number of offline CPU as an Array. It doesn't get affected by taskset or anything.
1057
1137
 
@@ -1069,13 +1149,13 @@ Any n number of CPU can get hotplugged in and out, and this will report that cor
1069
1149
 
1070
1150
  It just gets the info from /sys/devices/system/cpu/offline, and parses the output.
1071
1151
 
1072
- 5. The `LinuxStat::Sysconf.processor_configured()`:
1152
+ 6. The `LinuxStat::Sysconf.processor_configured()`:
1073
1153
 
1074
1154
  Sounds repetitive! Actually yes, this is written in C, and it is called by `LinuxStat::CPU.count`.
1075
1155
 
1076
1156
  The difference is that `LinuxStat::CPU.count` caches the return value, and this method doesn't.
1077
1157
 
1078
- 6. The `LinuxStat::Sysconf.processor_online()`:
1158
+ 7. The `LinuxStat::Sysconf.processor_online()`:
1079
1159
 
1080
1160
  This may again sound repititive to LinuxStat::CPU.online, but it's actually not!
1081
1161
 
@@ -1281,7 +1361,65 @@ irb(main):004:0> LinuxStat::User.get_login
1281
1361
 
1282
1362
  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.
1283
1363
 
1284
- ## Note 7: PrettifyBytes
1364
+ ## Note 7: Hwdata
1365
+ The PCI and USB modules actually rely on hwdata found in /usr/share/hwdata/.
1366
+ But if the directory is not available, it won't show hwdata related information.
1367
+
1368
+ So it's suggested to install hwdata. But you might face issues with heroku and
1369
+ other online PaaS where you can't install it. So Version 1.1.1+ comes with a module function called `hwdata_file = file`.
1370
+
1371
+ + You can use any usb.ids or pci.ids files:
1372
+
1373
+ ```
1374
+ LS::PCI.hwdata_file = File.join(__dir__, 'hwdata', 'pci.ids')
1375
+ LS::USB.hwdata_file = File.join(__dir__, 'hwdata', 'usb.ids')
1376
+ ```
1377
+
1378
+ Assuming that you have `pci.ids` and `usb.ids` under ./hwdata directory.
1379
+
1380
+ On rails, you can put this (replace `__dir__` with `Rails.root` inside environment.rb).
1381
+
1382
+ But do note that the file can be set only once. It's suggested to do that in the beginning of your app.
1383
+
1384
+ + There's one method to check if the hwdata file was already set:
1385
+
1386
+ ```
1387
+ irb(main):001:0' require 'linux_stat'
1388
+ => true
1389
+
1390
+ irb(main):002:0> LS::USB.hwdata_file_set?
1391
+ => false
1392
+
1393
+ irb(main):003:0> LS::USB.devices_stat ; ''
1394
+ => ""
1395
+
1396
+ irb(main):004:0> LS::USB.hwdata_file_set?
1397
+ => true
1398
+ ```
1399
+
1400
+ It works on USB and PCI modules.
1401
+
1402
+ Once the file is set, calling `LS::PCI.hwdata_file = file` is futile.
1403
+
1404
+ + Initializing hwdata can take 0.1 to 0.2 seconds at the first, so there's a method to initialize_hwdata at first:
1405
+
1406
+ ```
1407
+ irb(main):001:0> require 'linux_stat'
1408
+ => true
1409
+
1410
+ irb(main):002:0> LS::PCI.initialize_hwdata
1411
+ => true
1412
+
1413
+ irb(main):003:0> LS::PCI.initialize_hwdata
1414
+ => false
1415
+ ```
1416
+
1417
+ It will return true if it worked, else it will return false. It's intended to be done once.
1418
+
1419
+ If you don't initialize and call methods that utilizes hwdata, they will call it and the first
1420
+ call may take 0.1 to 0.2 seconds, the consecutive calls will then take under a millisecond.
1421
+
1422
+ ## Note 8: PrettifyBytes
1285
1423
  Often times we need to work with KB, MB GB, TB, or KiB, MiB, GiB, TiB, etc.
1286
1424
  And we need some work to convert bytes to those units.
1287
1425
  Because LinuxStat provides a lot of data in bytes, and kilobytes, it's quite tedious to convert them all the time.