linux_stat 2.0.1 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1292d974695e1622fd5ca04cd91393b325a8acd4116727498b077b74b530aa6
4
- data.tar.gz: ba39825500d32ebaafa6d0a6176901c34e9abc98ea747f6035f4731db9ed1818
3
+ metadata.gz: b86b9e971bbc4cba82696a08bed77a75d05ba88151ab39fe107ea9ce6902bfa1
4
+ data.tar.gz: efeb2d8994fc87b3fc6a059f106988df53b3b41ced83ca1099e96210f8dbc299
5
5
  SHA512:
6
- metadata.gz: 4ae4eed738ade10f5aa8202a6552c9a4e05d2e8ba22c6f2e6f2b8f5f59a38f057befe3f2b5cef4302917ba04477c21a5fedf34538cca32256dea55df408dcee5
7
- data.tar.gz: 1569d7d670cb488b10fac97f0bfcf9c8e6c9ce3ff997524dc478e5a762e7806bbf84fb06e31f4c7376ef0c2f48e6b08f5f27671abdc5c7d54e041971ca17da64
6
+ metadata.gz: 2af9a6be65de9ed75f1d7e19fa4b19c4557a35dcffa375daef08355b6e468ba8c25f09937cfb6dbda8bc5d87999144db06408263a1f9a37901cded9bc56c7d5d
7
+ data.tar.gz: d67f4d12cc911c0d6abdc3bb08f8a913d028e39a454cca041af3b1cd6f59d5fa53d667620a698047db85dde1e9660d877576bb0e6f4aa8c1c2f40cfbb5b17acd
data/README.md CHANGED
@@ -89,7 +89,7 @@ It's generated by linuxstat.rb command, which is available after the installatio
89
89
 
90
90
  For ease of use, LinuxStat is also assigned to the LS constant.
91
91
 
