linux_stat 2.1.2 → 2.2.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 -108
- data/ext/procfs/procfs.c +1 -0
- data/ext/procfs/stat.h +21 -0
- data/lib/linux_stat/os.rb +11 -5
- data/lib/linux_stat/process_info.rb +18 -12
- data/lib/linux_stat/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa2ee379e74b817dd795ceec02ddcdf67d49c2f0b2d37524906111c74ea40ccb
|
4
|
+
data.tar.gz: 540c6e1a9eef8b3596afe963b6387b107e8450ec879b7d96bd95ae271cced14a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1501322abefbddf6261133be26decb9a117a568fd73c2f76825e425ea0d256aee0fc8d1c4b805edd05d062631453ff73339bea280a250906419aa6cae6e6d32
|
7
|
+
data.tar.gz: 592ce707540e60071feb3ac0ce9fedd3bf026c234921cf074acb2640e96ea3c8d90906287960253b5700b373b465e4ac344c0389e1e5651970336b2251033c93
|
data/README.md
CHANGED
@@ -183,7 +183,7 @@ LinuxStat::Battery.technology()
|
|
183
183
|
# File: battery.rb | Line: 162
|
184
184
|
# Definition: def voltage_now
|
185
185
|
LinuxStat::Battery.voltage_now()
|
186
|
-
=> 12.
|
186
|
+
=> 12.531
|
187
187
|
|
188
188
|
```
|
189
189
|
|
@@ -207,7 +207,7 @@ LinuxStat::CPU.count_online()
|
|
207
207
|
# File: cpu.rb | Line: 199
|
208
208
|
# Definition: def cur_freq
|
209
209
|
LinuxStat::CPU.cur_freq()
|
210
|
-
=> {"cpu0"=>
|
210
|
+
=> {"cpu0"=>1969861, "cpu1"=>2000059, "cpu2"=>2000024, "cpu3"=>1949778}
|
211
211
|
|
212
212
|
# File: cpu.rb | Line: 267
|
213
213
|
# Definition: def governor
|
@@ -242,29 +242,29 @@ LinuxStat::CPU.online()
|
|
242
242
|
# File: cpu.rb | Line: 25
|
243
243
|
# Definition: def stat(sleep = ticks_to_ms_t5)
|
244
244
|
LinuxStat::CPU.stat(sleep)
|
245
|
-
=> {0=>
|
245
|
+
=> {0=>9.52, 1=>16.67, 2=>20.0, 3=>0.0, 4=>16.67}
|
246
246
|
|
247
247
|
# File: cpu.rb | Line: 65
|
248
248
|
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
249
249
|
LinuxStat::CPU.total_usage(sleep)
|
250
|
-
=>
|
250
|
+
=> 5.56
|
251
251
|
|
252
252
|
# File: cpu.rb | Line: 65
|
253
253
|
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
254
254
|
LinuxStat::CPU.usage(sleep)
|
255
|
-
=>
|
255
|
+
=> 5.0
|
256
256
|
|
257
257
|
# File: cpu.rb | Line: 25
|
258
258
|
# Definition: def stat(sleep = ticks_to_ms_t5)
|
259
259
|
LinuxStat::CPU.usages(sleep)
|
260
|
-
=> {0=>
|
260
|
+
=> {0=>10.0, 1=>0.0, 2=>0.0, 3=>0.0, 4=>0.0}
|
261
261
|
|
262
262
|
```
|
263
263
|
|
264
264
|
### LinuxStat::FS
|
265
265
|
```
|
266
266
|
LinuxStat::FS.stat(arg = "/")
|
267
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>
|
267
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>7498564, :block_avail_unpriv=>7498564, :inodes=>58612160, :free_inodes=>56765394, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
268
268
|
|
269
269
|
```
|
270
270
|
|
@@ -273,22 +273,22 @@ LinuxStat::FS.stat(arg = "/")
|
|
273
273
|
# File: filesystem.rb | Line: 94
|
274
274
|
# Definition: def available(fs = ?..freeze)
|
275
275
|
LinuxStat::Filesystem.available(fs)
|
276
|
-
=>
|
276
|
+
=> 30714118144
|
277
277
|
|
278
278
|
# File: filesystem.rb | Line: 60
|
279
279
|
# Definition: def free(fs = ?..freeze)
|
280
280
|
LinuxStat::Filesystem.free(fs)
|
281
|
-
=>
|
281
|
+
=> 30714118144
|
282
282
|
|
283
283
|
# File: filesystem.rb | Line: 21
|
284
284
|
# Definition: def stat(fs = ?..freeze)
|
285
285
|
LinuxStat::Filesystem.stat(fs)
|
286
|
-
=> {:total=>119981191168, :free=>
|
286
|
+
=> {:total=>119981191168, :free=>30714118144, :used=>89267073024}
|
287
287
|
|
288
288
|
# File: filesystem.rb | Line: 110
|
289
289
|
# Definition: def stat_raw(fs = ?..freeze)
|
290
290
|
LinuxStat::Filesystem.stat_raw(fs)
|
291
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>
|
291
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>7498564, :block_avail_unpriv=>7498564, :inodes=>58612160, :free_inodes=>56765394, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
292
292
|
|
293
293
|
# File: filesystem.rb | Line: 41
|
294
294
|
# Definition: def total(fs = ?..freeze)
|
@@ -298,7 +298,7 @@ LinuxStat::Filesystem.total(fs)
|
|
298
298
|
# File: filesystem.rb | Line: 75
|
299
299
|
# Definition: def used(fs = ?..freeze)
|
300
300
|
LinuxStat::Filesystem.used(fs)
|
301
|
-
=>
|
301
|
+
=> 89267073024
|
302
302
|
|
303
303
|
```
|
304
304
|
|
@@ -361,37 +361,37 @@ LinuxStat::Kernel.version()
|
|
361
361
|
# File: memory.rb | Line: 62
|
362
362
|
# Definition: def available
|
363
363
|
LinuxStat::Memory.available()
|
364
|
-
=>
|
364
|
+
=> 595616
|
365
365
|
|
366
366
|
# File: memory.rb | Line: 52
|
367
367
|
# Definition: def free
|
368
368
|
LinuxStat::Memory.free()
|
369
|
-
=>
|
369
|
+
=> 256356
|
370
370
|
|
371
371
|
# File: memory.rb | Line: 93
|
372
372
|
# Definition: def percent_available
|
373
373
|
LinuxStat::Memory.percent_available()
|
374
|
-
=>
|
374
|
+
=> 15.53
|
375
375
|
|
376
376
|
# File: memory.rb | Line: 82
|
377
377
|
# Definition: def percent_used
|
378
378
|
LinuxStat::Memory.percent_used()
|
379
|
-
=>
|
379
|
+
=> 84.47
|
380
380
|
|
381
381
|
# File: memory.rb | Line: 13
|
382
382
|
# Definition: def stat
|
383
383
|
LinuxStat::Memory.stat()
|
384
|
-
=> {:total=>
|
384
|
+
=> {:total=>3836228, :used=>3240612, :available=>595616, :percent_used=>84.47, :percent_available=>15.53}
|
385
385
|
|
386
386
|
# File: memory.rb | Line: 42
|
387
387
|
# Definition: def total
|
388
388
|
LinuxStat::Memory.total()
|
389
|
-
=>
|
389
|
+
=> 3836228
|
390
390
|
|
391
391
|
# File: memory.rb | Line: 72
|
392
392
|
# Definition: def used
|
393
393
|
LinuxStat::Memory.used()
|
394
|
-
=>
|
394
|
+
=> 3240620
|
395
395
|
|
396
396
|
```
|
397
397
|
|
@@ -400,7 +400,7 @@ LinuxStat::Memory.used()
|
|
400
400
|
# File: mounts.rb | Line: 181
|
401
401
|
# Definition: def device_stat(dev = root)
|
402
402
|
LinuxStat::Mounts.device_stat(dev)
|
403
|
-
=> {:mountpoint=>"/", :total=>119981191168, :free=>
|
403
|
+
=> {:mountpoint=>"/", :total=>119981191168, :free=>30714118144, :available=>30714118144, :used=>89267073024, :percent_used=>74.4, :percent_free=>25.6, :percent_available=>25.6}
|
404
404
|
|
405
405
|
# File: mounts.rb | Line: 139
|
406
406
|
# Definition: def devices_stat
|
@@ -410,17 +410,17 @@ LinuxStat::Mounts.devices_stat()
|
|
410
410
|
# File: mounts.rb | Line: 13
|
411
411
|
# Definition: def list
|
412
412
|
LinuxStat::Mounts.list()
|
413
|
-
=> ["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=
|
413
|
+
=> ["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=1892888k,nr_inodes=473222,mode=755 0 0", "run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0", "...
|
414
414
|
|
415
415
|
# File: mounts.rb | Line: 22
|
416
416
|
# Definition: def list_devices
|
417
417
|
LinuxStat::Mounts.list_devices()
|
418
|
-
=> ["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", "
|
418
|
+
=> ["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", "deb...
|
419
419
|
|
420
420
|
# File: mounts.rb | Line: 111
|
421
421
|
# Definition: def list_devices_mount_point
|
422
422
|
LinuxStat::Mounts.list_devices_mount_point()
|
423
|
-
=> {"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/
|
423
|
+
=> {"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/rdma", "pstore"=>"/s...
|
424
424
|
|
425
425
|
# File: mounts.rb | Line: 82
|
426
426
|
# Definition: def mount_point(dev = root)
|
@@ -445,7 +445,7 @@ LinuxStat::Mounts.root_mount_options()
|
|
445
445
|
# File: mounts.rb | Line: 58
|
446
446
|
# Definition: def tmpfs
|
447
447
|
LinuxStat::Mounts.tmpfs()
|
448
|
-
=> {"/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", "/
|
448
|
+
=> {"/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", "/ramdisk"=>"tmpfs /ramdisk tmpfs rw,nosuid,nodev,relatime,size=6291456k 0 0", "/tmp...
|
449
449
|
|
450
450
|
```
|
451
451
|
|
@@ -459,93 +459,93 @@ LinuxStat::Net.current_usage(interval)
|
|
459
459
|
# File: net.rb | Line: 12
|
460
460
|
# Definition: def ipv4_private
|
461
461
|
LinuxStat::Net.ipv4_private()
|
462
|
-
=> "192.168.
|
462
|
+
=> "192.168.0.103"
|
463
463
|
|
464
464
|
# File: net.rb | Line: 27
|
465
465
|
# Definition: def total_bytes
|
466
466
|
LinuxStat::Net.total_bytes()
|
467
|
-
=> {:received=>
|
467
|
+
=> {:received=>2371748196, :transmitted=>220748232}
|
468
468
|
|
469
469
|
# File: net.rb | Line: 45
|
470
470
|
# Definition: def total_bytes_received
|
471
471
|
LinuxStat::Net.total_bytes_received()
|
472
|
-
=>
|
472
|
+
=> 2371748196
|
473
473
|
|
474
474
|
# File: net.rb | Line: 58
|
475
475
|
# Definition: def total_bytes_transmitted
|
476
476
|
LinuxStat::Net.total_bytes_transmitted()
|
477
|
-
=>
|
477
|
+
=> 220748232
|
478
478
|
|
479
479
|
# File: net.rb | Line: 86
|
480
480
|
# Definition: def usage(interval = 0.1)
|
481
481
|
LinuxStat::Net.usage(interval)
|
482
|
-
=> {:received=>
|
482
|
+
=> {:received=>820.0, :transmitted=>0.0}
|
483
483
|
|
484
484
|
```
|
485
485
|
|
486
486
|
### LinuxStat::OS
|
487
487
|
```
|
488
|
-
# File: os.rb | Line:
|
488
|
+
# File: os.rb | Line: 133
|
489
489
|
# Definition: def bits
|
490
490
|
LinuxStat::OS.bits()
|
491
491
|
=> 64
|
492
492
|
|
493
|
-
# File: os.rb | Line:
|
493
|
+
# File: os.rb | Line: 88
|
494
494
|
# Definition: def version
|
495
495
|
LinuxStat::OS.distrib_version()
|
496
496
|
=> "rolling"
|
497
497
|
|
498
|
-
# File: os.rb | Line:
|
498
|
+
# File: os.rb | Line: 50
|
499
499
|
# Definition: def distribution
|
500
500
|
LinuxStat::OS.distribution()
|
501
501
|
=> "Arch Linux"
|
502
502
|
|
503
|
-
# File: os.rb | Line:
|
503
|
+
# File: os.rb | Line: 121
|
504
504
|
# Definition: def hostname
|
505
505
|
LinuxStat::OS.hostname()
|
506
506
|
=> "archlinux"
|
507
507
|
|
508
|
-
# File: os.rb | Line:
|
508
|
+
# File: os.rb | Line: 208
|
509
509
|
# Definition: def loadavg
|
510
510
|
LinuxStat::OS.loadavg()
|
511
|
-
=> {1=>
|
511
|
+
=> {1=>2.873046875, 5=>1.9189453125, 15=>1.396484375}
|
512
512
|
|
513
|
-
# File: os.rb | Line:
|
513
|
+
# File: os.rb | Line: 39
|
514
514
|
# Definition: def lsb_release
|
515
515
|
LinuxStat::OS.lsb_release()
|
516
516
|
=> {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
|
517
517
|
|
518
|
-
# File: os.rb | Line:
|
518
|
+
# File: os.rb | Line: 104
|
519
519
|
# Definition: def machine
|
520
520
|
LinuxStat::OS.machine()
|
521
521
|
=> "x86_64"
|
522
522
|
|
523
|
-
# File: os.rb | Line:
|
523
|
+
# File: os.rb | Line: 112
|
524
524
|
# Definition: def nodename
|
525
525
|
LinuxStat::OS.nodename()
|
526
526
|
=> "archlinux"
|
527
527
|
|
528
|
-
# File: os.rb | Line:
|
528
|
+
# File: os.rb | Line: 23
|
529
529
|
# Definition: def os_release
|
530
530
|
LinuxStat::OS.os_release()
|
531
531
|
=> {: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/"...
|
532
532
|
|
533
|
-
# File: os.rb | Line:
|
533
|
+
# File: os.rb | Line: 150
|
534
534
|
# Definition: def uptime
|
535
535
|
LinuxStat::OS.uptime()
|
536
|
-
=> {:hour=>16, :minute=>
|
536
|
+
=> {:hour=>16, :minute=>16, :second=>1, :jiffy=>430}
|
537
537
|
|
538
|
-
# File: os.rb | Line:
|
538
|
+
# File: os.rb | Line: 180
|
539
539
|
# Definition: def uptime_f
|
540
540
|
LinuxStat::OS.uptime_f()
|
541
|
-
=>
|
541
|
+
=> 58561.43
|
542
542
|
|
543
|
-
# File: os.rb | Line:
|
543
|
+
# File: os.rb | Line: 191
|
544
544
|
# Definition: def uptime_i
|
545
545
|
LinuxStat::OS.uptime_i()
|
546
|
-
=>
|
546
|
+
=> 58562
|
547
547
|
|
548
|
-
# File: os.rb | Line:
|
548
|
+
# File: os.rb | Line: 88
|
549
549
|
# Definition: def version
|
550
550
|
LinuxStat::OS.version()
|
551
551
|
=> "rolling"
|
@@ -595,33 +595,33 @@ LinuxStat::PCI.initialize_hwdata()
|
|
595
595
|
```
|
596
596
|
# File: prettify_bytes.rb | Line: 49
|
597
597
|
# Definition: def convert_binary(n, precision: 2)
|
598
|
-
LinuxStat::PrettifyBytes.convert_binary(n =
|
599
|
-
=> "
|
598
|
+
LinuxStat::PrettifyBytes.convert_binary(n = 55206562261629, precision:)
|
599
|
+
=> "50.21 tebibytes"
|
600
600
|
|
601
601
|
# File: prettify_bytes.rb | Line: 26
|
602
602
|
# Definition: def convert_decimal(n, precision: 2)
|
603
|
-
LinuxStat::PrettifyBytes.convert_decimal(n =
|
604
|
-
=> "
|
603
|
+
LinuxStat::PrettifyBytes.convert_decimal(n = 341141363483637, precision:)
|
604
|
+
=> "341.14 terabytes"
|
605
605
|
|
606
606
|
# File: prettify_bytes.rb | Line: 97
|
607
607
|
# Definition: def convert_short_binary(n, precision: 2)
|
608
|
-
LinuxStat::PrettifyBytes.convert_short_binary(n =
|
609
|
-
=> "
|
608
|
+
LinuxStat::PrettifyBytes.convert_short_binary(n = 175331196815015, precision:)
|
609
|
+
=> "159.46 TiB"
|
610
610
|
|
611
611
|
# File: prettify_bytes.rb | Line: 72
|
612
612
|
# Definition: def convert_short_decimal(n, precision: 2)
|
613
|
-
LinuxStat::PrettifyBytes.convert_short_decimal(n =
|
614
|
-
=> "
|
613
|
+
LinuxStat::PrettifyBytes.convert_short_decimal(n = 789625492086030, precision:)
|
614
|
+
=> "789.63 TB"
|
615
615
|
|
616
616
|
```
|
617
617
|
|
618
618
|
### LinuxStat::ProcFS
|
619
619
|
```
|
620
620
|
LinuxStat::ProcFS.last_pid()
|
621
|
-
=>
|
621
|
+
=> 52438
|
622
622
|
|
623
623
|
LinuxStat::ProcFS.uptime_f()
|
624
|
-
=>
|
624
|
+
=> 58561.65
|
625
625
|
|
626
626
|
```
|
627
627
|
|
@@ -630,22 +630,22 @@ LinuxStat::ProcFS.uptime_f()
|
|
630
630
|
# File: process.rb | Line: 57
|
631
631
|
# Definition: def cmdlines
|
632
632
|
LinuxStat::Process.cmdlines()
|
633
|
-
=> {1=>"/
|
633
|
+
=> {1=>"/usr/lib/systemd/systemd --system --deserialize 63", 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=>""...
|
634
634
|
|
635
635
|
# File: process.rb | Line: 29
|
636
636
|
# Definition: def count
|
637
637
|
LinuxStat::Process.count()
|
638
|
-
=>
|
638
|
+
=> 212
|
639
639
|
|
640
640
|
# File: process.rb | Line: 120
|
641
641
|
# Definition: def idle
|
642
642
|
LinuxStat::Process.idle()
|
643
|
-
=> [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,
|
643
|
+
=> [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, 165, 168, 170, 171, 175, 180, 181, 182, 183, 184, 185, 186, 187, 189, 231, 234, 275, 447, 502, 21751, 23896, 41972, 41973, 41974, 41975, 41...
|
644
644
|
|
645
645
|
# File: process.rb | Line: 160
|
646
646
|
# Definition: def last_pid
|
647
647
|
LinuxStat::Process.last_pid()
|
648
|
-
=>
|
648
|
+
=> 52438
|
649
649
|
|
650
650
|
# File: process.rb | Line: 11
|
651
651
|
# Definition: def list
|
@@ -655,17 +655,17 @@ LinuxStat::Process.list()
|
|
655
655
|
# File: process.rb | Line: 36
|
656
656
|
# Definition: def names
|
657
657
|
LinuxStat::Process.names()
|
658
|
-
=> {1=>"systemd", 2=>"kthreadd", 3=>"rcu_gp", 4=>"rcu_par_gp", 6=>"kworker/0:0H", 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=>"
|
658
|
+
=> {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...
|
659
659
|
|
660
660
|
# File: process.rb | Line: 138
|
661
661
|
# Definition: def running
|
662
662
|
LinuxStat::Process.running()
|
663
|
-
=> [
|
663
|
+
=> [52438]
|
664
664
|
|
665
665
|
# File: process.rb | Line: 111
|
666
666
|
# Definition: def sleeping
|
667
667
|
LinuxStat::Process.sleeping()
|
668
|
-
=> [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,
|
668
|
+
=> [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, 164, 167, 188, 218, 233, 235, 308, 311, 362, 364, 365, 378, 379, 380, 381, 395, 398, 401, 465, 520, 522,...
|
669
669
|
|
670
670
|
# File: process.rb | Line: 147
|
671
671
|
# Definition: def stopped
|
@@ -689,14 +689,14 @@ LinuxStat::Process.zombie()
|
|
689
689
|
# File: process_info.rb | Line: 61
|
690
690
|
# Definition: def cmdline(pid = $$)
|
691
691
|
LinuxStat::ProcessInfo.cmdline(pid)
|
692
|
-
=> "/usr/bin/ruby /home/sourav/.gem/ruby/2.7.0/bin/linuxstat.rb
|
692
|
+
=> "/usr/bin/ruby /home/sourav/.gem/ruby/2.7.0/bin/linuxstat.rb --markdown"
|
693
693
|
|
694
694
|
# File: process_info.rb | Line: 87
|
695
695
|
# Definition: def command_name(pid = $$)
|
696
696
|
LinuxStat::ProcessInfo.command_name(pid)
|
697
697
|
=> "ruby"
|
698
698
|
|
699
|
-
# File: process_info.rb | Line:
|
699
|
+
# File: process_info.rb | Line: 608
|
700
700
|
# Definition: def nproc(pid = $$)
|
701
701
|
LinuxStat::ProcessInfo.count_cpu(pid)
|
702
702
|
=> 4
|
@@ -706,52 +706,52 @@ LinuxStat::ProcessInfo.count_cpu(pid)
|
|
706
706
|
LinuxStat::ProcessInfo.cpu_stat(pid:, sleep:)
|
707
707
|
=> {:cpu_usage=>0.0, :threads=>0, :last_executed_cpu=>0}
|
708
708
|
|
709
|
-
# File: process_info.rb | Line:
|
709
|
+
# File: process_info.rb | Line: 619
|
710
710
|
# Definition: def cpu_time(pid = $$)
|
711
711
|
LinuxStat::ProcessInfo.cpu_time(pid)
|
712
|
-
=> 0
|
712
|
+
=> 0.4399999976158142
|
713
713
|
|
714
|
-
# File: process_info.rb | Line:
|
714
|
+
# File: process_info.rb | Line: 634
|
715
715
|
# Definition: def cpu_times(pid = $$)
|
716
716
|
LinuxStat::ProcessInfo.cpu_times(pid)
|
717
|
-
=> {:hour=>0, :minute=>0, :second=>0}
|
717
|
+
=> {:hour=>0, :minute=>0, :second=>0, :jiffy=>439}
|
718
718
|
|
719
719
|
# File: process_info.rb | Line: 340
|
720
720
|
# Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
|
721
721
|
LinuxStat::ProcessInfo.cpu_usage(pid:, sleep:)
|
722
722
|
=> 0.0
|
723
723
|
|
724
|
-
# File: process_info.rb | Line:
|
724
|
+
# File: process_info.rb | Line: 450
|
725
725
|
# Definition: def gid(pid = $$)
|
726
726
|
LinuxStat::ProcessInfo.gid(pid)
|
727
727
|
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
728
728
|
|
729
|
-
# File: process_info.rb | Line:
|
729
|
+
# File: process_info.rb | Line: 416
|
730
730
|
# Definition: def last_executed_cpu(pid = $$)
|
731
731
|
LinuxStat::ProcessInfo.last_executed_cpu(pid)
|
732
|
-
=>
|
732
|
+
=> 3
|
733
733
|
|
734
734
|
# File: process_info.rb | Line: 151
|
735
735
|
# Definition: def mem_stat(pid = $$)
|
736
736
|
LinuxStat::ProcessInfo.mem_stat(pid)
|
737
|
-
=> {:memory=>
|
737
|
+
=> {:memory=>24735744, :virtual_memory=>96317440, :resident_memory=>30707712, :shared_memory=>5971968}
|
738
738
|
|
739
739
|
# File: process_info.rb | Line: 171
|
740
740
|
# Definition: def memory(pid = $$)
|
741
741
|
LinuxStat::ProcessInfo.memory(pid)
|
742
|
-
=>
|
742
|
+
=> 24735.744
|
743
743
|
|
744
|
-
# File: process_info.rb | Line:
|
744
|
+
# File: process_info.rb | Line: 578
|
745
745
|
# Definition: def nice(pid = $$)
|
746
746
|
LinuxStat::ProcessInfo.nice(pid)
|
747
747
|
=> 0
|
748
748
|
|
749
|
-
# File: process_info.rb | Line:
|
749
|
+
# File: process_info.rb | Line: 608
|
750
750
|
# Definition: def nproc(pid = $$)
|
751
751
|
LinuxStat::ProcessInfo.nproc(pid)
|
752
752
|
=> 4
|
753
753
|
|
754
|
-
# File: process_info.rb | Line:
|
754
|
+
# File: process_info.rb | Line: 471
|
755
755
|
# Definition: def owner(pid = $$)
|
756
756
|
LinuxStat::ProcessInfo.owner(pid)
|
757
757
|
=> "sourav"
|
@@ -764,39 +764,39 @@ LinuxStat::ProcessInfo.process_name(pid)
|
|
764
764
|
# File: process_info.rb | Line: 213
|
765
765
|
# Definition: def resident_memory(pid = $$)
|
766
766
|
LinuxStat::ProcessInfo.resident_memory(pid)
|
767
|
-
=>
|
767
|
+
=> 30707.712
|
768
768
|
|
769
|
-
# File: process_info.rb | Line:
|
769
|
+
# File: process_info.rb | Line: 540
|
770
770
|
# Definition: def running_time(pid = $$)
|
771
771
|
LinuxStat::ProcessInfo.running_time(pid)
|
772
|
-
=> 1.
|
772
|
+
=> 1.03
|
773
773
|
|
774
774
|
# File: process_info.rb | Line: 234
|
775
775
|
# Definition: def shared_memory(pid = $$)
|
776
776
|
LinuxStat::ProcessInfo.shared_memory(pid)
|
777
|
-
=>
|
777
|
+
=> 5971.968
|
778
778
|
|
779
|
-
# File: process_info.rb | Line:
|
779
|
+
# File: process_info.rb | Line: 521
|
780
780
|
# Definition: def start_time(pid = $$)
|
781
781
|
LinuxStat::ProcessInfo.start_time(pid)
|
782
|
-
=> 2021-02-
|
782
|
+
=> 2021-02-07 03:30:35 +0530
|
783
783
|
|
784
|
-
# File: process_info.rb | Line:
|
784
|
+
# File: process_info.rb | Line: 493
|
785
785
|
# Definition: def start_time_epoch(pid = $$)
|
786
786
|
LinuxStat::ProcessInfo.start_time_epoch(pid)
|
787
|
-
=>
|
787
|
+
=> 1612648835
|
788
788
|
|
789
|
-
# File: process_info.rb | Line:
|
789
|
+
# File: process_info.rb | Line: 565
|
790
790
|
# Definition: def state(pid = $$)
|
791
791
|
LinuxStat::ProcessInfo.state(pid)
|
792
792
|
=> "R"
|
793
793
|
|
794
|
-
# File: process_info.rb | Line:
|
794
|
+
# File: process_info.rb | Line: 370
|
795
795
|
# Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
|
796
796
|
LinuxStat::ProcessInfo.thread_usage(pid:, sleep:)
|
797
797
|
=> 0.0
|
798
798
|
|
799
|
-
# File: process_info.rb | Line:
|
799
|
+
# File: process_info.rb | Line: 395
|
800
800
|
# Definition: def threads(pid = $$)
|
801
801
|
LinuxStat::ProcessInfo.threads(pid)
|
802
802
|
=> 1
|
@@ -804,9 +804,9 @@ LinuxStat::ProcessInfo.threads(pid)
|
|
804
804
|
# File: process_info.rb | Line: 30
|
805
805
|
# Definition: def total_io(pid = $$)
|
806
806
|
LinuxStat::ProcessInfo.total_io(pid)
|
807
|
-
=> {:read_bytes=>
|
807
|
+
=> {:read_bytes=>1286144, :write_bytes=>0}
|
808
808
|
|
809
|
-
# File: process_info.rb | Line:
|
809
|
+
# File: process_info.rb | Line: 426
|
810
810
|
# Definition: def uid(pid = $$)
|
811
811
|
LinuxStat::ProcessInfo.uid(pid)
|
812
812
|
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
@@ -814,7 +814,7 @@ LinuxStat::ProcessInfo.uid(pid)
|
|
814
814
|
# File: process_info.rb | Line: 192
|
815
815
|
# Definition: def virtual_memory(pid = $$)
|
816
816
|
LinuxStat::ProcessInfo.virtual_memory(pid)
|
817
|
-
=>
|
817
|
+
=> 96317.44
|
818
818
|
|
819
819
|
```
|
820
820
|
|
@@ -828,32 +828,32 @@ LinuxStat::Swap.any?()
|
|
828
828
|
# File: swap.rb | Line: 84
|
829
829
|
# Definition: def available
|
830
830
|
LinuxStat::Swap.available()
|
831
|
-
=>
|
831
|
+
=> 2328956
|
832
832
|
|
833
833
|
# File: swap.rb | Line: 73
|
834
834
|
# Definition: def free
|
835
835
|
LinuxStat::Swap.free()
|
836
|
-
=>
|
836
|
+
=> 2328956
|
837
837
|
|
838
838
|
# File: swap.rb | Line: 10
|
839
839
|
# Definition: def list
|
840
840
|
LinuxStat::Swap.list()
|
841
|
-
=> {"/dev/zram0"=>[:partition, 4194300,
|
841
|
+
=> {"/dev/zram0"=>[:partition, 4194300, 1865344, -2]}
|
842
842
|
|
843
843
|
# File: swap.rb | Line: 127
|
844
844
|
# Definition: def percent_available
|
845
845
|
LinuxStat::Swap.percent_available()
|
846
|
-
=>
|
846
|
+
=> 55.53
|
847
847
|
|
848
848
|
# File: swap.rb | Line: 107
|
849
849
|
# Definition: def percent_used
|
850
850
|
LinuxStat::Swap.percent_used()
|
851
|
-
=>
|
851
|
+
=> 44.47
|
852
852
|
|
853
853
|
# File: swap.rb | Line: 34
|
854
854
|
# Definition: def stat
|
855
855
|
LinuxStat::Swap.stat()
|
856
|
-
=> {:total=>4194300, :used=>
|
856
|
+
=> {:total=>4194300, :used=>1865344, :available=>2328956, :percent_used=>44.47, :percent_available=>55.53}
|
857
857
|
|
858
858
|
# File: swap.rb | Line: 62
|
859
859
|
# Definition: def total
|
@@ -863,7 +863,7 @@ LinuxStat::Swap.total()
|
|
863
863
|
# File: swap.rb | Line: 98
|
864
864
|
# Definition: def used
|
865
865
|
LinuxStat::Swap.used()
|
866
|
-
=>
|
866
|
+
=> 1865344
|
867
867
|
|
868
868
|
```
|
869
869
|
|
@@ -937,31 +937,31 @@ LinuxStat::Sysinfo.freehigh()
|
|
937
937
|
=> 0
|
938
938
|
|
939
939
|
LinuxStat::Sysinfo.freeram()
|
940
|
-
=>
|
940
|
+
=> 258519040
|
941
941
|
|
942
942
|
LinuxStat::Sysinfo.freeswap()
|
943
|
-
=>
|
943
|
+
=> 2384850944
|
944
944
|
|
945
945
|
LinuxStat::Sysinfo.loads()
|
946
|
-
=> [
|
946
|
+
=> [2.873046875, 1.9189453125, 1.396484375]
|
947
947
|
|
948
948
|
LinuxStat::Sysinfo.sharedram()
|
949
|
-
=>
|
949
|
+
=> 644231168
|
950
950
|
|
951
951
|
LinuxStat::Sysinfo.stat()
|
952
|
-
=> {:totalram=>
|
952
|
+
=> {:totalram=>3928297472, :freeram=>258519040, :sharedram=>644231168, :bufferram=>4096, :totalswap=>4294963200, :freeswap=>2384850944, :totalhigh=>0, :freehigh=>0, :uptime=>58562, :loads=>[2.873046875, 1.9189453125, 1.396484375]}
|
953
953
|
|
954
954
|
LinuxStat::Sysinfo.totalhigh()
|
955
955
|
=> 0
|
956
956
|
|
957
957
|
LinuxStat::Sysinfo.totalram()
|
958
|
-
=>
|
958
|
+
=> 3928297472
|
959
959
|
|
960
960
|
LinuxStat::Sysinfo.totalswap()
|
961
961
|
=> 4294963200
|
962
962
|
|
963
963
|
LinuxStat::Sysinfo.uptime()
|
964
|
-
=>
|
964
|
+
=> 58562
|
965
965
|
|
966
966
|
```
|
967
967
|
|
@@ -980,12 +980,12 @@ LinuxStat::Thermal.count_sensors()
|
|
980
980
|
# File: thermal.rb | Line: 41
|
981
981
|
# Definition: def fans
|
982
982
|
LinuxStat::Thermal.fans()
|
983
|
-
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Processor Fan", :rpm=>
|
983
|
+
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Processor Fan", :rpm=>2795}]
|
984
984
|
|
985
985
|
# File: thermal.rb | Line: 23
|
986
986
|
# Definition: def temperatures
|
987
987
|
LinuxStat::Thermal.temperatures()
|
988
|
-
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"SODIMM", :temperature=>
|
988
|
+
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"SODIMM", :temperature=>33.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"CPU", :temperature=>41.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Ambi...
|
989
989
|
|
990
990
|
```
|
991
991
|
|
@@ -1004,7 +1004,7 @@ LinuxStat::USB.count_devices()
|
|
1004
1004
|
# File: usb.rb | Line: 49
|
1005
1005
|
# Definition: def devices_stat(hwdata: true)
|
1006
1006
|
LinuxStat::USB.devices_stat(hwdata:)
|
1007
|
-
=> [{:path=>"/sys/bus/usb/devices/1-1.2/", :id=>"04d9:1203", :vendor_id=>"04d9", :product_id=>"1203", :bus_num=>1, :dev_num=>
|
1007
|
+
=> [{:path=>"/sys/bus/usb/devices/1-1.2/", :id=>"04d9:1203", :vendor_id=>"04d9", :product_id=>"1203", :bus_num=>1, :dev_num=>12, :hwdata=>{:vendor=>"Holtek Semiconductor, Inc.", :product=>"Keyboard"}, :authorized=>true, :b_max_power=>"100mA", :b_max_pack...
|
1008
1008
|
|
1009
1009
|
# File: usb.rb | Line: 179
|
1010
1010
|
# Definition: def hwdata_file
|
data/ext/procfs/procfs.c
CHANGED
data/ext/procfs/stat.h
CHANGED
@@ -17,6 +17,27 @@ VALUE ps_state(VALUE obj, VALUE pid) {
|
|
17
17
|
return rb_str_new_cstr(_s) ;
|
18
18
|
}
|
19
19
|
|
20
|
+
VALUE ps_times(VALUE obj, VALUE pid) {
|
21
|
+
int _pid = FIX2INT(pid) ;
|
22
|
+
if (_pid < 0) return Qnil ;
|
23
|
+
|
24
|
+
char _path[22] ;
|
25
|
+
sprintf(_path, "/proc/%d/stat", _pid) ;
|
26
|
+
|
27
|
+
FILE *f = fopen(_path, "r") ;
|
28
|
+
if (!f) return Qnil ;
|
29
|
+
|
30
|
+
unsigned long utime, stime ;
|
31
|
+
|
32
|
+
char status = fscanf(f, "%*llu (%*[^)]%*[)] %*c %*d %*d %*d %*d %*d %*u %*lu %*lu %*lu %*lu %lu %lu", &utime, &stime) ;
|
33
|
+
fclose(f) ;
|
34
|
+
|
35
|
+
if (status != 2) return Qnil ;
|
36
|
+
double total_time = (utime + stime) / (float)sysconf(_SC_CLK_TCK);
|
37
|
+
|
38
|
+
return DBL2NUM(total_time) ;
|
39
|
+
}
|
40
|
+
|
20
41
|
VALUE ps_stat(VALUE obj, VALUE pid) {
|
21
42
|
int _pid = FIX2INT(pid) ;
|
22
43
|
if (_pid < 0) return rb_str_new_cstr("") ;
|
data/lib/linux_stat/os.rb
CHANGED
@@ -7,7 +7,11 @@ module LinuxStat
|
|
7
7
|
# Reads /etc/os-release and returns a Hash. For example:
|
8
8
|
# LinuxStat::OS.os_release
|
9
9
|
#
|
10
|
-
# => {:NAME=>"Arch Linux", :PRETTY_NAME=>"Arch Linux", :ID=>"arch", :BUILD_ID=>"rolling",
|
10
|
+
# => {:NAME=>"Arch Linux", :PRETTY_NAME=>"Arch Linux", :ID=>"arch", :BUILD_ID=>"rolling",
|
11
|
+
# :ANSI_COLOR=>"38;2;23;147;209", :HOME_URL=>"https://www.archlinux.org/",
|
12
|
+
# :DOCUMENTATION_URL=>"https://wiki.archlinux.org/",
|
13
|
+
# :SUPPORT_URL=>"https://bbs.archlinux.org/", :BUG_REPORT_URL=>"https://bugs.archlinux.org/",
|
14
|
+
# :LOGO=>"archlinux"}
|
11
15
|
#
|
12
16
|
# If the info isn't available, it will return an empty Hash.
|
13
17
|
#
|
@@ -127,7 +131,7 @@ module LinuxStat
|
|
127
131
|
#
|
128
132
|
# The return type is strictly Integer and doesn't fail.
|
129
133
|
def bits
|
130
|
-
@@bits ||= if
|
134
|
+
@@bits ||= if machine.end_with?('64') || RbConfig::CONFIG['host_cpu'].end_with?('64') || RUBY_PLATFORM.end_with?('64')
|
131
135
|
64
|
132
136
|
else
|
133
137
|
32
|
@@ -138,7 +142,7 @@ module LinuxStat
|
|
138
142
|
# Reads /proc/uptime and returns the system uptime:
|
139
143
|
# LinuxStat::OS.uptime
|
140
144
|
#
|
141
|
-
# => {:hour=>
|
145
|
+
# => {:hour=>16, :minute=>10, :second=>11, :jiffy=>20}
|
142
146
|
#
|
143
147
|
# Using uptime is 10x slower than using uptime_i
|
144
148
|
#
|
@@ -151,12 +155,14 @@ module LinuxStat
|
|
151
155
|
|
152
156
|
h = uptime_i / 3600
|
153
157
|
m = uptime_i % 3600 / 60
|
154
|
-
s =
|
158
|
+
s = uptime_i.%(60)
|
159
|
+
j = _uptime.-(uptime_i) * 100
|
155
160
|
|
156
161
|
{
|
157
162
|
hour: h,
|
158
163
|
minute: m,
|
159
|
-
second: s
|
164
|
+
second: s,
|
165
|
+
jiffy: j.to_i
|
160
166
|
}
|
161
167
|
end
|
162
168
|
|
@@ -614,13 +614,10 @@ module LinuxStat
|
|
614
614
|
#
|
615
615
|
# Shows the CPU time used by the process.
|
616
616
|
#
|
617
|
-
# The return value is
|
617
|
+
# The return value is a Float.
|
618
|
+
# But if the info isn't available, it will return nil.
|
618
619
|
def cpu_time(pid = $$)
|
619
|
-
|
620
|
-
utime, stime, cutime, cstime = times[10], times[11], times[12], times[13]
|
621
|
-
return nil unless utime && stime && cutime && cstime
|
622
|
-
|
623
|
-
utime.+(stime).+(cutime).+(cstime) / get_ticks
|
620
|
+
LinuxStat::ProcFS.ps_times(pid)
|
624
621
|
end
|
625
622
|
|
626
623
|
##
|
@@ -628,19 +625,28 @@ module LinuxStat
|
|
628
625
|
#
|
629
626
|
# Shows the CPU time used by the process.
|
630
627
|
#
|
631
|
-
# The return value is a Hash
|
628
|
+
# The return value is a Hash formatted like this:
|
629
|
+
# LS::ProcessInfo.cpu_times($$)
|
630
|
+
#
|
631
|
+
# => {:hour=>0, :minute=>39, :second=>12, :jiffy=>0.42}
|
632
|
+
#
|
633
|
+
# But if the info isn't available, it will return an empty Hash..
|
632
634
|
def cpu_times(pid = $$)
|
633
|
-
v =
|
635
|
+
v = LinuxStat::ProcFS.ps_times(pid)
|
634
636
|
return {} unless v
|
635
637
|
|
636
|
-
|
637
|
-
|
638
|
-
|
638
|
+
v_i = v.to_i
|
639
|
+
|
640
|
+
hour = v_i / 3600
|
641
|
+
min = v_i % 3600 / 60
|
642
|
+
sec = v_i % 60
|
643
|
+
jiffy = v.-(v_i) * 100
|
639
644
|
|
640
645
|
{
|
641
646
|
hour: hour,
|
642
647
|
minute: min,
|
643
|
-
second: sec
|
648
|
+
second: sec,
|
649
|
+
jiffy: jiffy.to_i
|
644
650
|
}
|
645
651
|
end
|
646
652
|
|
data/lib/linux_stat/version.rb
CHANGED