linux_stat 1.1.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +108 -64
- data/ext/sysconf/sysconf.c +11 -0
- data/lib/linux_stat.rb +1 -0
- data/lib/linux_stat/battery.rb +2 -0
- data/lib/linux_stat/bios.rb +2 -0
- data/lib/linux_stat/cpu.rb +2 -0
- data/lib/linux_stat/filesystem.rb +2 -0
- data/lib/linux_stat/kernel.rb +2 -0
- data/lib/linux_stat/memory.rb +9 -7
- data/lib/linux_stat/mounts.rb +5 -3
- data/lib/linux_stat/net.rb +6 -4
- data/lib/linux_stat/os.rb +50 -15
- data/lib/linux_stat/pci.rb +61 -56
- data/lib/linux_stat/prettify_bytes.rb +7 -0
- data/lib/linux_stat/process.rb +48 -23
- data/lib/linux_stat/process_info.rb +7 -0
- data/lib/linux_stat/swap.rb +6 -4
- data/lib/linux_stat/thermal.rb +122 -0
- data/lib/linux_stat/usb.rb +52 -48
- data/lib/linux_stat/user.rb +6 -3
- data/lib/linux_stat/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58652553450c8570d4e9d1137256e8b27155bf7f61f2bd89f423f3eb3e6fd907
|
4
|
+
data.tar.gz: d90289e14f856823d2370d7a0629769d874d8f630043c1cce0fd3c357ca12f1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ee5142e8a10b2f4171aac6901b9cb98d9ca9ef74738e39f7b4dfca15381ee6c4a40c0815bb957476250958d207d21e8759266c3c7229af510b189d4ec7d758f
|
7
|
+
data.tar.gz: 454c9d051de0a49156e421a1c866e4b690fd6d98bdcb714acabb18d6b5e13c1ae29b1bb1035b75962e1e47f9a7094b6a5bde46742e54212aac427103f56308d4
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ LinuxStat lets you read status of a Linux system. It can show you cpu stats and
|
|
10
10
|
|
11
11
|
It only works for Linux, and detecting the OS is upto the user of this gem.
|
12
12
|
|
13
|
-
|
13
|
+
Languages Used:
|
14
14
|
|
15
15
|
<img src="https://linuxstatloc.herokuapp.com/badge.svg" width="260px">
|
16
16
|
|
@@ -114,7 +114,7 @@ LinuxStat::BIOS.version()
|
|
114
114
|
# File: battery.rb | Line: 105
|
115
115
|
# Definition: def charge
|
116
116
|
LinuxStat::Battery.charge()
|
117
|
-
=>
|
117
|
+
=> 100.0
|
118
118
|
|
119
119
|
# File: battery.rb | Line: 122
|
120
120
|
# Definition: def charge_full_design_wh
|
@@ -134,7 +134,7 @@ LinuxStat::Battery.charging?()
|
|
134
134
|
# File: battery.rb | Line: 184
|
135
135
|
# Definition: def devices_stat
|
136
136
|
LinuxStat::Battery.devices_stat()
|
137
|
-
=> {:AC=>{:type=>"Mains", :online=>1}, :BAT0=>{:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :type=>"Battery", :status=>"
|
137
|
+
=> {: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....
|
138
138
|
|
139
139
|
# File: battery.rb | Line: 87
|
140
140
|
# Definition: def discharging?
|
@@ -144,7 +144,7 @@ LinuxStat::Battery.discharging?()
|
|
144
144
|
# File: battery.rb | Line: 96
|
145
145
|
# Definition: def full?
|
146
146
|
LinuxStat::Battery.full?()
|
147
|
-
=>
|
147
|
+
=> true
|
148
148
|
|
149
149
|
# File: battery.rb | Line: 47
|
150
150
|
# Definition: def manufacturer
|
@@ -164,12 +164,12 @@ LinuxStat::Battery.present?()
|
|
164
164
|
# File: battery.rb | Line: 16
|
165
165
|
# Definition: def stat
|
166
166
|
LinuxStat::Battery.stat()
|
167
|
-
=> {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"
|
167
|
+
=> {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Full", :charge=>100.0, :charging=>true, :discharging=>false, :full=>true}
|
168
168
|
|
169
169
|
# File: battery.rb | Line: 68
|
170
170
|
# Definition: def status
|
171
171
|
LinuxStat::Battery.status()
|
172
|
-
=> "
|
172
|
+
=> "Full"
|
173
173
|
|
174
174
|
# File: battery.rb | Line: 57
|
175
175
|
# Definition: def technology
|
@@ -179,7 +179,7 @@ LinuxStat::Battery.technology()
|
|
179
179
|
# File: battery.rb | Line: 160
|
180
180
|
# Definition: def voltage_now
|
181
181
|
LinuxStat::Battery.voltage_now()
|
182
|
-
=> 12.
|
182
|
+
=> 12.625
|
183
183
|
|
184
184
|
```
|
185
185
|
|
@@ -203,7 +203,7 @@ LinuxStat::CPU.count_online()
|
|
203
203
|
# File: cpu.rb | Line: 197
|
204
204
|
# Definition: def cur_freq
|
205
205
|
LinuxStat::CPU.cur_freq()
|
206
|
-
=> {"cpu0"=>
|
206
|
+
=> {"cpu0"=>1999999, "cpu1"=>2000045, "cpu2"=>2000144, "cpu3"=>2000034}
|
207
207
|
|
208
208
|
# File: cpu.rb | Line: 265
|
209
209
|
# Definition: def governor
|
@@ -238,29 +238,29 @@ LinuxStat::CPU.online()
|
|
238
238
|
# File: cpu.rb | Line: 23
|
239
239
|
# Definition: def stat(sleep = ticks_to_ms_t5)
|
240
240
|
LinuxStat::CPU.stat(sleep)
|
241
|
-
=> {0=>
|
241
|
+
=> {0=>10.0, 1=>0.0, 2=>0.0, 3=>16.67, 4=>0.0}
|
242
242
|
|
243
243
|
# File: cpu.rb | Line: 63
|
244
244
|
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
245
245
|
LinuxStat::CPU.total_usage(sleep)
|
246
|
-
=>
|
246
|
+
=> 19.05
|
247
247
|
|
248
248
|
# File: cpu.rb | Line: 63
|
249
249
|
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
250
250
|
LinuxStat::CPU.usage(sleep)
|
251
|
-
=>
|
251
|
+
=> 5.26
|
252
252
|
|
253
253
|
# File: cpu.rb | Line: 23
|
254
254
|
# Definition: def stat(sleep = ticks_to_ms_t5)
|
255
255
|
LinuxStat::CPU.usages(sleep)
|
256
|
-
=> {0=>
|
256
|
+
=> {0=>5.26, 1=>0.0, 2=>0.0, 3=>33.33, 4=>20.0}
|
257
257
|
|
258
258
|
```
|
259
259
|
|
260
260
|
### LinuxStat::FS
|
261
261
|
```
|
262
262
|
LinuxStat::FS.stat(arg = "/")
|
263
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>
|
263
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>10846968, :block_avail_unpriv=>10846968, :inodes=>58612160, :free_inodes=>56825184, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
264
264
|
|
265
265
|
```
|
266
266
|
|
@@ -269,22 +269,22 @@ LinuxStat::FS.stat(arg = "/")
|
|
269
269
|
# File: filesystem.rb | Line: 92
|
270
270
|
# Definition: def available(fs = ?..freeze)
|
271
271
|
LinuxStat::Filesystem.available(fs)
|
272
|
-
=>
|
272
|
+
=> 44429180928
|
273
273
|
|
274
274
|
# File: filesystem.rb | Line: 58
|
275
275
|
# Definition: def free(fs = ?..freeze)
|
276
276
|
LinuxStat::Filesystem.free(fs)
|
277
|
-
=>
|
277
|
+
=> 44429180928
|
278
278
|
|
279
279
|
# File: filesystem.rb | Line: 19
|
280
280
|
# Definition: def stat(fs = ?..freeze)
|
281
281
|
LinuxStat::Filesystem.stat(fs)
|
282
|
-
=> {:total=>119981191168, :free=>
|
282
|
+
=> {:total=>119981191168, :free=>44429180928, :used=>75552010240}
|
283
283
|
|
284
284
|
# File: filesystem.rb | Line: 108
|
285
285
|
# Definition: def stat_raw(fs = ?..freeze)
|
286
286
|
LinuxStat::Filesystem.stat_raw(fs)
|
287
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>
|
287
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>10846968, :block_avail_unpriv=>10846968, :inodes=>58612160, :free_inodes=>56825184, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
288
288
|
|
289
289
|
# File: filesystem.rb | Line: 39
|
290
290
|
# Definition: def total(fs = ?..freeze)
|
@@ -294,7 +294,7 @@ LinuxStat::Filesystem.total(fs)
|
|
294
294
|
# File: filesystem.rb | Line: 73
|
295
295
|
# Definition: def used(fs = ?..freeze)
|
296
296
|
LinuxStat::Filesystem.used(fs)
|
297
|
-
=>
|
297
|
+
=> 75552010240
|
298
298
|
|
299
299
|
```
|
300
300
|
|
@@ -357,22 +357,22 @@ LinuxStat::Kernel.version()
|
|
357
357
|
# File: memory.rb | Line: 50
|
358
358
|
# Definition: def available
|
359
359
|
LinuxStat::Memory.available()
|
360
|
-
=>
|
360
|
+
=> 375384
|
361
361
|
|
362
362
|
# File: memory.rb | Line: 81
|
363
363
|
# Definition: def percent_available
|
364
364
|
LinuxStat::Memory.percent_available()
|
365
|
-
=>
|
365
|
+
=> 9.79
|
366
366
|
|
367
367
|
# File: memory.rb | Line: 70
|
368
368
|
# Definition: def percent_used
|
369
369
|
LinuxStat::Memory.percent_used()
|
370
|
-
=>
|
370
|
+
=> 90.21
|
371
371
|
|
372
372
|
# File: memory.rb | Line: 11
|
373
373
|
# Definition: def stat
|
374
374
|
LinuxStat::Memory.stat()
|
375
|
-
=> {:total=>3836036, :used=>
|
375
|
+
=> {:total=>3836036, :used=>3460652, :available=>375384, :percent_used=>90.21, :percent_available=>9.79}
|
376
376
|
|
377
377
|
# File: memory.rb | Line: 40
|
378
378
|
# Definition: def total
|
@@ -382,7 +382,7 @@ LinuxStat::Memory.total()
|
|
382
382
|
# File: memory.rb | Line: 60
|
383
383
|
# Definition: def used
|
384
384
|
LinuxStat::Memory.used()
|
385
|
-
=>
|
385
|
+
=> 3460652
|
386
386
|
|
387
387
|
```
|
388
388
|
|
@@ -391,7 +391,7 @@ LinuxStat::Memory.used()
|
|
391
391
|
# File: mounts.rb | Line: 179
|
392
392
|
# Definition: def device_stat(dev = root)
|
393
393
|
LinuxStat::Mounts.device_stat(dev)
|
394
|
-
=> {:mountpoint=>"/", :total=>119981191168, :free=>
|
394
|
+
=> {:mountpoint=>"/", :total=>119981191168, :free=>44429180928, :available=>44429180928, :used=>75552010240, :percent_used=>62.97, :percent_free=>37.03, :percent_available=>37.03}
|
395
395
|
|
396
396
|
# File: mounts.rb | Line: 137
|
397
397
|
# Definition: def devices_stat
|
@@ -411,7 +411,7 @@ LinuxStat::Mounts.list_devices()
|
|
411
411
|
# File: mounts.rb | Line: 109
|
412
412
|
# Definition: def list_devices_mount_point
|
413
413
|
LinuxStat::Mounts.list_devices_mount_point()
|
414
|
-
=> {"proc"=>"/proc", "sys"=>"/sys", "dev"=>"/dev", "run"=>"/run", "/dev/sda2"=>"/", "securityfs"=>"/sys/kernel/security", "tmpfs"=>"/run/user/
|
414
|
+
=> {"proc"=>"/proc", "sys"=>"/sys", "dev"=>"/dev", "run"=>"/run", "/dev/sda2"=>"/", "securityfs"=>"/sys/kernel/security", "tmpfs"=>"/run/user/0", "devpts"=>"/dev/pts", "cgroup2"=>"/sys/fs/cgroup/unified", "cgroup"=>"/sys/fs/cgroup/cpuset", "pstore"=>"/sy...
|
415
415
|
|
416
416
|
# File: mounts.rb | Line: 80
|
417
417
|
# Definition: def mount_point(dev = root)
|
@@ -445,7 +445,7 @@ LinuxStat::Mounts.tmpfs()
|
|
445
445
|
# File: net.rb | Line: 84
|
446
446
|
# Definition: def usage(interval = 0.1)
|
447
447
|
LinuxStat::Net.current_usage(interval)
|
448
|
-
=> {:received=>
|
448
|
+
=> {:received=>279000.0, :transmitted=>5640.0}
|
449
449
|
|
450
450
|
# File: net.rb | Line: 10
|
451
451
|
# Definition: def ipv4_private
|
@@ -455,38 +455,43 @@ LinuxStat::Net.ipv4_private()
|
|
455
455
|
# File: net.rb | Line: 25
|
456
456
|
# Definition: def total_bytes
|
457
457
|
LinuxStat::Net.total_bytes()
|
458
|
-
=> {:received=>
|
458
|
+
=> {:received=>2093813713, :transmitted=>138899807}
|
459
459
|
|
460
460
|
# File: net.rb | Line: 43
|
461
461
|
# Definition: def total_bytes_received
|
462
462
|
LinuxStat::Net.total_bytes_received()
|
463
|
-
=>
|
463
|
+
=> 2093813713
|
464
464
|
|
465
465
|
# File: net.rb | Line: 56
|
466
466
|
# Definition: def total_bytes_transmitted
|
467
467
|
LinuxStat::Net.total_bytes_transmitted()
|
468
|
-
=>
|
468
|
+
=> 138899807
|
469
469
|
|
470
470
|
# File: net.rb | Line: 84
|
471
471
|
# Definition: def usage(interval = 0.1)
|
472
472
|
LinuxStat::Net.usage(interval)
|
473
|
-
=> {:received=>
|
473
|
+
=> {:received=>419320.0, :transmitted=>10340.0}
|
474
474
|
|
475
475
|
```
|
476
476
|
|
477
477
|
### LinuxStat::OS
|
478
478
|
```
|
479
|
-
# File: os.rb | Line:
|
479
|
+
# File: os.rb | Line: 127
|
480
480
|
# Definition: def bits
|
481
481
|
LinuxStat::OS.bits()
|
482
482
|
=> 64
|
483
483
|
|
484
|
+
# File: os.rb | Line: 82
|
485
|
+
# Definition: def version
|
486
|
+
LinuxStat::OS.distrib_version()
|
487
|
+
=> "rolling"
|
488
|
+
|
484
489
|
# File: os.rb | Line: 44
|
485
490
|
# Definition: def distribution
|
486
491
|
LinuxStat::OS.distribution()
|
487
492
|
=> "Arch Linux"
|
488
493
|
|
489
|
-
# File: os.rb | Line:
|
494
|
+
# File: os.rb | Line: 115
|
490
495
|
# Definition: def hostname
|
491
496
|
LinuxStat::OS.hostname()
|
492
497
|
=> "archlinux"
|
@@ -496,12 +501,12 @@ LinuxStat::OS.hostname()
|
|
496
501
|
LinuxStat::OS.lsb_release()
|
497
502
|
=> {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
|
498
503
|
|
499
|
-
# File: os.rb | Line:
|
504
|
+
# File: os.rb | Line: 98
|
500
505
|
# Definition: def machine
|
501
506
|
LinuxStat::OS.machine()
|
502
507
|
=> "x86_64"
|
503
508
|
|
504
|
-
# File: os.rb | Line:
|
509
|
+
# File: os.rb | Line: 106
|
505
510
|
# Definition: def nodename
|
506
511
|
LinuxStat::OS.nodename()
|
507
512
|
=> "archlinux"
|
@@ -511,10 +516,15 @@ LinuxStat::OS.nodename()
|
|
511
516
|
LinuxStat::OS.os_release()
|
512
517
|
=> {: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/"...
|
513
518
|
|
514
|
-
# File: os.rb | Line:
|
519
|
+
# File: os.rb | Line: 142
|
515
520
|
# Definition: def uptime
|
516
521
|
LinuxStat::OS.uptime()
|
517
|
-
=> {:hour=>
|
522
|
+
=> {:hour=>14, :minute=>24, :second=>12.06}
|
523
|
+
|
524
|
+
# File: os.rb | Line: 82
|
525
|
+
# Definition: def version
|
526
|
+
LinuxStat::OS.version()
|
527
|
+
=> "rolling"
|
518
528
|
|
519
529
|
```
|
520
530
|
|
@@ -561,23 +571,23 @@ LinuxStat::PCI.initialize_hwdata()
|
|
561
571
|
```
|
562
572
|
# File: prettify_bytes.rb | Line: 42
|
563
573
|
# Definition: def convert_binary(n)
|
564
|
-
LinuxStat::PrettifyBytes.convert_binary(n =
|
565
|
-
=> "
|
574
|
+
LinuxStat::PrettifyBytes.convert_binary(n = 320846048510750)
|
575
|
+
=> "291.81 tebibytes"
|
566
576
|
|
567
577
|
# File: prettify_bytes.rb | Line: 19
|
568
578
|
# Definition: def convert_decimal(n)
|
569
|
-
LinuxStat::PrettifyBytes.convert_decimal(n =
|
570
|
-
=> "
|
579
|
+
LinuxStat::PrettifyBytes.convert_decimal(n = 996984130887475)
|
580
|
+
=> "996.98 terabytes"
|
571
581
|
|
572
582
|
# File: prettify_bytes.rb | Line: 90
|
573
583
|
# Definition: def convert_short_binary(n)
|
574
|
-
LinuxStat::PrettifyBytes.convert_short_binary(n =
|
575
|
-
=> "
|
584
|
+
LinuxStat::PrettifyBytes.convert_short_binary(n = 396350966829319)
|
585
|
+
=> "360.48 TiB"
|
576
586
|
|
577
587
|
# File: prettify_bytes.rb | Line: 65
|
578
588
|
# Definition: def convert_short_decimal(n)
|
579
|
-
LinuxStat::PrettifyBytes.convert_short_decimal(n =
|
580
|
-
=> "
|
589
|
+
LinuxStat::PrettifyBytes.convert_short_decimal(n = 558910893490277)
|
590
|
+
=> "558.91 TB"
|
581
591
|
|
582
592
|
```
|
583
593
|
|
@@ -586,12 +596,12 @@ LinuxStat::PrettifyBytes.convert_short_decimal(n = 448181119260617)
|
|
586
596
|
# File: process.rb | Line: 19
|
587
597
|
# Definition: def count
|
588
598
|
LinuxStat::Process.count()
|
589
|
-
=>
|
599
|
+
=> 210
|
590
600
|
|
591
601
|
# File: process.rb | Line: 71
|
592
602
|
# Definition: def idle
|
593
603
|
LinuxStat::Process.idle()
|
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,
|
604
|
+
=> [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, 20004, 29...
|
595
605
|
|
596
606
|
# File: process.rb | Line: 8
|
597
607
|
# Definition: def list
|
@@ -606,12 +616,12 @@ LinuxStat::Process.names()
|
|
606
616
|
# File: process.rb | Line: 97
|
607
617
|
# Definition: def running
|
608
618
|
LinuxStat::Process.running()
|
609
|
-
=> [
|
619
|
+
=> [34967]
|
610
620
|
|
611
621
|
# File: process.rb | Line: 58
|
612
622
|
# Definition: def sleeping
|
613
623
|
LinuxStat::Process.sleeping()
|
614
|
-
=> [1, 2, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20,
|
624
|
+
=> [1, 2, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 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, 351, 376, 403, 405, 406...
|
615
625
|
|
616
626
|
# File: process.rb | Line: 37
|
617
627
|
# Definition: def types
|
@@ -630,7 +640,7 @@ LinuxStat::Process.zombie()
|
|
630
640
|
# File: process_info.rb | Line: 54
|
631
641
|
# Definition: def cmdline(pid = $$)
|
632
642
|
LinuxStat::ProcessInfo.cmdline(pid)
|
633
|
-
=> "/usr/bin/ruby /home/sourav/.gem/ruby/2.7.0/bin/linuxstat.rb
|
643
|
+
=> "/usr/bin/ruby /home/sourav/.gem/ruby/2.7.0/bin/linuxstat.rb --markdown"
|
634
644
|
|
635
645
|
# File: process_info.rb | Line: 78
|
636
646
|
# Definition: def command_name(pid = $$)
|
@@ -665,12 +675,12 @@ LinuxStat::ProcessInfo.last_executed_cpu(pid)
|
|
665
675
|
# File: process_info.rb | Line: 114
|
666
676
|
# Definition: def mem_stat(pid = $$)
|
667
677
|
LinuxStat::ProcessInfo.mem_stat(pid)
|
668
|
-
=> {:memory=>
|
678
|
+
=> {:memory=>26836.992, :virtual_memory=>97992.704, :resident_memory=>32841.728}
|
669
679
|
|
670
680
|
# File: process_info.rb | Line: 147
|
671
681
|
# Definition: def memory(pid = $$)
|
672
682
|
LinuxStat::ProcessInfo.memory(pid)
|
673
|
-
=>
|
683
|
+
=> 26836.992
|
674
684
|
|
675
685
|
# File: process_info.rb | Line: 607
|
676
686
|
# Definition: def nice(pid = $$)
|
@@ -690,7 +700,7 @@ LinuxStat::ProcessInfo.owner(pid)
|
|
690
700
|
# File: process_info.rb | Line: 197
|
691
701
|
# Definition: def resident_memory(pid = $$)
|
692
702
|
LinuxStat::ProcessInfo.resident_memory(pid)
|
693
|
-
=>
|
703
|
+
=> 32841.728
|
694
704
|
|
695
705
|
# File: process_info.rb | Line: 563
|
696
706
|
# Definition: def running_time(pid = $$)
|
@@ -700,12 +710,12 @@ LinuxStat::ProcessInfo.running_time(pid)
|
|
700
710
|
# File: process_info.rb | Line: 544
|
701
711
|
# Definition: def start_time(pid = $$)
|
702
712
|
LinuxStat::ProcessInfo.start_time(pid)
|
703
|
-
=> 2020-12-
|
713
|
+
=> 2020-12-29 01:58:56 +0530
|
704
714
|
|
705
715
|
# File: process_info.rb | Line: 513
|
706
716
|
# Definition: def start_time_epoch(pid = $$)
|
707
717
|
LinuxStat::ProcessInfo.start_time_epoch(pid)
|
708
|
-
=>
|
718
|
+
=> 1609187336
|
709
719
|
|
710
720
|
# File: process_info.rb | Line: 592
|
711
721
|
# Definition: def state(pid = $$)
|
@@ -725,7 +735,7 @@ LinuxStat::ProcessInfo.threads(pid)
|
|
725
735
|
# File: process_info.rb | Line: 23
|
726
736
|
# Definition: def total_io(pid = $$)
|
727
737
|
LinuxStat::ProcessInfo.total_io(pid)
|
728
|
-
=> {:read_bytes=>
|
738
|
+
=> {:read_bytes=>1249280, :write_bytes=>0}
|
729
739
|
|
730
740
|
# File: process_info.rb | Line: 446
|
731
741
|
# Definition: def uid(pid = $$)
|
@@ -735,7 +745,7 @@ LinuxStat::ProcessInfo.uid(pid)
|
|
735
745
|
# File: process_info.rb | Line: 172
|
736
746
|
# Definition: def virtual_memory(pid = $$)
|
737
747
|
LinuxStat::ProcessInfo.virtual_memory(pid)
|
738
|
-
=>
|
748
|
+
=> 97992.704
|
739
749
|
|
740
750
|
```
|
741
751
|
|
@@ -749,27 +759,27 @@ LinuxStat::Swap.any?()
|
|
749
759
|
# File: swap.rb | Line: 68
|
750
760
|
# Definition: def available
|
751
761
|
LinuxStat::Swap.available()
|
752
|
-
=>
|
762
|
+
=> 2293908
|
753
763
|
|
754
764
|
# File: swap.rb | Line: 8
|
755
765
|
# Definition: def list
|
756
766
|
LinuxStat::Swap.list()
|
757
|
-
=> {"/dev/zram0"=>[:partition, 4194300,
|
767
|
+
=> {"/dev/zram0"=>[:partition, 4194300, 1900392, -2]}
|
758
768
|
|
759
769
|
# File: swap.rb | Line: 103
|
760
770
|
# Definition: def percent_available
|
761
771
|
LinuxStat::Swap.percent_available()
|
762
|
-
=> 69
|
772
|
+
=> 54.69
|
763
773
|
|
764
774
|
# File: swap.rb | Line: 89
|
765
775
|
# Definition: def percent_used
|
766
776
|
LinuxStat::Swap.percent_used()
|
767
|
-
=>
|
777
|
+
=> 45.31
|
768
778
|
|
769
779
|
# File: swap.rb | Line: 32
|
770
780
|
# Definition: def stat
|
771
781
|
LinuxStat::Swap.stat()
|
772
|
-
=> {:total=>4194300, :used=>
|
782
|
+
=> {:total=>4194300, :used=>1900392, :available=>2293908, :percent_used=>45.31, :percent_available=>54.69}
|
773
783
|
|
774
784
|
# File: swap.rb | Line: 57
|
775
785
|
# Definition: def total
|
@@ -779,7 +789,7 @@ LinuxStat::Swap.total()
|
|
779
789
|
# File: swap.rb | Line: 80
|
780
790
|
# Definition: def used
|
781
791
|
LinuxStat::Swap.used()
|
782
|
-
=>
|
792
|
+
=> 1900392
|
783
793
|
|
784
794
|
```
|
785
795
|
|
@@ -806,6 +816,9 @@ LinuxStat::Sysconf.get_uid()
|
|
806
816
|
LinuxStat::Sysconf.get_user()
|
807
817
|
=> "sourav"
|
808
818
|
|
819
|
+
LinuxStat::Sysconf.hostname()
|
820
|
+
=> "archlinux"
|
821
|
+
|
809
822
|
LinuxStat::Sysconf.hostname_max()
|
810
823
|
=> 64
|
811
824
|
|
@@ -841,6 +854,30 @@ LinuxStat::Sysconf.tty_name_max()
|
|
841
854
|
|
842
855
|
```
|
843
856
|
|
857
|
+
### LinuxStat::Thermal
|
858
|
+
```
|
859
|
+
# File: thermal.rb | Line: 57
|
860
|
+
# Definition: def count_fans
|
861
|
+
LinuxStat::Thermal.count_fans()
|
862
|
+
=> 1
|
863
|
+
|
864
|
+
# File: thermal.rb | Line: 49
|
865
|
+
# Definition: def count_sensors
|
866
|
+
LinuxStat::Thermal.count_sensors()
|
867
|
+
=> 8
|
868
|
+
|
869
|
+
# File: thermal.rb | Line: 41
|
870
|
+
# Definition: def fans
|
871
|
+
LinuxStat::Thermal.fans()
|
872
|
+
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Processor Fan", :rpm=>0}]
|
873
|
+
|
874
|
+
# File: thermal.rb | Line: 23
|
875
|
+
# Definition: def temperatures
|
876
|
+
LinuxStat::Thermal.temperatures()
|
877
|
+
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"SODIMM", :temperature=>36.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"CPU", :temperature=>46.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Ambi...
|
878
|
+
|
879
|
+
```
|
880
|
+
|
844
881
|
### LinuxStat::USB
|
845
882
|
```
|
846
883
|
# File: usb.rb | Line: 135
|
@@ -1363,7 +1400,14 @@ Right, the get_login() can return an empty string. But LinuxStat::User.get_user
|
|
1363
1400
|
|
1364
1401
|
## Note 7: Hwdata
|
1365
1402
|
The PCI and USB modules actually rely on hwdata found in /usr/share/hwdata/.
|
1366
|
-
|
1403
|
+
The LS::USB.devices_stat and LS::PCI.devices_stat returns the information in a Hash:
|
1404
|
+
|
1405
|
+
```
|
1406
|
+
$ ruby -r linux_stat -e "puts LS::USB.devices_stat.to_s[0..200]"
|
1407
|
+
[{: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"}, :aut
|
1408
|
+
```
|
1409
|
+
|
1410
|
+
But if the files are not available, it won't return hwdata related information.
|
1367
1411
|
|
1368
1412
|
So it's suggested to install hwdata. But you might face issues with heroku and
|
1369
1413
|
other online PaaS where you can't install it. So Version 1.1.1+ comes with a module function called `hwdata_file = file`.
|
@@ -1377,7 +1421,7 @@ LS::USB.hwdata_file = File.join(__dir__, 'hwdata', 'usb.ids')
|
|
1377
1421
|
|
1378
1422
|
Assuming that you have `pci.ids` and `usb.ids` under ./hwdata directory.
|
1379
1423
|
|
1380
|
-
On rails, you can put this (replace `__dir__` with `Rails.root` inside environment.rb
|
1424
|
+
On rails, you can put this (replace `__dir__` with `Rails.root`) inside environment.rb.
|
1381
1425
|
|
1382
1426
|
But do note that the file can be set only once. It's suggested to do that in the beginning of your app.
|
1383
1427
|
|