92
- #### LinuxStat::BIOS
92
+ ### LinuxStat::BIOS
93
93
  ```
94
94
  # File: bios.rb | Line: 58
95
95
  # Definition: def date
@@ -135,7 +135,7 @@ LinuxStat::Battery.charge_full_wh()
135
135
  LinuxStat::Battery.charging?()
136
136
  => true
137
137
 
138
- # File: battery.rb | Line: 186
138
+ # File: battery.rb | Line: 193
139
139
  # Definition: def devices_stat
140
140
  LinuxStat::Battery.devices_stat()
141
141
  => {: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....
@@ -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.538
186
+ => 12.627
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"=>1980781, "cpu1"=>2000008, "cpu2"=>1760131, "cpu3"=>2000064}
210
+ => {"cpu0"=>2000001, "cpu1"=>2000003, "cpu2"=>2000010, "cpu3"=>1999999}
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=>9.52, 1=>16.67, 2=>16.67, 3=>0.0, 4=>0.0}
245
+ => {0=>38.89, 1=>20.0, 2=>33.33, 3=>25.0, 4=>100.0}
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
- => 0.0
250
+ => 45.0
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
- => 5.0
255
+ => 47.37
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=>5.26, 1=>20.0, 2=>0.0, 3=>0.0, 4=>0.0}
260
+ => {0=>44.44, 1=>20.0, 2=>20.0, 3=>20.0, 4=>100.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=>8714668, :block_avail_unpriv=>8714668, :inodes=>58612160, :free_inodes=>56817750, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
267
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>7715553, :block_avail_unpriv=>7715553, :inodes=>58612160, :free_inodes=>56766199, :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
- => 35695280128
276
+ => 31602905088
277
277
 
278
278
  # File: filesystem.rb | Line: 60
279
279
  # Definition: def free(fs = ?..freeze)
280
280
  LinuxStat::Filesystem.free(fs)
281
- => 35695280128
281
+ => 31602905088
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=>35695280128, :used=>84285911040}
286
+ => {:total=>119981191168, :free=>31602905088, :used=>88378286080}
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=>8714668, :block_avail_unpriv=>8714668, :inodes=>58612160, :free_inodes=>56817750, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
291
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>7715553, :block_avail_unpriv=>7715553, :inodes=>58612160, :free_inodes=>56766199, :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
- => 84285911040
301
+ => 88378286080
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
- => 1155372
364
+ => 310424
365
365
 
366
366
  # File: memory.rb | Line: 52
367
367
  # Definition: def free
368
368
  LinuxStat::Memory.free()
369
- => 261316
369
+ => 278680
370
370
 
371
371
  # File: memory.rb | Line: 93
372
372
  # Definition: def percent_available
373
373
  LinuxStat::Memory.percent_available()
374
- => 30.12
374
+ => 8.09
375
375
 
376
376
  # File: memory.rb | Line: 82
377
377
  # Definition: def percent_used
378
378
  LinuxStat::Memory.percent_used()
379
- => 69.88
379
+ => 91.91
380
380
 
381
381
  # File: memory.rb | Line: 13
382
382
  # Definition: def stat
383
383
  LinuxStat::Memory.stat()
384
- => {:total=>3836228, :used=>2680856, :available=>1155372, :percent_used=>69.88, :percent_available=>30.12}
384
+ => {:total=>3836236, :used=>3525820, :available=>310416, :percent_used=>91.91, :percent_available=>8.09}
385
385
 
386
386
  # File: memory.rb | Line: 42
387
387
  # Definition: def total
388
388
  LinuxStat::Memory.total()
389
- => 3836228
389
+ => 3836236
390
390
 
391
391
  # File: memory.rb | Line: 72
392
392
  # Definition: def used
393
393
  LinuxStat::Memory.used()
394
- => 2680856
394
+ => 3525820
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=>35695280128, :available=>35695280128, :used=>84285911040, :percent_used=>70.25, :percent_free=>29.75, :percent_available=>29.75}
403
+ => {:mountpoint=>"/", :total=>119981191168, :free=>31602905088, :available=>31602905088, :used=>88378286080, :percent_used=>73.66, :percent_free=>26.34, :percent_available=>26.34}
404
404
 
405
405
  # File: mounts.rb | Line: 139
406
406
  # Definition: def devices_stat
@@ -410,7 +410,7 @@ 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=1892888k,nr_inodes=473222,mode=755 0 0", "run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0", "...
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=1892892k,nr_inodes=473223,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
@@ -420,7 +420,7 @@ LinuxStat::Mounts.list_devices()
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/perf_event", "pstore...
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/cpuset", "pstore"=>"...
424
424
 
425
425
  # File: mounts.rb | Line: 82
426
426
  # Definition: def mount_point(dev = root)
@@ -454,32 +454,32 @@ LinuxStat::Mounts.tmpfs()
454
454
  # File: net.rb | Line: 86
455
455
  # Definition: def usage(interval = 0.1)
456
456
  LinuxStat::Net.current_usage(interval)
457
- => {:received=>2805500.0, :transmitted=>127290.0}
457
+ => {:received=>0.0, :transmitted=>0.0}
458
458
 
459
459
  # File: net.rb | Line: 12
460
460
  # Definition: def ipv4_private
461
461
  LinuxStat::Net.ipv4_private()
462
- => "192.168.0.103"
462
+ => "192.168.43.107"
463
463
 
464
464
  # File: net.rb | Line: 27
465
465
  # Definition: def total_bytes
466
466
  LinuxStat::Net.total_bytes()
467
- => {:received=>1312151997, :transmitted=>81641336}
467
+ => {:received=>850558466, :transmitted=>187230758}
468
468
 
469
469
  # File: net.rb | Line: 45
470
470
  # Definition: def total_bytes_received
471
471
  LinuxStat::Net.total_bytes_received()
472
- => 1312151997
472
+ => 850558466
473
473
 
474
474
  # File: net.rb | Line: 58
475
475
  # Definition: def total_bytes_transmitted
476
476
  LinuxStat::Net.total_bytes_transmitted()
477
- => 81641336
477
+ => 187230758
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=>2971440.0, :transmitted=>80020.0}
482
+ => {:received=>0.0, :transmitted=>0.0}
483
483
 
484
484
  ```
