linux_stat 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +106 -87
- data/lib/linux_stat/process.rb +53 -11
- data/lib/linux_stat/process_info.rb +86 -25
- data/lib/linux_stat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 219b1bdf4ab0f8c62143e6b8c28059966baa28c33323bf65c718614446377513
|
4
|
+
data.tar.gz: 3f38dede32f96b80b74311468524e20e07a87184cbaf55ccbc8c899a86a20eb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0a08fd12c22370baf0080845e64ec8d0ea027d575b238ee02bb1b9dc5e193d12f5c9f3d705490a2ef9824e839dffa549d6840c21b434d08bcae58f1e135768d
|
7
|
+
data.tar.gz: f47e5f32f8cac9d4aa5dbb5510f85d8acde8d81c849da28a097ab07cd551cefc2e8c567047a16a4741ab49301d9adf8e33557423b60675b6434514bde831e407
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ 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
|
-
<img src="https://linuxstatloc.herokuapp.com/
|
15
|
+
<img src="https://linuxstatloc.herokuapp.com/svg" width="260px">
|
16
16
|
|
17
17
|
---
|
18
18
|
|
@@ -73,11 +73,15 @@ gem 'linux_stat'
|
|
73
73
|
|
74
74
|
And then execute:
|
75
75
|
|
76
|
-
|
76
|
+
```
|
77
|
+
$ bundle install
|
78
|
+
```
|
77
79
|
|
78
80
|
Or install it yourself as:
|
79
81
|
|
80
|
-
|
82
|
+
```
|
83
|
+
$ gem install linux_stat
|
84
|
+
```
|
81
85
|
|
82
86
|
## Usage
|
83
87
|
Following are the LinuxStat modules and module functions.
|
@@ -85,6 +89,7 @@ It's generated by linuxstat.rb command, which is available after the installatio
|
|
85
89
|
|
86
90
|
For ease of use, LinuxStat is also assigned to the LS constant.
|
87
91
|
|
92
|
+
### LinuxStat::BIOS
|
88
93
|
### LinuxStat::BIOS
|
89
94
|
```
|
90
95
|
# File: bios.rb | Line: 58
|
@@ -179,7 +184,7 @@ LinuxStat::Battery.technology()
|
|
179
184
|
# File: battery.rb | Line: 162
|
180
185
|
# Definition: def voltage_now
|
181
186
|
LinuxStat::Battery.voltage_now()
|
182
|
-
=> 12.
|
187
|
+
=> 12.537
|
183
188
|
|
184
189
|
```
|
185
190
|
|
@@ -203,7 +208,7 @@ LinuxStat::CPU.count_online()
|
|
203
208
|
# File: cpu.rb | Line: 199
|
204
209
|
# Definition: def cur_freq
|
205
210
|
LinuxStat::CPU.cur_freq()
|
206
|
-
=> {"cpu0"=>
|
211
|
+
=> {"cpu0"=>1999901, "cpu1"=>1999408, "cpu2"=>2000039, "cpu3"=>2000019}
|
207
212
|
|
208
213
|
# File: cpu.rb | Line: 267
|
209
214
|
# Definition: def governor
|
@@ -238,29 +243,29 @@ LinuxStat::CPU.online()
|
|
238
243
|
# File: cpu.rb | Line: 25
|
239
244
|
# Definition: def stat(sleep = ticks_to_ms_t5)
|
240
245
|
LinuxStat::CPU.stat(sleep)
|
241
|
-
=> {0=>
|
246
|
+
=> {0=>27.78, 1=>20.0, 2=>25.0, 3=>25.0, 4=>40.0}
|
242
247
|
|
243
248
|
# File: cpu.rb | Line: 65
|
244
249
|
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
245
250
|
LinuxStat::CPU.total_usage(sleep)
|
246
|
-
=>
|
251
|
+
=> 25.0
|
247
252
|
|
248
253
|
# File: cpu.rb | Line: 65
|
249
254
|
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
250
255
|
LinuxStat::CPU.usage(sleep)
|
251
|
-
=>
|
256
|
+
=> 25.0
|
252
257
|
|
253
258
|
# File: cpu.rb | Line: 25
|
254
259
|
# Definition: def stat(sleep = ticks_to_ms_t5)
|
255
260
|
LinuxStat::CPU.usages(sleep)
|
256
|
-
=> {0=>
|
261
|
+
=> {0=>25.0, 1=>20.0, 2=>33.33, 3=>20.0, 4=>0.0}
|
257
262
|
|
258
263
|
```
|
259
264
|
|
260
265
|
### LinuxStat::FS
|
261
266
|
```
|
262
267
|
LinuxStat::FS.stat(arg = "/")
|
263
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>
|
268
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>7268389, :block_avail_unpriv=>7268389, :inodes=>58612160, :free_inodes=>56907397, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
264
269
|
|
265
270
|
```
|
266
271
|
|
@@ -269,22 +274,22 @@ LinuxStat::FS.stat(arg = "/")
|
|
269
274
|
# File: filesystem.rb | Line: 94
|
270
275
|
# Definition: def available(fs = ?..freeze)
|
271
276
|
LinuxStat::Filesystem.available(fs)
|
272
|
-
=>
|
277
|
+
=> 29771321344
|
273
278
|
|
274
279
|
# File: filesystem.rb | Line: 60
|
275
280
|
# Definition: def free(fs = ?..freeze)
|
276
281
|
LinuxStat::Filesystem.free(fs)
|
277
|
-
=>
|
282
|
+
=> 29771321344
|
278
283
|
|
279
284
|
# File: filesystem.rb | Line: 21
|
280
285
|
# Definition: def stat(fs = ?..freeze)
|
281
286
|
LinuxStat::Filesystem.stat(fs)
|
282
|
-
=> {:total=>119981191168, :free=>
|
287
|
+
=> {:total=>119981191168, :free=>29771321344, :used=>90209869824}
|
283
288
|
|
284
289
|
# File: filesystem.rb | Line: 110
|
285
290
|
# Definition: def stat_raw(fs = ?..freeze)
|
286
291
|
LinuxStat::Filesystem.stat_raw(fs)
|
287
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>
|
292
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>7268389, :block_avail_unpriv=>7268389, :inodes=>58612160, :free_inodes=>56907397, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
288
293
|
|
289
294
|
# File: filesystem.rb | Line: 41
|
290
295
|
# Definition: def total(fs = ?..freeze)
|
@@ -294,7 +299,7 @@ LinuxStat::Filesystem.total(fs)
|
|
294
299
|
# File: filesystem.rb | Line: 75
|
295
300
|
# Definition: def used(fs = ?..freeze)
|
296
301
|
LinuxStat::Filesystem.used(fs)
|
297
|
-
=>
|
302
|
+
=> 90209869824
|
298
303
|
|
299
304
|
```
|
300
305
|
|
@@ -357,32 +362,32 @@ LinuxStat::Kernel.version()
|
|
357
362
|
# File: memory.rb | Line: 52
|
358
363
|
# Definition: def available
|
359
364
|
LinuxStat::Memory.available()
|
360
|
-
=>
|
365
|
+
=> 337416
|
361
366
|
|
362
367
|
# File: memory.rb | Line: 83
|
363
368
|
# Definition: def percent_available
|
364
369
|
LinuxStat::Memory.percent_available()
|
365
|
-
=>
|
370
|
+
=> 8.8
|
366
371
|
|
367
372
|
# File: memory.rb | Line: 72
|
368
373
|
# Definition: def percent_used
|
369
374
|
LinuxStat::Memory.percent_used()
|
370
|
-
=>
|
375
|
+
=> 91.2
|
371
376
|
|
372
377
|
# File: memory.rb | Line: 13
|
373
378
|
# Definition: def stat
|
374
379
|
LinuxStat::Memory.stat()
|
375
|
-
=> {:total=>
|
380
|
+
=> {:total=>3836228, :used=>3498812, :available=>337416, :percent_used=>91.2, :percent_available=>8.8}
|
376
381
|
|
377
382
|
# File: memory.rb | Line: 42
|
378
383
|
# Definition: def total
|
379
384
|
LinuxStat::Memory.total()
|
380
|
-
=>
|
385
|
+
=> 3836228
|
381
386
|
|
382
387
|
# File: memory.rb | Line: 62
|
383
388
|
# Definition: def used
|
384
389
|
LinuxStat::Memory.used()
|
385
|
-
=>
|
390
|
+
=> 3498812
|
386
391
|
|
387
392
|
```
|
388
393
|
|
@@ -391,7 +396,7 @@ LinuxStat::Memory.used()
|
|
391
396
|
# File: mounts.rb | Line: 181
|
392
397
|
# Definition: def device_stat(dev = root)
|
393
398
|
LinuxStat::Mounts.device_stat(dev)
|
394
|
-
=> {:mountpoint=>"/", :total=>119981191168, :free=>
|
399
|
+
=> {:mountpoint=>"/", :total=>119981191168, :free=>29771321344, :available=>29771321344, :used=>90209869824, :percent_used=>75.19, :percent_free=>24.81, :percent_available=>24.81}
|
395
400
|
|
396
401
|
# File: mounts.rb | Line: 139
|
397
402
|
# Definition: def devices_stat
|
@@ -401,7 +406,7 @@ LinuxStat::Mounts.devices_stat()
|
|
401
406
|
# File: mounts.rb | Line: 13
|
402
407
|
# Definition: def list
|
403
408
|
LinuxStat::Mounts.list()
|
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=
|
409
|
+
=> ["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", "...
|
405
410
|
|
406
411
|
# File: mounts.rb | Line: 22
|
407
412
|
# Definition: def list_devices
|
@@ -411,7 +416,7 @@ LinuxStat::Mounts.list_devices()
|
|
411
416
|
# File: mounts.rb | Line: 111
|
412
417
|
# Definition: def list_devices_mount_point
|
413
418
|
LinuxStat::Mounts.list_devices_mount_point()
|
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/
|
419
|
+
=> {"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"=>"...
|
415
420
|
|
416
421
|
# File: mounts.rb | Line: 82
|
417
422
|
# Definition: def mount_point(dev = root)
|
@@ -436,7 +441,7 @@ LinuxStat::Mounts.root_mount_options()
|
|
436
441
|
# File: mounts.rb | Line: 58
|
437
442
|
# Definition: def tmpfs
|
438
443
|
LinuxStat::Mounts.tmpfs()
|
439
|
-
=> {"/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", "/
|
444
|
+
=> {"/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...
|
440
445
|
|
441
446
|
```
|
442
447
|
|
@@ -450,22 +455,22 @@ LinuxStat::Net.current_usage(interval)
|
|
450
455
|
# File: net.rb | Line: 12
|
451
456
|
# Definition: def ipv4_private
|
452
457
|
LinuxStat::Net.ipv4_private()
|
453
|
-
=> "192.168.
|
458
|
+
=> "192.168.43.107"
|
454
459
|
|
455
460
|
# File: net.rb | Line: 27
|
456
461
|
# Definition: def total_bytes
|
457
462
|
LinuxStat::Net.total_bytes()
|
458
|
-
=> {:received=>
|
463
|
+
=> {:received=>936112008, :transmitted=>141554101}
|
459
464
|
|
460
465
|
# File: net.rb | Line: 45
|
461
466
|
# Definition: def total_bytes_received
|
462
467
|
LinuxStat::Net.total_bytes_received()
|
463
|
-
=>
|
468
|
+
=> 936112008
|
464
469
|
|
465
470
|
# File: net.rb | Line: 58
|
466
471
|
# Definition: def total_bytes_transmitted
|
467
472
|
LinuxStat::Net.total_bytes_transmitted()
|
468
|
-
=>
|
473
|
+
=> 141554101
|
469
474
|
|
470
475
|
# File: net.rb | Line: 86
|
471
476
|
# Definition: def usage(interval = 0.1)
|
@@ -519,7 +524,7 @@ LinuxStat::OS.os_release()
|
|
519
524
|
# File: os.rb | Line: 144
|
520
525
|
# Definition: def uptime
|
521
526
|
LinuxStat::OS.uptime()
|
522
|
-
=> {:hour=>
|
527
|
+
=> {:hour=>14, :minute=>8, :second=>42.08}
|
523
528
|
|
524
529
|
# File: os.rb | Line: 84
|
525
530
|
# Definition: def version
|
@@ -571,64 +576,74 @@ LinuxStat::PCI.initialize_hwdata()
|
|
571
576
|
```
|
572
577
|
# File: prettify_bytes.rb | Line: 49
|
573
578
|
# Definition: def convert_binary(n, precision: 2)
|
574
|
-
LinuxStat::PrettifyBytes.convert_binary(n =
|
575
|
-
=> "
|
579
|
+
LinuxStat::PrettifyBytes.convert_binary(n = 327222499582327, precision:)
|
580
|
+
=> "297.61 tebibytes"
|
576
581
|
|
577
582
|
# File: prettify_bytes.rb | Line: 26
|
578
583
|
# Definition: def convert_decimal(n, precision: 2)
|
579
|
-
LinuxStat::PrettifyBytes.convert_decimal(n =
|
580
|
-
=> "
|
584
|
+
LinuxStat::PrettifyBytes.convert_decimal(n = 812496332434396, precision:)
|
585
|
+
=> "812.50 terabytes"
|
581
586
|
|
582
587
|
# File: prettify_bytes.rb | Line: 97
|
583
588
|
# Definition: def convert_short_binary(n, precision: 2)
|
584
|
-
LinuxStat::PrettifyBytes.convert_short_binary(n =
|
585
|
-
=> "
|
589
|
+
LinuxStat::PrettifyBytes.convert_short_binary(n = 447429857254915, precision:)
|
590
|
+
=> "406.94 TiB"
|
586
591
|
|
587
592
|
# File: prettify_bytes.rb | Line: 72
|
588
593
|
# Definition: def convert_short_decimal(n, precision: 2)
|
589
|
-
LinuxStat::PrettifyBytes.convert_short_decimal(n =
|
590
|
-
=> "
|
594
|
+
LinuxStat::PrettifyBytes.convert_short_decimal(n = 157028156498063, precision:)
|
595
|
+
=> "157.03 TB"
|
591
596
|
|
592
597
|
```
|
593
598
|
|
594
599
|
### LinuxStat::Process
|
595
600
|
```
|
601
|
+
# File: process.rb | Line: 57
|
602
|
+
# Definition: def cmdlines
|
603
|
+
LinuxStat::Process.cmdlines()
|
604
|
+
=> {1=>"/sbin/init", 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=>""...
|
605
|
+
|
596
606
|
# File: process.rb | Line: 29
|
597
607
|
# Definition: def count
|
598
608
|
LinuxStat::Process.count()
|
599
|
-
=>
|
609
|
+
=> 209
|
600
610
|
|
601
|
-
# File: process.rb | Line:
|
611
|
+
# File: process.rb | Line: 124
|
602
612
|
# Definition: def idle
|
603
613
|
LinuxStat::Process.idle()
|
604
|
-
=> [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, 166, 168,
|
614
|
+
=> [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, 164, 166, 168, 169, 172, 174, 179, 180, 181, 182, 183, 184, 185, 186, 230, 234, 283, 418, 426, 428, 5731, 5732, 5733, 5734, 5735, 5736, 517...
|
605
615
|
|
606
616
|
# File: process.rb | Line: 11
|
607
617
|
# Definition: def list
|
608
618
|
LinuxStat::Process.list()
|
609
|
-
=> [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,
|
619
|
+
=> [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,...
|
610
620
|
|
611
|
-
# File: process.rb | Line:
|
621
|
+
# File: process.rb | Line: 36
|
612
622
|
# Definition: def names
|
613
623
|
LinuxStat::Process.names()
|
614
624
|
=> {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...
|
615
625
|
|
616
|
-
# File: process.rb | Line:
|
626
|
+
# File: process.rb | Line: 150
|
617
627
|
# Definition: def running
|
618
628
|
LinuxStat::Process.running()
|
619
|
-
=> [
|
629
|
+
=> [474, 628, 643, 55770]
|
620
630
|
|
621
|
-
# File: process.rb | Line:
|
631
|
+
# File: process.rb | Line: 111
|
622
632
|
# Definition: def sleeping
|
623
633
|
LinuxStat::Process.sleeping()
|
624
|
-
=> [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,
|
634
|
+
=> [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, 163, 165, 187, 216, 233, 235, 349, 350, 352, 353, 363, 425, 427, 451, 452, 453, 454, 468, 470, 474, 485,...
|
625
635
|
|
626
|
-
# File: process.rb | Line:
|
636
|
+
# File: process.rb | Line: 163
|
637
|
+
# Definition: def stopped
|
638
|
+
LinuxStat::Process.stopped()
|
639
|
+
=> []
|
640
|
+
|
641
|
+
# File: process.rb | Line: 78
|
627
642
|
# Definition: def types
|
628
643
|
LinuxStat::Process.types()
|
629
644
|
=> {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...
|
630
645
|
|
631
|
-
# File: process.rb | Line:
|
646
|
+
# File: process.rb | Line: 137
|
632
647
|
# Definition: def zombie
|
633
648
|
LinuxStat::Process.zombie()
|
634
649
|
=> []
|
@@ -642,92 +657,97 @@ LinuxStat::Process.zombie()
|
|
642
657
|
LinuxStat::ProcessInfo.cmdline(pid)
|
643
658
|
=> "/usr/bin/ruby /home/sourav/.gem/ruby/2.7.0/bin/linuxstat.rb -md"
|
644
659
|
|
645
|
-
# File: process_info.rb | Line:
|
660
|
+
# File: process_info.rb | Line: 87
|
646
661
|
# Definition: def command_name(pid = $$)
|
647
662
|
LinuxStat::ProcessInfo.command_name(pid)
|
648
663
|
=> "ruby"
|
649
664
|
|
650
|
-
# File: process_info.rb | Line:
|
665
|
+
# File: process_info.rb | Line: 708
|
651
666
|
# Definition: def nproc(pid = $$)
|
652
667
|
LinuxStat::ProcessInfo.count_cpu(pid)
|
653
668
|
=> 4
|
654
669
|
|
655
|
-
# File: process_info.rb | Line:
|
670
|
+
# File: process_info.rb | Line: 284
|
656
671
|
# Definition: def cpu_stat(pid: $$, sleep: ticks_to_ms_t5)
|
657
672
|
LinuxStat::ProcessInfo.cpu_stat(pid:, sleep:)
|
658
673
|
=> {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>2}
|
659
674
|
|
660
|
-
# File: process_info.rb | Line:
|
675
|
+
# File: process_info.rb | Line: 350
|
661
676
|
# Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
|
662
677
|
LinuxStat::ProcessInfo.cpu_usage(pid:, sleep:)
|
663
|
-
=>
|
678
|
+
=> 5.0
|
664
679
|
|
665
|
-
# File: process_info.rb | Line:
|
680
|
+
# File: process_info.rb | Line: 525
|
666
681
|
# Definition: def gid(pid = $$)
|
667
682
|
LinuxStat::ProcessInfo.gid(pid)
|
668
683
|
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
669
684
|
|
670
|
-
# File: process_info.rb | Line:
|
685
|
+
# File: process_info.rb | Line: 487
|
671
686
|
# Definition: def last_executed_cpu(pid = $$)
|
672
687
|
LinuxStat::ProcessInfo.last_executed_cpu(pid)
|
673
688
|
=> 2
|
674
689
|
|
675
|
-
# File: process_info.rb | Line:
|
690
|
+
# File: process_info.rb | Line: 151
|
676
691
|
# Definition: def mem_stat(pid = $$)
|
677
692
|
LinuxStat::ProcessInfo.mem_stat(pid)
|
678
|
-
=> {:memory=>
|
693
|
+
=> {:memory=>24842.24, :virtual_memory=>96309.248, :resident_memory=>30720.0}
|
679
694
|
|
680
|
-
# File: process_info.rb | Line:
|
695
|
+
# File: process_info.rb | Line: 184
|
681
696
|
# Definition: def memory(pid = $$)
|
682
697
|
LinuxStat::ProcessInfo.memory(pid)
|
683
|
-
=>
|
698
|
+
=> 24842.24
|
684
699
|
|
685
|
-
# File: process_info.rb | Line:
|
700
|
+
# File: process_info.rb | Line: 672
|
686
701
|
# Definition: def nice(pid = $$)
|
687
702
|
LinuxStat::ProcessInfo.nice(pid)
|
688
703
|
=> 0
|
689
704
|
|
690
|
-
# File: process_info.rb | Line:
|
705
|
+
# File: process_info.rb | Line: 708
|
691
706
|
# Definition: def nproc(pid = $$)
|
692
707
|
LinuxStat::ProcessInfo.nproc(pid)
|
693
708
|
=> 4
|
694
709
|
|
695
|
-
# File: process_info.rb | Line:
|
710
|
+
# File: process_info.rb | Line: 546
|
696
711
|
# Definition: def owner(pid = $$)
|
697
712
|
LinuxStat::ProcessInfo.owner(pid)
|
698
713
|
=> "sourav"
|
699
714
|
|
700
|
-
# File: process_info.rb | Line:
|
715
|
+
# File: process_info.rb | Line: 112
|
716
|
+
# Definition: def process_name(pid = $$)
|
717
|
+
LinuxStat::ProcessInfo.process_name(pid)
|
718
|
+
=> "linuxstat.rb"
|
719
|
+
|
720
|
+
# File: process_info.rb | Line: 234
|
701
721
|
# Definition: def resident_memory(pid = $$)
|
702
722
|
LinuxStat::ProcessInfo.resident_memory(pid)
|
703
|
-
=>
|
723
|
+
=> 30720.0
|
704
724
|
|
705
|
-
# File: process_info.rb | Line:
|
725
|
+
# File: process_info.rb | Line: 621
|
706
726
|
# Definition: def running_time(pid = $$)
|
707
727
|
LinuxStat::ProcessInfo.running_time(pid)
|
708
|
-
=> 1.
|
728
|
+
=> 1.19
|
709
729
|
|
710
|
-
# File: process_info.rb | Line:
|
730
|
+
# File: process_info.rb | Line: 602
|
711
731
|
# Definition: def start_time(pid = $$)
|
712
732
|
LinuxStat::ProcessInfo.start_time(pid)
|
713
|
-
=> 2021-01-
|
733
|
+
=> 2021-01-20 00:10:50 +0530
|
714
734
|
|
715
|
-
# File: process_info.rb | Line:
|
735
|
+
# File: process_info.rb | Line: 568
|
716
736
|
# Definition: def start_time_epoch(pid = $$)
|
717
737
|
LinuxStat::ProcessInfo.start_time_epoch(pid)
|
718
|
-
=>
|
738
|
+
=> 1611081650
|
719
739
|
|
720
|
-
# File: process_info.rb | Line:
|
740
|
+
# File: process_info.rb | Line: 653
|
721
741
|
# Definition: def state(pid = $$)
|
722
742
|
LinuxStat::ProcessInfo.state(pid)
|
723
743
|
=> "R"
|
724
744
|
|
725
|
-
# File: process_info.rb | Line:
|
745
|
+
# File: process_info.rb | Line: 407
|
726
746
|
# Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
|
727
747
|
LinuxStat::ProcessInfo.thread_usage(pid:, sleep:)
|
728
748
|
=> 0.0
|
729
749
|
|
730
|
-
# File: process_info.rb | Line:
|
750
|
+
# File: process_info.rb | Line: 462
|
731
751
|
# Definition: def threads(pid = $$)
|
732
752
|
LinuxStat::ProcessInfo.threads(pid)
|
733
753
|
=> 1
|
@@ -735,17 +755,17 @@ LinuxStat::ProcessInfo.threads(pid)
|
|
735
755
|
# File: process_info.rb | Line: 30
|
736
756
|
# Definition: def total_io(pid = $$)
|
737
757
|
LinuxStat::ProcessInfo.total_io(pid)
|
738
|
-
=> {:read_bytes=>
|
758
|
+
=> {:read_bytes=>1286144, :write_bytes=>0}
|
739
759
|
|
740
|
-
# File: process_info.rb | Line:
|
760
|
+
# File: process_info.rb | Line: 501
|
741
761
|
# Definition: def uid(pid = $$)
|
742
762
|
LinuxStat::ProcessInfo.uid(pid)
|
743
763
|
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
744
764
|
|
745
|
-
# File: process_info.rb | Line:
|
765
|
+
# File: process_info.rb | Line: 209
|
746
766
|
# Definition: def virtual_memory(pid = $$)
|
747
767
|
LinuxStat::ProcessInfo.virtual_memory(pid)
|
748
|
-
=>
|
768
|
+
=> 96309.248
|
749
769
|
|
750
770
|
```
|
751
771
|
|
@@ -759,27 +779,27 @@ LinuxStat::Swap.any?()
|
|
759
779
|
# File: swap.rb | Line: 70
|
760
780
|
# Definition: def available
|
761
781
|
LinuxStat::Swap.available()
|
762
|
-
=>
|
782
|
+
=> 3546108
|
763
783
|
|
764
784
|
# File: swap.rb | Line: 10
|
765
785
|
# Definition: def list
|
766
786
|
LinuxStat::Swap.list()
|
767
|
-
=> {"/dev/zram0"=>[:partition, 4194300,
|
787
|
+
=> {"/dev/zram0"=>[:partition, 4194300, 648192, -2]}
|
768
788
|
|
769
789
|
# File: swap.rb | Line: 105
|
770
790
|
# Definition: def percent_available
|
771
791
|
LinuxStat::Swap.percent_available()
|
772
|
-
=>
|
792
|
+
=> 84.55
|
773
793
|
|
774
794
|
# File: swap.rb | Line: 91
|
775
795
|
# Definition: def percent_used
|
776
796
|
LinuxStat::Swap.percent_used()
|
777
|
-
=>
|
797
|
+
=> 15.45
|
778
798
|
|
779
799
|
# File: swap.rb | Line: 34
|
780
800
|
# Definition: def stat
|
781
801
|
LinuxStat::Swap.stat()
|
782
|
-
=> {:total=>4194300, :used=>
|
802
|
+
=> {:total=>4194300, :used=>648192, :available=>3546108, :percent_used=>15.45, :percent_available=>84.55}
|
783
803
|
|
784
804
|
# File: swap.rb | Line: 59
|
785
805
|
# Definition: def total
|
@@ -789,7 +809,7 @@ LinuxStat::Swap.total()
|
|
789
809
|
# File: swap.rb | Line: 82
|
790
810
|
# Definition: def used
|
791
811
|
LinuxStat::Swap.used()
|
792
|
-
=>
|
812
|
+
=> 648192
|
793
813
|
|
794
814
|
```
|
795
815
|
|
@@ -869,12 +889,12 @@ LinuxStat::Thermal.count_sensors()
|
|
869
889
|
# File: thermal.rb | Line: 41
|
870
890
|
# Definition: def fans
|
871
891
|
LinuxStat::Thermal.fans()
|
872
|
-
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Processor Fan", :rpm=>
|
892
|
+
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Processor Fan", :rpm=>2718}]
|
873
893
|
|
874
894
|
# File: thermal.rb | Line: 23
|
875
895
|
# Definition: def temperatures
|
876
896
|
LinuxStat::Thermal.temperatures()
|
877
|
-
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"SODIMM", :temperature=>
|
897
|
+
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"SODIMM", :temperature=>33.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"CPU", :temperature=>42.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Ambi...
|
878
898
|
|
879
899
|
```
|
880
900
|
|
@@ -1025,7 +1045,6 @@ LinuxStat::User.usernames_by_uid(uid)
|
|
1025
1045
|
|
1026
1046
|
```
|
1027
1047
|
|
1028
|
-
|
1029
1048
|
---
|
1030
1049
|
|
1031
1050
|
## Note 1: CPU usage, and Net usage
|
data/lib/linux_stat/process.rb
CHANGED
@@ -31,7 +31,8 @@ module LinuxStat
|
|
31
31
|
end
|
32
32
|
|
33
33
|
##
|
34
|
-
# Returns all the id of processes mapped with their names as a Hash.
|
34
|
+
# Returns all the id of processes mapped with their executable names (comm) as a Hash.
|
35
|
+
# The names can be truncated to TASK_COMM_LEN or (16 - 1 = 15) places.
|
35
36
|
def names
|
36
37
|
h, i = {}, -1
|
37
38
|
|
@@ -42,7 +43,30 @@ module LinuxStat
|
|
42
43
|
x = l[i]
|
43
44
|
|
44
45
|
begin
|
45
|
-
h.merge!( x => IO.
|
46
|
+
h.merge!( x => IO.read("/proc/#{x}/comm").strip)
|
47
|
+
rescue StandardError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
h
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Returns all the id of processes mapped with their cmdline info as a Hash.
|
55
|
+
# The cmdlines aren't usually truncated like names, but they can contain
|
56
|
+
# arguments with the command.
|
57
|
+
def cmdlines
|
58
|
+
h, i = {}, -1
|
59
|
+
|
60
|
+
l = list
|
61
|
+
count = l.length
|
62
|
+
|
63
|
+
while(i += 1) < count
|
64
|
+
x = l[i]
|
65
|
+
|
66
|
+
begin
|
67
|
+
cmdlines = IO.read("/proc/#{x}/cmdline").strip
|
68
|
+
cmdlines.gsub!(?\u0000.freeze, ?\s.freeze)
|
69
|
+
h.merge!( x => cmdlines)
|
46
70
|
rescue StandardError
|
47
71
|
end
|
48
72
|
end
|
@@ -62,11 +86,15 @@ module LinuxStat
|
|
62
86
|
|
63
87
|
begin
|
64
88
|
h.merge!(x =>
|
65
|
-
case IO.
|
89
|
+
case IO.read("/proc/#{x}/stat").split(/(\(.*\))/)[-1][/\s.+?/].strip
|
66
90
|
when ?S.freeze then :sleeping
|
67
91
|
when ?I.freeze then :idle
|
68
92
|
when ?Z.freeze then :zombie
|
69
93
|
when ?R.freeze then :running
|
94
|
+
when ?T.freeze then :stopped
|
95
|
+
when ?X.freeze then :dead
|
96
|
+
when ?D.freeze then :sleeping
|
97
|
+
when ?t.freeze then :stopped
|
70
98
|
else :unknown
|
71
99
|
end
|
72
100
|
)
|
@@ -83,9 +111,9 @@ module LinuxStat
|
|
83
111
|
def sleeping
|
84
112
|
list.select { |x|
|
85
113
|
begin
|
86
|
-
IO.
|
114
|
+
IO.read("/proc/#{x}/stat").split(/(\(.*\))/)[-1][/\s.+?/].strip == ?S.freeze
|
87
115
|
rescue StandardError
|
88
|
-
|
116
|
+
false
|
89
117
|
end
|
90
118
|
}
|
91
119
|
end
|
@@ -96,9 +124,9 @@ module LinuxStat
|
|
96
124
|
def idle
|
97
125
|
list.select { |x|
|
98
126
|
begin
|
99
|
-
IO.
|
127
|
+
IO.read("/proc/#{x}/stat").split(/(\(.*\))/)[-1][/\s.+?/].strip == ?I.freeze
|
100
128
|
rescue StandardError
|
101
|
-
|
129
|
+
false
|
102
130
|
end
|
103
131
|
}
|
104
132
|
end
|
@@ -109,9 +137,9 @@ module LinuxStat
|
|
109
137
|
def zombie
|
110
138
|
list.select { |x|
|
111
139
|
begin
|
112
|
-
IO.
|
140
|
+
IO.read("/proc/#{x}/stat").split(/(\(.*\))/)[-1][/\s.+?/].strip == ?Z.freeze
|
113
141
|
rescue StandardError
|
114
|
-
|
142
|
+
false
|
115
143
|
end
|
116
144
|
}
|
117
145
|
end
|
@@ -122,9 +150,23 @@ module LinuxStat
|
|
122
150
|
def running
|
123
151
|
list.select { |x|
|
124
152
|
begin
|
125
|
-
IO.
|
153
|
+
IO.read("/proc/#{x}/stat").split(/(\(.*\))/)[-1][/\s.+?/].strip == ?R.freeze
|
154
|
+
rescue StandardError
|
155
|
+
false
|
156
|
+
end
|
157
|
+
}
|
158
|
+
end
|
159
|
+
|
160
|
+
##
|
161
|
+
# Returns all the id of processes that are stopped.
|
162
|
+
# The return type is an Array of Integers.
|
163
|
+
def stopped
|
164
|
+
list.select { |x|
|
165
|
+
begin
|
166
|
+
v = IO.read("/proc/#{x}/stat").split(/(\(.*\))/)[-1][/\s.+?/].strip
|
167
|
+
v == ?T.freeze || v == ?t.freeze
|
126
168
|
rescue StandardError
|
127
|
-
|
169
|
+
false
|
128
170
|
end
|
129
171
|
}
|
130
172
|
end
|
@@ -69,6 +69,8 @@ module LinuxStat
|
|
69
69
|
|
70
70
|
##
|
71
71
|
# = command_name(pid = $$)
|
72
|
+
# Not to be confused with process_name
|
73
|
+
# It just splits the cmdline to show the command name
|
72
74
|
#
|
73
75
|
# Where pid is the process ID.
|
74
76
|
#
|
@@ -84,12 +86,40 @@ module LinuxStat
|
|
84
86
|
# If the info isn't available it will return an empty frozen String.
|
85
87
|
def command_name(pid = $$)
|
86
88
|
# Do note that the /proc/ppid/comm may not contain the full name
|
87
|
-
|
88
|
-
|
89
|
+
# It's limited by TASK_COMM_LEN (16) characters
|
90
|
+
c = cmdline(pid).split[0]
|
91
|
+
return ''.freeze unless c
|
92
|
+
File.split(c)[-1]
|
93
|
+
end
|
89
94
|
|
90
|
-
|
91
|
-
|
92
|
-
|
95
|
+
##
|
96
|
+
# = process_name(pid = $$)
|
97
|
+
# It shows the filename of the command
|
98
|
+
# Sometimes the filename is stripped
|
99
|
+
#
|
100
|
+
# Where pid is the process ID.
|
101
|
+
#
|
102
|
+
# By default it is the id of the current process ($$)
|
103
|
+
#
|
104
|
+
# It retuns the total command name of the process.
|
105
|
+
#
|
106
|
+
# The output is String. For example:
|
107
|
+
# LinuxStat::ProcessInfo.process_name
|
108
|
+
#
|
109
|
+
# "ruby"
|
110
|
+
#
|
111
|
+
# If the info isn't available it will return an empty frozen String.
|
112
|
+
def process_name(pid = $$)
|
113
|
+
file = "/proc/#{pid}/stat".freeze
|
114
|
+
return command_name unless File.readable?(file)
|
115
|
+
|
116
|
+
name = IO.read(file).split(/(\(.*\))/) &.[](1) &.[](1..-2)
|
117
|
+
|
118
|
+
if name && name.length > 0 && name.length < 15
|
119
|
+
name
|
120
|
+
else
|
121
|
+
command_name
|
122
|
+
end
|
93
123
|
end
|
94
124
|
|
95
125
|
##
|
@@ -256,8 +286,11 @@ module LinuxStat
|
|
256
286
|
ticks = get_ticks
|
257
287
|
|
258
288
|
return {} unless File.readable?(file)
|
259
|
-
|
260
|
-
|
289
|
+
|
290
|
+
stat = IO.read(file).split(/(\(.*\))/)[-1] &.split
|
291
|
+
return {} unless stat
|
292
|
+
|
293
|
+
utime, stime, starttime = *stat.values_at(11, 12, 19).map(&:to_f)
|
261
294
|
|
262
295
|
uptime = IO.read('/proc/uptime'.freeze).to_f * ticks
|
263
296
|
|
@@ -267,9 +300,12 @@ module LinuxStat
|
|
267
300
|
sleep(sleep)
|
268
301
|
|
269
302
|
return {} unless File.readable?(file)
|
270
|
-
stat = IO.read(file).split
|
271
303
|
|
272
|
-
|
304
|
+
stat = IO.read(file).split(/(\(.*\))/)[-1] &.split
|
305
|
+
return {} unless stat
|
306
|
+
|
307
|
+
utime2, stime2, starttime2 = *stat.values_at(11, 12, 19).map(&:to_f)
|
308
|
+
|
273
309
|
uptime = IO.read('/proc/uptime'.freeze).to_f * ticks
|
274
310
|
|
275
311
|
total_time2 = utime2 + stime2
|
@@ -280,8 +316,8 @@ module LinuxStat
|
|
280
316
|
|
281
317
|
{
|
282
318
|
cpu_usage: cpu_u > 100 ? 100.0 : cpu_u.round(2),
|
283
|
-
threads: stat[
|
284
|
-
last_executed_cpu: stat[
|
319
|
+
threads: stat[17].to_i,
|
320
|
+
last_executed_cpu: stat[36].to_i
|
285
321
|
}
|
286
322
|
end
|
287
323
|
|
@@ -316,8 +352,11 @@ module LinuxStat
|
|
316
352
|
ticks = get_ticks
|
317
353
|
|
318
354
|
return nil unless File.readable?(file)
|
319
|
-
|
320
|
-
|
355
|
+
|
356
|
+
stat = IO.read(file).split(/(\(.*\))/)[-1] &.split
|
357
|
+
return nil unless stat
|
358
|
+
|
359
|
+
utime, stime, starttime = *stat.values_at(11, 12, 19).map(&:to_f)
|
321
360
|
|
322
361
|
uptime = IO.read('/proc/uptime'.freeze).to_f * ticks
|
323
362
|
|
@@ -327,9 +366,11 @@ module LinuxStat
|
|
327
366
|
sleep(sleep)
|
328
367
|
|
329
368
|
return nil unless File.readable?(file)
|
330
|
-
utime2, stime2, starttime2 = IO.read(file)
|
331
|
-
.split.values_at(13, 14, 21).map(&:to_f)
|
332
369
|
|
370
|
+
stat = IO.read(file).split(/(\(.*\))/)[-1] &.split
|
371
|
+
return nil unless stat
|
372
|
+
|
373
|
+
utime2, stime2, starttime2 = *stat.values_at(11, 12, 19).map(&:to_f)
|
333
374
|
uptime = IO.read('/proc/uptime'.freeze).to_f * ticks
|
334
375
|
|
335
376
|
total_time2 = utime2 + stime2
|
@@ -368,8 +409,11 @@ module LinuxStat
|
|
368
409
|
ticks = get_ticks
|
369
410
|
|
370
411
|
return nil unless File.readable?(file)
|
371
|
-
|
372
|
-
|
412
|
+
|
413
|
+
stat = IO.read(file).split(/(\(.*\))/)[-1] &.split
|
414
|
+
return nil unless stat
|
415
|
+
|
416
|
+
utime, stime, starttime = *stat.values_at(11, 12, 19).map(&:to_f)
|
373
417
|
|
374
418
|
uptime = IO.read('/proc/uptime'.freeze).to_f * ticks
|
375
419
|
|
@@ -379,8 +423,11 @@ module LinuxStat
|
|
379
423
|
sleep(sleep)
|
380
424
|
|
381
425
|
return nil unless File.readable?(file)
|
382
|
-
|
383
|
-
|
426
|
+
|
427
|
+
stat = IO.read(file).split(/(\(.*\))/)[-1] &.split
|
428
|
+
return nil unless stat
|
429
|
+
|
430
|
+
utime2, stime2, starttime2 = *stat.values_at(11, 12, 19).map(&:to_f)
|
384
431
|
|
385
432
|
uptime = IO.read('/proc/uptime'.freeze).to_f * ticks
|
386
433
|
|
@@ -416,7 +463,7 @@ module LinuxStat
|
|
416
463
|
file = "/proc/#{pid}/stat".freeze
|
417
464
|
return nil unless File.readable?(file)
|
418
465
|
|
419
|
-
data = IO.
|
466
|
+
data = IO.read(file).split(/(\(.*\))/)[-1] &.split &.at(17)
|
420
467
|
data ? data.to_i : nil
|
421
468
|
end
|
422
469
|
|
@@ -441,7 +488,8 @@ module LinuxStat
|
|
441
488
|
file = "/proc/#{pid}/stat".freeze
|
442
489
|
return nil unless File.readable?(file)
|
443
490
|
|
444
|
-
IO.read(file).split[
|
491
|
+
data = IO.read(file).split(/(\(.*\))/)[-1] &.split &.at(36)
|
492
|
+
data ? data.to_i : nil
|
445
493
|
end
|
446
494
|
|
447
495
|
##
|
@@ -524,8 +572,11 @@ module LinuxStat
|
|
524
572
|
@@u_readable ||= File.readable?(uptime)
|
525
573
|
return nil unless @@u_readable && File.readable?(stat_file)
|
526
574
|
|
575
|
+
stat = IO.read(stat_file).split(/(\(.*\))/)[-1] &.split
|
576
|
+
return nil unless stat
|
577
|
+
|
527
578
|
u = IO.foreach(uptime, ' '.freeze).next.to_f
|
528
|
-
st =
|
579
|
+
st = stat[19].to_f / get_ticks
|
529
580
|
|
530
581
|
# Getting two Time objects and dealing with floating point numbers
|
531
582
|
# Just to make sure the time goes monotonically
|
@@ -574,8 +625,11 @@ module LinuxStat
|
|
574
625
|
@@u_readable ||= File.readable?(uptime)
|
575
626
|
return nil unless @@u_readable && File.readable?(stat_file)
|
576
627
|
|
628
|
+
stat = IO.read(stat_file).split(/(\(.*\))/)[-1] &.split
|
629
|
+
return nil unless stat
|
630
|
+
|
577
631
|
IO.foreach(uptime, ' '.freeze).next.to_f
|
578
|
-
.-(
|
632
|
+
.-(stat[19].to_f / get_ticks).round(2)
|
579
633
|
end
|
580
634
|
|
581
635
|
##
|
@@ -599,7 +653,11 @@ module LinuxStat
|
|
599
653
|
def state(pid = $$)
|
600
654
|
file = "/proc/#{pid}/stat".freeze
|
601
655
|
return ''.freeze unless File.readable?(file)
|
602
|
-
|
656
|
+
|
657
|
+
stat = IO.read(file).split(/(\(.*\))/)[-1]
|
658
|
+
return '' unless stat
|
659
|
+
|
660
|
+
stat[/\s.+?/].strip
|
603
661
|
end
|
604
662
|
|
605
663
|
##
|
@@ -615,7 +673,10 @@ module LinuxStat
|
|
615
673
|
file = "/proc/#{pid}/stat"
|
616
674
|
return nil unless File.readable?(file)
|
617
675
|
|
618
|
-
IO.
|
676
|
+
stat = IO.read(file).split(/(\(.*\))/)[-1] &.split
|
677
|
+
return nil unless stat
|
678
|
+
|
679
|
+
stat[16].to_i
|
619
680
|
end
|
620
681
|
|
621
682
|
##
|
data/lib/linux_stat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linux_stat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sourav Goswami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Linux only, efficient linux system utilization reporting and system monitoring
|
14
14
|
gem
|