485
485
 
@@ -508,7 +508,7 @@ LinuxStat::OS.hostname()
508
508
  # File: os.rb | Line: 202
509
509
  # Definition: def loadavg
510
510
  LinuxStat::OS.loadavg()
511
- => {1=>2.78173828125, 5=>2.96923828125, 15=>2.40185546875}
511
+ => {1=>4.5693359375, 5=>3.85400390625, 15=>3.53515625}
512
512
 
513
513
  # File: os.rb | Line: 35
514
514
  # Definition: def lsb_release
@@ -533,17 +533,17 @@ LinuxStat::OS.os_release()
533
533
  # File: os.rb | Line: 146
534
534
  # Definition: def uptime
535
535
  LinuxStat::OS.uptime()
536
- => {:hour=>5, :minute=>33, :second=>59.77}
536
+ => {:hour=>16, :minute=>52, :second=>3.39}
537
537
 
538
538
  # File: os.rb | Line: 174
539
539
  # Definition: def uptime_f
540
540
  LinuxStat::OS.uptime_f()
541
- => 20039.77
541
+ => 60723.39
542
542
 
543
543
  # File: os.rb | Line: 185
544
544
  # Definition: def uptime_i
545
545
  LinuxStat::OS.uptime_i()
546
- => 20040
546
+ => 60724
547
547
 
548
548
  # File: os.rb | Line: 84
549
549
  # Definition: def version
@@ -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 = 388183402613652, precision:)
599
- => "353.05 tebibytes"
598
+ LinuxStat::PrettifyBytes.convert_binary(n = 630454817180687, precision:)
599
+ => "573.40 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 = 937555692903085, precision:)
604
- => "937.56 terabytes"
603
+ LinuxStat::PrettifyBytes.convert_decimal(n = 42077508120898, precision:)
604
+ => "42.08 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 = 542625870963586, precision:)
609
- => "493.52 TiB"
608
+ LinuxStat::PrettifyBytes.convert_short_binary(n = 363689812033137, precision:)
609
+ => "330.77 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 = 861937756585891, precision:)
614
- => "861.94 TB"
613
+ LinuxStat::PrettifyBytes.convert_short_decimal(n = 119056846159316, precision:)
614
+ => "119.06 TB"
615
615
 
616
616
  ```
617
617
 
618
618
  ### LinuxStat::ProcFS
619
619
  ```
620
620
  LinuxStat::ProcFS.last_pid()
621
- => 12587
621
+ => 34902
622
622
 
623
623
  LinuxStat::ProcFS.uptime_f()
624
- => 20039.98
624
+ => 60723.68
625
625
 
626
626
  ```
627
627
 
@@ -635,17 +635,17 @@ LinuxStat::Process.cmdlines()
635
635
  # File: process.rb | Line: 29
636
636
  # Definition: def count
637
637
  LinuxStat::Process.count()
638
- => 190
638
+ => 216
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, 135, 140, 165, 167, 170, 171, 175, 180, 181, 182, 183, 184, 185, 186, 188, 225, 232, 234, 270, 415, 419, 422, 10749, 11032, 11078, 11124, 11128,...
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, 177, 179, 182, 183, 186, 192, 193, 194, 195, 196, 197, 198, 199, 243, 245, 294, 461, 493, 517, 9197, 16346, 16347, 16348, 16349, 16350, 163...
644
644
 
645
645
  # File: process.rb | Line: 160
646
646
  # Definition: def last_pid
647
647
  LinuxStat::Process.last_pid()
648
- => 12587
648
+ => 34902
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-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...
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=>"idle_inject/...
659
659
 
660
660
  # File: process.rb | Line: 138
661
661
  # Definition: def running
662
662
  LinuxStat::Process.running()
663
- => [12583]
663
+ => [16203, 27259, 34902]
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, 164, 166, 189, 217, 233, 235, 307, 310, 311, 312, 313, 418, 420, 421, 424, 426, 429, 444, 447, 450, 481,...
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, 176, 178, 200, 228, 244, 246, 322, 325, 326, 327, 328, 389, 390, 391, 392, 409, 411, 415, 479, 535, 537,...
669
669
 
670
670
  # File: process.rb | Line: 147
671
671
  # Definition: def stopped
@@ -706,6 +706,16 @@ 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: 664
710
+ # Definition: def cpu_time(pid = $$)
711
+ LinuxStat::ProcessInfo.cpu_time(pid)
712
+ => 0
713
+
714
+ # File: process_info.rb | Line: 677
715
+ # Definition: def cpu_times(pid = $$)
716
+ LinuxStat::ProcessInfo.cpu_times(pid)
717
+ => {:hour=>0, :minute=>0, :second=>0}
718
+
709
719
  # File: process_info.rb | Line: 340
710
720
  # Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
711
721
  LinuxStat::ProcessInfo.cpu_usage(pid:, sleep:)
@@ -724,12 +734,12 @@ LinuxStat::ProcessInfo.last_executed_cpu(pid)
724
734
  # File: process_info.rb | Line: 151
725
735
  # Definition: def mem_stat(pid = $$)
726
736
  LinuxStat::ProcessInfo.mem_stat(pid)
727
- => {:memory=>24576000, :virtual_memory=>96206848, :resident_memory=>30736384, :shared_memory=>6160384}
737
+ => {:memory=>24821760, :virtual_memory=>96198656, :resident_memory=>30973952, :shared_memory=>6152192}
728
738
 
729
739
  # File: process_info.rb | Line: 171
730
740
  # Definition: def memory(pid = $$)
731
741
  LinuxStat::ProcessInfo.memory(pid)
732
- => 24576.0
742
+ => 24821.76
733
743
 
734
744
  # File: process_info.rb | Line: 624
735
745
  # Definition: def nice(pid = $$)
@@ -754,27 +764,27 @@ LinuxStat::ProcessInfo.process_name(pid)
754
764
  # File: process_info.rb | Line: 213
755
765
  # Definition: def resident_memory(pid = $$)
756
766
  LinuxStat::ProcessInfo.resident_memory(pid)
757
- => 30736.384
767
+ => 30973.952
758
768
 
759
769
  # File: process_info.rb | Line: 586
760
770
  # Definition: def running_time(pid = $$)
761
771
  LinuxStat::ProcessInfo.running_time(pid)
762
- => 1.02
772
+ => 1.19
763
773
 
764
774
  # File: process_info.rb | Line: 234
765
775
  # Definition: def shared_memory(pid = $$)
766
776
  LinuxStat::ProcessInfo.shared_memory(pid)
767
- => 6160.384
777
+ => 6152.192
768
778
 
769
779
  # File: process_info.rb | Line: 567
770
780
  # Definition: def start_time(pid = $$)
771
781
  LinuxStat::ProcessInfo.start_time(pid)
772
- => 2021-02-01 16:58:34 +0530
782
+ => 2021-02-06 04:32:07 +0530
773
783
 
774
784
  # File: process_info.rb | Line: 539
775
785
  # Definition: def start_time_epoch(pid = $$)
776
786
  LinuxStat::ProcessInfo.start_time_epoch(pid)
777
- => 1612178914
787
+ => 1612566127
778
788
 
779
789
  # File: process_info.rb | Line: 611
780
790
  # Definition: def state(pid = $$)
@@ -794,7 +804,7 @@ LinuxStat::ProcessInfo.threads(pid)
794
804
  # File: process_info.rb | Line: 30
795
805
  # Definition: def total_io(pid = $$)
796
806
  LinuxStat::ProcessInfo.total_io(pid)
797
- => {:read_bytes=>1245184, :write_bytes=>0}
807
+ => {:read_bytes=>0, :write_bytes=>0}
798
808
 
799
809
  # File: process_info.rb | Line: 472
800
810
  # Definition: def uid(pid = $$)
@@ -804,7 +814,7 @@ LinuxStat::ProcessInfo.uid(pid)
804
814
  # File: process_info.rb | Line: 192
805
815
  # Definition: def virtual_memory(pid = $$)
806
816
  LinuxStat::ProcessInfo.virtual_memory(pid)
807
- => 96206.848
817
+ => 96198.656
808
818
 
809
819
  ```
810
820
 
@@ -815,45 +825,45 @@ LinuxStat::ProcessInfo.virtual_memory(pid)
815
825
  LinuxStat::Swap.any?()
816
826
  => true
817
827
 
818
- # File: swap.rb | Line: 81
828
+ # File: swap.rb | Line: 84
819
829
  # Definition: def available
820
830
  LinuxStat::Swap.available()
821
- => 3856636
831
+ => 2800844
822
832
 
823
- # File: swap.rb | Line: 70
833
+ # File: swap.rb | Line: 73
824
834
  # Definition: def free
825
835
  LinuxStat::Swap.free()
826
- => 3856636
836
+ => 2800844
827
837
 
828
838
  # File: swap.rb | Line: 10
829
839
  # Definition: def list
830
840
  LinuxStat::Swap.list()
831
- => {"/dev/zram0"=>[:partition, 4194300, 337664, -2]}
841
+ => {"/dev/zram0"=>[:partition, 4194300, 1393456, -2]}
832
842
 
833
- # File: swap.rb | Line: 116
843
+ # File: swap.rb | Line: 127
834
844
  # Definition: def percent_available
835
845
  LinuxStat::Swap.percent_available()
836
- => 91.95
846
+ => 66.78
837
847
 
838
- # File: swap.rb | Line: 102
848
+ # File: swap.rb | Line: 107
839
849
  # Definition: def percent_used
840
850
  LinuxStat::Swap.percent_used()
841
- => 8.05
851
+ => 33.22
842
852
 
843
853
  # File: swap.rb | Line: 34
844
854
  # Definition: def stat
845
855
  LinuxStat::Swap.stat()
846
- => {:total=>4194300, :used=>337664, :available=>3856636, :percent_used=>8.05, :percent_available=>91.95}
856
+ => {:total=>4194300, :used=>1393456, :available=>2800844, :percent_used=>33.22, :percent_available=>66.78}
847
857
 
848
- # File: swap.rb | Line: 59
858
+ # File: swap.rb | Line: 62
849
859
  # Definition: def total
850
860
  LinuxStat::Swap.total()
851
861
  => 4194300
852
862
 
853
- # File: swap.rb | Line: 93
863
+ # File: swap.rb | Line: 98
854
864
  # Definition: def used
855
865
  LinuxStat::Swap.used()
856
- => 337664
866
+ => 1393456
857
867
 
858
868
  ```
859
869
 
@@ -927,31 +937,31 @@ LinuxStat::Sysinfo.freehigh()
927
937
  => 0
928
938
 
929
939
  LinuxStat::Sysinfo.freeram()
930
- => 251408384
940
+ => 281231360
931
941
 
932
942
  LinuxStat::Sysinfo.freeswap()
933
- => 3949195264
943
+ => 2868064256
934
944
 
935
945
  LinuxStat::Sysinfo.loads()
936
- => [2.78173828125, 2.96923828125, 2.40185546875]
946
+ => [4.5693359375, 3.85400390625, 3.53515625]
937
947
 
938
948
  LinuxStat::Sysinfo.sharedram()
939
- => 606461952
949
+ => 694075392
940
950
 
941
951
  LinuxStat::Sysinfo.stat()
942
- => {:totalram=>3928297472, :freeram=>251408384, :sharedram=>606461952, :bufferram=>4096, :totalswap=>4294963200, :freeswap=>3949195264, :totalhigh=>0, :freehigh=>0, :uptime=>20041, :loads=>[2.78173828125, 2.96923828125, 2.40185546875]}
952
+ => {:totalram=>3928305664, :freeram=>281231360, :sharedram=>694075392, :bufferram=>4096, :totalswap=>4294963200, :freeswap=>2868064256, :totalhigh=>0, :freehigh=>0, :uptime=>60724, :loads=>[4.5693359375, 3.85400390625, 3.53515625]}
943
953
 
944
954
  LinuxStat::Sysinfo.totalhigh()
945
955
  => 0
946
956
 
947
957
  LinuxStat::Sysinfo.totalram()
948
- => 3928297472
958
+ => 3928305664
949
959
 
950
960
  LinuxStat::Sysinfo.totalswap()
951
961
  => 4294963200
952
962
 
953
963
  LinuxStat::Sysinfo.uptime()
954
- => 20041
964
+ => 60724
955
965
 
956
966
  ```
957
967
 
@@ -970,12 +980,12 @@ LinuxStat::Thermal.count_sensors()
970
980
  # File: thermal.rb | Line: 41
971
981
  # Definition: def fans
972
982
  LinuxStat::Thermal.fans()
973
- => [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Processor Fan", :rpm=>2785}]
983
+ => [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Processor Fan", :rpm=>2686}]
974
984
 
975
985
  # File: thermal.rb | Line: 23
976
986
  # Definition: def temperatures
977
987
  LinuxStat::Thermal.temperatures()
978
- => [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"SODIMM", :temperature=>34.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"CPU", :temperature=>43.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Ambi...
988
+ => [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"SODIMM", :temperature=>36.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"CPU", :temperature=>50.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Ambi...
979
989
 
980
990
  ```
981
991
 
@@ -984,17 +994,17 @@ LinuxStat::Thermal.temperatures()
984
994
  # File: usb.rb | Line: 139
985
995
  # Definition: def count
986
996
  LinuxStat::USB.count()
987
- => 10
997
+ => 11
988
998
 
989
999
  # File: usb.rb | Line: 139
990
1000
  # Definition: def count
991
1001
  LinuxStat::USB.count_devices()
992
- => 10
1002
+ => 11
993
1003
 
994
1004
  # File: usb.rb | Line: 49
995
1005
  # Definition: def devices_stat(hwdata: true)
996
1006
  LinuxStat::USB.devices_stat(hwdata:)
997
- => [{: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...
1007
+ => [{:path=>"/sys/bus/usb/devices/1-1.2/", :id=>"04d9:1203", :vendor_id=>"04d9", :product_id=>"1203", :bus_num=>1, :dev_num=>20, :hwdata=>{:vendor=>"Holtek Semiconductor, Inc.", :product=>"Keyboard"}, :authorized=>true, :b_max_power=>"100mA", :b_max_pack...
998
1008
 
999
1009
  # File: usb.rb | Line: 179
1000
1010
  # Definition: def hwdata_file
data/ext/procfs/stat.h CHANGED
@@ -1,6 +1,9 @@
1
1
  VALUE ps_state(VALUE obj, VALUE pid) {
2
+ int _pid = FIX2INT(pid) ;
3
+ if (_pid < 0) return rb_str_new_cstr("") ;
4
+
2
5
  char _path[22] ;
3
- sprintf(_path, "/proc/%lu/stat", FIX2UINT(pid)) ;
6
+ sprintf(_path, "/proc/%d/stat", _pid) ;
4
7
 
5
8
  FILE *f = fopen(_path, "r") ;
6
9
  if (!f) return rb_str_new_cstr("") ;
@@ -15,8 +18,11 @@ VALUE ps_state(VALUE obj, VALUE pid) {
15
18
  }
16
19
 
17
20
  VALUE ps_stat(VALUE obj, VALUE pid) {
21
+ int _pid = FIX2INT(pid) ;
22
+ if (_pid < 0) return rb_str_new_cstr("") ;
23
+
18
24
  char _path[22] ;
19
- sprintf(_path, "/proc/%lu/stat", FIX2UINT(pid)) ;
25
+ sprintf(_path, "/proc/%d/stat", _pid) ;
20
26
 
21
27
  FILE *f = fopen(_path, "r") ;
22
28
 
data/ext/procfs/statm.h CHANGED
@@ -1,13 +1,15 @@
1
1
  #define PAGESIZE sysconf(_SC_PAGESIZE)
2
2
 
3
3
  VALUE statm(VALUE obj, VALUE pid) {
4
- char _path[22] ;
5
- sprintf(_path, "/proc/%lu/statm", FIX2UINT(pid)) ;
4
+ VALUE hash = rb_hash_new() ;
6
5
 
7
- FILE *f = fopen(_path, "r") ;
6
+ int _pid = FIX2INT(pid) ;
7
+ if (_pid < 0) return hash ;
8
8
 
9
- VALUE hash = rb_hash_new() ;
9
+ char _path[22] ;
10
+ sprintf(_path, "/proc/%d/statm", _pid) ;
10
11
 
12
+ FILE *f = fopen(_path, "r") ;
11
13
  if (!f) return hash ;
12
14
 
13
15
  unsigned int _virtual, resident, shared ;
@@ -33,13 +35,15 @@ VALUE statm(VALUE obj, VALUE pid) {
33
35
  }
34
36
 
35
37
  VALUE statm_virtual(VALUE obj, VALUE pid) {
38
+ int _pid = FIX2INT(pid) ;
39
+ if (_pid < 0) return Qnil ;
40
+
36
41
  char _path[22] ;
37
- sprintf(_path, "/proc/%lu/statm", FIX2UINT(pid)) ;
42
+ sprintf(_path, "/proc/%d/statm", _pid) ;
38
43
 
39
44
  FILE *f = fopen(_path, "r") ;
40
- VALUE hash = rb_hash_new() ;
45
+ if (!f) return Qnil ;
41
46
 
42
- if (!f) return hash ;
43
47
  unsigned int _virtual ;
44
48
  char status = fscanf(f, "%u", &_virtual) ;
45
49
  fclose(f) ;
@@ -49,13 +53,15 @@ VALUE statm_virtual(VALUE obj, VALUE pid) {
49
53
  }
50
54
 
51
55
  VALUE statm_resident(VALUE obj, VALUE pid) {
56
+ int _pid = FIX2INT(pid) ;
57
+ if (_pid < 0) return Qnil ;
58
+
52
59
  char _path[22] ;
53
- sprintf(_path, "/proc/%lu/statm", FIX2UINT(pid)) ;
60
+ sprintf(_path, "/proc/%d/statm", _pid) ;
54
61
 
55
62
  FILE *f = fopen(_path, "r") ;
56
- VALUE hash = rb_hash_new() ;
63
+ if (!f) return Qnil ;
57
64
 
58
- if (!f) return hash ;
59
65
  unsigned int resident ;
60
66
  char status = fscanf(f, "%*u %u", &resident) ;
61
67
  fclose(f) ;
@@ -65,13 +71,15 @@ VALUE statm_resident(VALUE obj, VALUE pid) {
65
71
  }
66
72
 
67
73
  VALUE statm_shared(VALUE obj, VALUE pid) {
74
+ int _pid = FIX2INT(pid) ;
75
+ if (_pid < 0) return Qnil ;
76
+
68
77
  char _path[22] ;
69
- sprintf(_path, "/proc/%lu/statm", FIX2UINT(pid)) ;
78
+ sprintf(_path, "/proc/%d/statm", _pid) ;
70
79
 
71
80
  FILE *f = fopen(_path, "r") ;
72
- VALUE hash = rb_hash_new() ;
81
+ if (!f) return Qnil ;
73
82
 
74
- if (!f) return hash ;
75
83
  unsigned int shared ;
76
84
  char status = fscanf(f, "%*u %*u %u", &shared) ;
77
85
  fclose(f) ;
@@ -81,11 +89,13 @@ VALUE statm_shared(VALUE obj, VALUE pid) {
81
89
  }
82
90
 
83
91
  VALUE statm_memory(VALUE obj, VALUE pid) {
92
+ int _pid = FIX2INT(pid) ;
93
+ if (_pid < 0) return Qnil ;
94
+
84
95
  char _path[22] ;
85
- sprintf(_path, "/proc/%lu/statm", FIX2UINT(pid)) ;
96
+ sprintf(_path, "/proc/%d/statm", _pid) ;
86
97
 
87
98
  FILE *f = fopen(_path, "r") ;
88
-
89
99
  if (!f) return Qnil ;
90
100
 
91
101
  unsigned int resident, shared ;
@@ -178,7 +178,14 @@ module LinuxStat
178
178
  # For example, a sample output can be like this (taken on a test system):
179
179
  #
180
180
  # LinuxStat::Battery.devices_stat
181
- # => {: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.558, :charge_now=>2.087, :charge_now_wh=>26.21, :charge_full_wh=>23.79, :charge_percentage=>100.0}, :hidpp_battery_0=>{:model=>"Wireless Keyboard", :manufacturer=>"Logitech", :type=>"Battery", :status=>"Discharging", :online=>1}}
181
+ # => {:AC=>{:type=>"Mains", :online=>1},
182
+ # :BAT0=>{:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI",
183
+ # :type=>"Battery", :status=>"Full", :capacity=>100, :voltage_min_design=>11.4,
184
+ # :charge_full_design=>3.684, :charge_full_design_wh=>42.0,
185
+ # :voltage_now=>12.558, :charge_now=>2.087, :charge_now_wh=>26.21,
186
+ # :charge_full_wh=>23.79, :charge_percentage=>100.0},
187
+ # :hidpp_battery_0=>{:model=>"Wireless Keyboard", :manufacturer=>"Logitech",
188
+ # :type=>"Battery", :status=>"Discharging", :online=>1}}
182
189
  #
183
190
  # If you need info about lots of batteries, use this method.
184
191
  # If the informations are not available, it will return empty Hash for each devices.
data/lib/linux_stat/os.rb CHANGED
@@ -151,7 +151,7 @@ module LinuxStat
151
151
 
152
152
  h = uptime_i / 3600
153
153
  m = uptime_i % 3600 / 60
154
- s = _uptime.%(3600).%(60).round(2)
154
+ s = _uptime.%(60).round(2)
155
155
 
156
156
  {
157
157
  hour: h,
@@ -655,6 +655,39 @@ module LinuxStat
655
655
  LinuxStat::Nproc.count_cpu_for_pid(pid)
656
656
  end
657
657
 
658
+ ##
659
+ # = def cpu_times_i(pid = $$)
660
+ #
661
+ # Shows the CPU time used by the process.
662
+ #
663
+ # The return value is an Integer.
664
+ def cpu_time(pid = $$)
665
+ times = LinuxStat::ProcFS.ps_stat(pid)
666
+ utime, stime, cutime, cstime = times[10], times[11], times[12], times[13]
667
+
668
+ utime.+(stime).+(cutime).+(cstime) / get_ticks
669
+ end
670
+
671
+ ##
672
+ # = def cpu_times(pid = $$)
673
+ #
674
+ # Shows the CPU time used by the process.
675
+ #
676
+ # The return value is a Hash.
677
+ def cpu_times(pid = $$)
678
+ v = cpu_time(pid)
679
+
680
+ hour = v / 3600
681
+ min = v % 3600 / 60
682
+ sec = v % 60
683
+
684
+ {
685
+ hour: hour,
686
+ minute: min,
687
+ second: sec
688
+ }
689
+ end
690
+
658
691
  alias count_cpu nproc
659
692
 
660
693
  private
@@ -1,3 +1,3 @@
1
1
  module LinuxStat
2
- VERSION ||= "2.0.1"
2
+ VERSION ||= "2.1.0"
3
3
  end
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: 2.0.1
4
+ version: 2.1.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-02-02 00:00:00.000000000 Z
11
+ date: 2021-02-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Linux only, efficient linux system utilization reporting and system monitoring
14
14
  gem
@@ -19,10 +19,10 @@ executables:
19
19
  extensions:
20
20
  - ext/fs_stat/extconf.rb
21
21
  - ext/nproc/extconf.rb
22
+ - ext/procfs/extconf.rb
22
23
  - ext/sysconf/extconf.rb
23
24
  - ext/sysinfo/extconf.rb
24
25
  - ext/utsname/extconf.rb
25
- - ext/procfs/extconf.rb
26
26
  extra_rdoc_files:
27
27
  - README.md
28
28
  files: