linux_stat 0.7.5 → 0.8.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 +102 -72
- data/ext/fs_stat/fs_stat.c +7 -2
- data/ext/sysconf/sysconf.c +28 -2
- data/ext/utsname/utsname.c +24 -14
- data/lib/linux_stat/cpu.rb +19 -4
- 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: f24315a14357e71327614a2ec812f052ff71973af21e34e6a14f3a24f537083a
|
4
|
+
data.tar.gz: f2c18ac10d00092ead72522700cf97d58b599890b6c6a0fd076e4ffd88ebf6b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06ec57333b02c7cf239ed0f2e2cd889f95110523e642807d534ec71c9761b9f58066326ed01291871b4f7d9b692adc778db743f2c275f4485c2779ea320b1253
|
7
|
+
data.tar.gz: b577d7ed448d1c5f474ab70c0fda4fd333f43049f27978cf9970032f15c05f2b2f3040d248108393bde474324b6e1d83694d7054a6f2d1f0eaba466d2c7c2b8b
|
data/README.md
CHANGED
@@ -10,6 +10,14 @@ It only works for Linux, and detecting the OS is upto the user of this gem.
|
|
10
10
|
|
11
11
|
---
|
12
12
|
|
13
|
+
## Source LOC (no comments / blank lines are counted):
|
14
|
+
|
15
|
+
<div style="text-align:center">
|
16
|
+
<img src="https://linuxstatloc.herokuapp.com/badge.svg" width="360px">
|
17
|
+
</div>
|
18
|
+
|
19
|
+
---
|
20
|
+
|
13
21
|
## Dependencies:
|
14
22
|
+ You need to have the C compiler installed to be able to compile the C extensions.
|
15
23
|
On Arch Linux:
|
@@ -128,52 +136,57 @@ LinuxStat::Battery.technology()
|
|
128
136
|
|
129
137
|
### LinuxStat::CPU
|
130
138
|
```
|
131
|
-
# File: cpu.rb | Line:
|
139
|
+
# File: cpu.rb | Line: 95
|
132
140
|
# Definition: def count
|
133
141
|
LinuxStat::CPU.count()
|
134
142
|
=> 4
|
135
143
|
|
136
|
-
# File: cpu.rb | Line:
|
144
|
+
# File: cpu.rb | Line: 116
|
137
145
|
# Definition: def cur_freq
|
138
146
|
LinuxStat::CPU.cur_freq()
|
139
|
-
=> [
|
147
|
+
=> [2000141, 2000023, 1999435, 2000128]
|
140
148
|
|
141
|
-
# File: cpu.rb | Line:
|
149
|
+
# File: cpu.rb | Line: 131
|
142
150
|
# Definition: def max_freq
|
143
151
|
LinuxStat::CPU.max_freq()
|
144
152
|
=> [2000000, 2000000, 2000000, 2000000]
|
145
153
|
|
146
|
-
# File: cpu.rb | Line:
|
154
|
+
# File: cpu.rb | Line: 108
|
147
155
|
# Definition: def model
|
148
156
|
LinuxStat::CPU.model()
|
149
157
|
=> "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
|
150
158
|
|
159
|
+
# File: cpu.rb | Line: 84
|
160
|
+
# Definition: def online
|
161
|
+
LinuxStat::CPU.online()
|
162
|
+
=> 4
|
163
|
+
|
151
164
|
# File: cpu.rb | Line: 21
|
152
|
-
# Definition: def stat(sleep =
|
165
|
+
# Definition: def stat(sleep = ticks_to_ms_t5)
|
153
166
|
LinuxStat::CPU.stat(sleep)
|
154
|
-
=> {0=>
|
167
|
+
=> {0=>5.26, 1=>0.0, 2=>0.0, 3=>0.0, 4=>16.67}
|
155
168
|
|
156
169
|
# File: cpu.rb | Line: 63
|
157
|
-
# Definition: def total_usage(sleep =
|
158
|
-
LinuxStat::CPU.
|
159
|
-
=>
|
170
|
+
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
171
|
+
LinuxStat::CPU.total_usage(sleep)
|
172
|
+
=> 15.0
|
160
173
|
|
161
174
|
# File: cpu.rb | Line: 63
|
162
|
-
# Definition: def total_usage(sleep =
|
175
|
+
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
163
176
|
LinuxStat::CPU.usage(sleep)
|
164
|
-
=>
|
177
|
+
=> 10.0
|
165
178
|
|
166
179
|
# File: cpu.rb | Line: 21
|
167
|
-
# Definition: def stat(sleep =
|
180
|
+
# Definition: def stat(sleep = ticks_to_ms_t5)
|
168
181
|
LinuxStat::CPU.usages(sleep)
|
169
|
-
=> {0=>
|
182
|
+
=> {0=>15.0, 1=>20.0, 2=>0.0, 3=>20.0, 4=>20.0}
|
170
183
|
|
171
184
|
```
|
172
185
|
|
173
186
|
### LinuxStat::FS
|
174
187
|
```
|
175
188
|
LinuxStat::FS.stat(arg = "/")
|
176
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>
|
189
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>12798990, :block_avail_unpriv=>12798990, :inodes=>58612160, :free_inodes=>56966374, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
177
190
|
|
178
191
|
```
|
179
192
|
|
@@ -182,22 +195,22 @@ LinuxStat::FS.stat(arg = "/")
|
|
182
195
|
# File: filesystem.rb | Line: 92
|
183
196
|
# Definition: def available(fs = ?/.freeze)
|
184
197
|
LinuxStat::Filesystem.available(fs)
|
185
|
-
=>
|
198
|
+
=> 52424663040
|
186
199
|
|
187
200
|
# File: filesystem.rb | Line: 58
|
188
201
|
# Definition: def free(fs = ?/.freeze)
|
189
202
|
LinuxStat::Filesystem.free(fs)
|
190
|
-
=>
|
203
|
+
=> 52424663040
|
191
204
|
|
192
205
|
# File: filesystem.rb | Line: 19
|
193
206
|
# Definition: def stat(fs = ?/.freeze)
|
194
207
|
LinuxStat::Filesystem.stat(fs)
|
195
|
-
=> {:total=>119981191168, :free=>
|
208
|
+
=> {:total=>119981191168, :free=>52424663040, :used=>67556528128}
|
196
209
|
|
197
210
|
# File: filesystem.rb | Line: 108
|
198
211
|
# Definition: def stat_raw(fs = ?/.freeze)
|
199
212
|
LinuxStat::Filesystem.stat_raw(fs)
|
200
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>
|
213
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>12798990, :block_avail_unpriv=>12798990, :inodes=>58612160, :free_inodes=>56966374, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
201
214
|
|
202
215
|
# File: filesystem.rb | Line: 39
|
203
216
|
# Definition: def total(fs = ?/.freeze)
|
@@ -207,7 +220,7 @@ LinuxStat::Filesystem.total(fs)
|
|
207
220
|
# File: filesystem.rb | Line: 73
|
208
221
|
# Definition: def used(fs = ?/.freeze)
|
209
222
|
LinuxStat::Filesystem.used(fs)
|
210
|
-
=>
|
223
|
+
=> 67556528128
|
211
224
|
|
212
225
|
```
|
213
226
|
|
@@ -270,22 +283,22 @@ LinuxStat::Kernel.version()
|
|
270
283
|
# File: memory.rb | Line: 50
|
271
284
|
# Definition: def available
|
272
285
|
LinuxStat::Memory.available()
|
273
|
-
=>
|
286
|
+
=> 842868
|
274
287
|
|
275
288
|
# File: memory.rb | Line: 81
|
276
289
|
# Definition: def percent_available
|
277
290
|
LinuxStat::Memory.percent_available()
|
278
|
-
=>
|
291
|
+
=> 21.97
|
279
292
|
|
280
293
|
# File: memory.rb | Line: 70
|
281
294
|
# Definition: def percent_used
|
282
295
|
LinuxStat::Memory.percent_used()
|
283
|
-
=>
|
296
|
+
=> 78.03
|
284
297
|
|
285
298
|
# File: memory.rb | Line: 11
|
286
299
|
# Definition: def stat
|
287
300
|
LinuxStat::Memory.stat()
|
288
|
-
=> {:total=>3836236, :used=>
|
301
|
+
=> {:total=>3836236, :used=>2993368, :available=>842868, :percent_used=>78.03, :percent_available=>21.97}
|
289
302
|
|
290
303
|
# File: memory.rb | Line: 40
|
291
304
|
# Definition: def total
|
@@ -295,7 +308,7 @@ LinuxStat::Memory.total()
|
|
295
308
|
# File: memory.rb | Line: 60
|
296
309
|
# Definition: def used
|
297
310
|
LinuxStat::Memory.used()
|
298
|
-
=>
|
311
|
+
=> 2993368
|
299
312
|
|
300
313
|
```
|
301
314
|
|
@@ -304,7 +317,7 @@ LinuxStat::Memory.used()
|
|
304
317
|
# File: mounts.rb | Line: 179
|
305
318
|
# Definition: def device_stat(dev = root)
|
306
319
|
LinuxStat::Mounts.device_stat(dev)
|
307
|
-
=> {:mountpoint=>"/", :total=>119981191168, :free=>
|
320
|
+
=> {:mountpoint=>"/", :total=>119981191168, :free=>52424663040, :available=>52424663040, :used=>67556528128, :percent_used=>56.31, :percent_free=>43.69, :percent_available=>43.69}
|
308
321
|
|
309
322
|
# File: mounts.rb | Line: 137
|
310
323
|
# Definition: def devices_stat
|
@@ -358,7 +371,7 @@ LinuxStat::Mounts.tmpfs()
|
|
358
371
|
# File: net.rb | Line: 80
|
359
372
|
# Definition: def usage(interval = 0.1)
|
360
373
|
LinuxStat::Net.current_usage(interval)
|
361
|
-
=> {:received=>
|
374
|
+
=> {:received=>61200.0, :transmitted=>1880.0}
|
362
375
|
|
363
376
|
# File: net.rb | Line: 10
|
364
377
|
# Definition: def ipv4_private
|
@@ -368,22 +381,22 @@ LinuxStat::Net.ipv4_private()
|
|
368
381
|
# File: net.rb | Line: 23
|
369
382
|
# Definition: def total_bytes
|
370
383
|
LinuxStat::Net.total_bytes()
|
371
|
-
=> {:received=>
|
384
|
+
=> {:received=>1112357335, :transmitted=>289215998}
|
372
385
|
|
373
386
|
# File: net.rb | Line: 41
|
374
387
|
# Definition: def total_bytes_received
|
375
388
|
LinuxStat::Net.total_bytes_received()
|
376
|
-
=>
|
389
|
+
=> 1112357335
|
377
390
|
|
378
391
|
# File: net.rb | Line: 54
|
379
392
|
# Definition: def total_bytes_transmitted
|
380
393
|
LinuxStat::Net.total_bytes_transmitted()
|
381
|
-
=>
|
394
|
+
=> 289215998
|
382
395
|
|
383
396
|
# File: net.rb | Line: 80
|
384
397
|
# Definition: def usage(interval = 0.1)
|
385
398
|
LinuxStat::Net.usage(interval)
|
386
|
-
=> {:received=>
|
399
|
+
=> {:received=>61200.0, :transmitted=>1880.0}
|
387
400
|
|
388
401
|
```
|
389
402
|
|
@@ -427,7 +440,7 @@ LinuxStat::OS.os_release()
|
|
427
440
|
# File: os.rb | Line: 110
|
428
441
|
# Definition: def uptime
|
429
442
|
LinuxStat::OS.uptime()
|
430
|
-
=> {:hour=>
|
443
|
+
=> {:hour=>10, :minute=>49, :second=>25.48}
|
431
444
|
|
432
445
|
```
|
433
446
|
|
@@ -435,23 +448,23 @@ LinuxStat::OS.uptime()
|
|
435
448
|
```
|
436
449
|
# File: prettify_bytes.rb | Line: 42
|
437
450
|
# Definition: def convert_binary(n)
|
438
|
-
LinuxStat::PrettifyBytes.convert_binary(n =
|
439
|
-
=> "
|
451
|
+
LinuxStat::PrettifyBytes.convert_binary(n = 304432464364884)
|
452
|
+
=> "276.88 tebibytes"
|
440
453
|
|
441
454
|
# File: prettify_bytes.rb | Line: 19
|
442
455
|
# Definition: def convert_decimal(n)
|
443
|
-
LinuxStat::PrettifyBytes.convert_decimal(n =
|
444
|
-
=> "
|
456
|
+
LinuxStat::PrettifyBytes.convert_decimal(n = 49306758655424)
|
457
|
+
=> "49.31 terabytes"
|
445
458
|
|
446
459
|
# File: prettify_bytes.rb | Line: 90
|
447
460
|
# Definition: def convert_short_binary(n)
|
448
|
-
LinuxStat::PrettifyBytes.convert_short_binary(n =
|
449
|
-
=> "
|
461
|
+
LinuxStat::PrettifyBytes.convert_short_binary(n = 361176129377179)
|
462
|
+
=> "328.49 TiB"
|
450
463
|
|
451
464
|
# File: prettify_bytes.rb | Line: 65
|
452
465
|
# Definition: def convert_short_decimal(n)
|
453
|
-
LinuxStat::PrettifyBytes.convert_short_decimal(n =
|
454
|
-
=> "
|
466
|
+
LinuxStat::PrettifyBytes.convert_short_decimal(n = 293690574885959)
|
467
|
+
=> "293.69 TB"
|
455
468
|
|
456
469
|
```
|
457
470
|
|
@@ -460,12 +473,12 @@ LinuxStat::PrettifyBytes.convert_short_decimal(n = 723831850276707)
|
|
460
473
|
# File: process.rb | Line: 19
|
461
474
|
# Definition: def count
|
462
475
|
LinuxStat::Process.count()
|
463
|
-
=>
|
476
|
+
=> 215
|
464
477
|
|
465
478
|
# File: process.rb | Line: 71
|
466
479
|
# Definition: def idle
|
467
480
|
LinuxStat::Process.idle()
|
468
|
-
=> [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 119, 121, 131, 134, 140, 152, 153, 169, 171, 173, 174, 177, 178, 183, 184, 185, 186, 187, 188, 231, 271, 373, 383,
|
481
|
+
=> [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 119, 121, 131, 134, 140, 152, 153, 169, 171, 173, 174, 177, 178, 183, 184, 185, 186, 187, 188, 231, 271, 373, 383, 18595, 21393, 21394, 21395, 21396, 21397, 21398,...
|
469
482
|
|
470
483
|
# File: process.rb | Line: 8
|
471
484
|
# Definition: def list
|
@@ -480,7 +493,7 @@ LinuxStat::Process.names()
|
|
480
493
|
# File: process.rb | Line: 97
|
481
494
|
# Definition: def running
|
482
495
|
LinuxStat::Process.running()
|
483
|
-
=> [
|
496
|
+
=> [25641, 33756]
|
484
497
|
|
485
498
|
# File: process.rb | Line: 58
|
486
499
|
# Definition: def sleeping
|
@@ -512,41 +525,41 @@ LinuxStat::ProcessInfo.command_name(pid)
|
|
512
525
|
=> "ruby"
|
513
526
|
|
514
527
|
# File: process_info.rb | Line: 247
|
515
|
-
# Definition: def cpu_stat(pid: $$, sleep:
|
528
|
+
# Definition: def cpu_stat(pid: $$, sleep: ticks_to_ms_t5)
|
516
529
|
LinuxStat::ProcessInfo.cpu_stat(pid:, sleep:)
|
517
|
-
=> {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>
|
530
|
+
=> {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>2}
|
518
531
|
|
519
532
|
# File: process_info.rb | Line: 301
|
520
|
-
# Definition: def cpu_usage(pid: $$, sleep:
|
533
|
+
# Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
|
521
534
|
LinuxStat::ProcessInfo.cpu_usage(pid:, sleep:)
|
522
535
|
=> 0.0
|
523
536
|
|
524
|
-
# File: process_info.rb | Line:
|
537
|
+
# File: process_info.rb | Line: 454
|
525
538
|
# Definition: def gid(pid = $$)
|
526
539
|
LinuxStat::ProcessInfo.gid(pid)
|
527
540
|
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
528
541
|
|
529
|
-
# File: process_info.rb | Line:
|
542
|
+
# File: process_info.rb | Line: 417
|
530
543
|
# Definition: def last_executed_cpu(pid = $$)
|
531
544
|
LinuxStat::ProcessInfo.last_executed_cpu(pid)
|
532
|
-
=>
|
545
|
+
=> 2
|
533
546
|
|
534
547
|
# File: process_info.rb | Line: 114
|
535
548
|
# Definition: def mem_stat(pid = $$)
|
536
549
|
LinuxStat::ProcessInfo.mem_stat(pid)
|
537
|
-
=> {:memory=>
|
550
|
+
=> {:memory=>12292.096, :virtual_memory=>84049.92, :resident_memory=>18128.896}
|
538
551
|
|
539
552
|
# File: process_info.rb | Line: 147
|
540
553
|
# Definition: def memory(pid = $$)
|
541
554
|
LinuxStat::ProcessInfo.memory(pid)
|
542
|
-
=>
|
555
|
+
=> 12292.096
|
543
556
|
|
544
|
-
# File: process_info.rb | Line:
|
557
|
+
# File: process_info.rb | Line: 588
|
545
558
|
# Definition: def nice(pid = $$)
|
546
559
|
LinuxStat::ProcessInfo.nice(pid)
|
547
560
|
=> 0
|
548
561
|
|
549
|
-
# File: process_info.rb | Line:
|
562
|
+
# File: process_info.rb | Line: 475
|
550
563
|
# Definition: def owner(pid = $$)
|
551
564
|
LinuxStat::ProcessInfo.owner(pid)
|
552
565
|
=> "sourav"
|
@@ -554,29 +567,34 @@ LinuxStat::ProcessInfo.owner(pid)
|
|
554
567
|
# File: process_info.rb | Line: 197
|
555
568
|
# Definition: def resident_memory(pid = $$)
|
556
569
|
LinuxStat::ProcessInfo.resident_memory(pid)
|
557
|
-
=>
|
570
|
+
=> 18128.896
|
558
571
|
|
559
|
-
# File: process_info.rb | Line:
|
572
|
+
# File: process_info.rb | Line: 545
|
560
573
|
# Definition: def running_time(pid = $$)
|
561
574
|
LinuxStat::ProcessInfo.running_time(pid)
|
562
|
-
=> 1.
|
575
|
+
=> 1.639999999999418
|
563
576
|
|
564
|
-
# File: process_info.rb | Line:
|
577
|
+
# File: process_info.rb | Line: 528
|
565
578
|
# Definition: def start_time(pid = $$)
|
566
579
|
LinuxStat::ProcessInfo.start_time(pid)
|
567
|
-
=> 2020-12-17
|
580
|
+
=> 2020-12-17 21:56:57 +0530
|
568
581
|
|
569
|
-
# File: process_info.rb | Line:
|
582
|
+
# File: process_info.rb | Line: 497
|
570
583
|
# Definition: def start_time_epoch(pid = $$)
|
571
584
|
LinuxStat::ProcessInfo.start_time_epoch(pid)
|
572
|
-
=>
|
585
|
+
=> 1608222417
|
573
586
|
|
574
|
-
# File: process_info.rb | Line:
|
587
|
+
# File: process_info.rb | Line: 573
|
575
588
|
# Definition: def state(pid = $$)
|
576
589
|
LinuxStat::ProcessInfo.state(pid)
|
577
590
|
=> "R"
|
578
591
|
|
579
|
-
# File: process_info.rb | Line:
|
592
|
+
# File: process_info.rb | Line: 349
|
593
|
+
# Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
|
594
|
+
LinuxStat::ProcessInfo.thread_usage(pid:, sleep:)
|
595
|
+
=> 0.0
|
596
|
+
|
597
|
+
# File: process_info.rb | Line: 392
|
580
598
|
# Definition: def threads(pid = $$)
|
581
599
|
LinuxStat::ProcessInfo.threads(pid)
|
582
600
|
=> 1
|
@@ -584,9 +602,9 @@ LinuxStat::ProcessInfo.threads(pid)
|
|
584
602
|
# File: process_info.rb | Line: 23
|
585
603
|
# Definition: def total_io(pid = $$)
|
586
604
|
LinuxStat::ProcessInfo.total_io(pid)
|
587
|
-
=> {:read_bytes=>
|
605
|
+
=> {:read_bytes=>253952, :write_bytes=>0}
|
588
606
|
|
589
|
-
# File: process_info.rb | Line:
|
607
|
+
# File: process_info.rb | Line: 430
|
590
608
|
# Definition: def uid(pid = $$)
|
591
609
|
LinuxStat::ProcessInfo.uid(pid)
|
592
610
|
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
@@ -594,7 +612,7 @@ LinuxStat::ProcessInfo.uid(pid)
|
|
594
612
|
# File: process_info.rb | Line: 172
|
595
613
|
# Definition: def virtual_memory(pid = $$)
|
596
614
|
LinuxStat::ProcessInfo.virtual_memory(pid)
|
597
|
-
=>
|
615
|
+
=> 84049.92
|
598
616
|
|
599
617
|
```
|
600
618
|
|
@@ -608,27 +626,27 @@ LinuxStat::Swap.any?()
|
|
608
626
|
# File: swap.rb | Line: 68
|
609
627
|
# Definition: def available
|
610
628
|
LinuxStat::Swap.available()
|
611
|
-
=>
|
629
|
+
=> 3681532
|
612
630
|
|
613
631
|
# File: swap.rb | Line: 8
|
614
632
|
# Definition: def list
|
615
633
|
LinuxStat::Swap.list()
|
616
|
-
=> {"/dev/zram0"=>[:partition, 4194300,
|
634
|
+
=> {"/dev/zram0"=>[:partition, 4194300, 512768, -2]}
|
617
635
|
|
618
636
|
# File: swap.rb | Line: 103
|
619
637
|
# Definition: def percent_available
|
620
638
|
LinuxStat::Swap.percent_available()
|
621
|
-
=>
|
639
|
+
=> 87.77
|
622
640
|
|
623
641
|
# File: swap.rb | Line: 89
|
624
642
|
# Definition: def percent_used
|
625
643
|
LinuxStat::Swap.percent_used()
|
626
|
-
=>
|
644
|
+
=> 12.23
|
627
645
|
|
628
646
|
# File: swap.rb | Line: 32
|
629
647
|
# Definition: def stat
|
630
648
|
LinuxStat::Swap.stat()
|
631
|
-
=> {:total=>4194300, :used=>
|
649
|
+
=> {:total=>4194300, :used=>512768, :available=>3681532, :percent_used=>12.23, :percent_available=>87.77}
|
632
650
|
|
633
651
|
# File: swap.rb | Line: 57
|
634
652
|
# Definition: def total
|
@@ -638,7 +656,7 @@ LinuxStat::Swap.total()
|
|
638
656
|
# File: swap.rb | Line: 80
|
639
657
|
# Definition: def used
|
640
658
|
LinuxStat::Swap.used()
|
641
|
-
=>
|
659
|
+
=> 512768
|
642
660
|
|
643
661
|
```
|
644
662
|
|
@@ -647,6 +665,9 @@ LinuxStat::Swap.used()
|
|
647
665
|
LinuxStat::Sysconf.child_max()
|
648
666
|
=> 2000000
|
649
667
|
|
668
|
+
LinuxStat::Sysconf.expr_nest_max()
|
669
|
+
=> 32
|
670
|
+
|
650
671
|
LinuxStat::Sysconf.get_euid()
|
651
672
|
=> 1000
|
652
673
|
|
@@ -665,11 +686,14 @@ LinuxStat::Sysconf.get_user()
|
|
665
686
|
LinuxStat::Sysconf.hostname_max()
|
666
687
|
=> 64
|
667
688
|
|
689
|
+
LinuxStat::Sysconf.line_max()
|
690
|
+
=> 2048
|
691
|
+
|
668
692
|
LinuxStat::Sysconf.login_name_max()
|
669
693
|
=> 256
|
670
694
|
|
671
695
|
LinuxStat::Sysconf.open_max()
|
672
|
-
=>
|
696
|
+
=> 1024
|
673
697
|
|
674
698
|
LinuxStat::Sysconf.pagesize()
|
675
699
|
=> 4096
|
@@ -677,6 +701,12 @@ LinuxStat::Sysconf.pagesize()
|
|
677
701
|
LinuxStat::Sysconf.posix_version()
|
678
702
|
=> 200809
|
679
703
|
|
704
|
+
LinuxStat::Sysconf.processor_configured()
|
705
|
+
=> 4
|
706
|
+
|
707
|
+
LinuxStat::Sysconf.processor_online()
|
708
|
+
=> 4
|
709
|
+
|
680
710
|
LinuxStat::Sysconf.sc_clk_tck()
|
681
711
|
=> 100
|
682
712
|
|
data/ext/fs_stat/fs_stat.c
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
#include <sys/statvfs.h>
|
2
2
|
#include "ruby.h"
|
3
3
|
|
4
|
-
#
|
5
|
-
#pragma
|
4
|
+
#ifdef __GNUC__
|
5
|
+
#pragma GCC optimize ("O3")
|
6
|
+
#pragma GCC diagnostic warning "-Wall"
|
7
|
+
#elif __clang__
|
8
|
+
#pragma clang optimize on
|
9
|
+
#pragma clang diagnostic warning "-Wall"
|
10
|
+
#endif
|
6
11
|
|
7
12
|
static VALUE statfs(VALUE obj, VALUE dir) {
|
8
13
|
struct statvfs buf ;
|
data/ext/sysconf/sysconf.c
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
#include <unistd.h>
|
2
2
|
#include "ruby.h"
|
3
3
|
|
4
|
-
#
|
5
|
-
#pragma
|
4
|
+
#ifdef __GNUC__
|
5
|
+
#pragma GCC optimize ("O3")
|
6
|
+
#pragma GCC diagnostic warning "-Wall"
|
7
|
+
#elif __clang__
|
8
|
+
#pragma clang optimize on
|
9
|
+
#pragma clang diagnostic warning "-Wall"
|
10
|
+
#endif
|
6
11
|
|
7
12
|
static VALUE getTick(VALUE obj) {
|
8
13
|
return INT2FIX(sysconf(_SC_CLK_TCK)) ;
|
@@ -40,6 +45,22 @@ static VALUE getPosixVersion(VALUE obj) {
|
|
40
45
|
return INT2FIX(sysconf(_SC_VERSION)) ;
|
41
46
|
}
|
42
47
|
|
48
|
+
static VALUE getLineMax(VALUE obj) {
|
49
|
+
return INT2FIX(sysconf(_SC_LINE_MAX)) ;
|
50
|
+
}
|
51
|
+
|
52
|
+
static VALUE getExprNestMax(VALUE obj) {
|
53
|
+
return INT2FIX(sysconf(_SC_EXPR_NEST_MAX)) ;
|
54
|
+
}
|
55
|
+
|
56
|
+
VALUE getProcessorConfigured(VALUE obj) {
|
57
|
+
return INT2FIX(sysconf(_SC_NPROCESSORS_CONF)) ;
|
58
|
+
}
|
59
|
+
|
60
|
+
VALUE getProcessorOnline(VALUE obj) {
|
61
|
+
return INT2FIX(sysconf(_SC_NPROCESSORS_ONLN)) ;
|
62
|
+
}
|
63
|
+
|
43
64
|
static VALUE getUser(VALUE obj) {
|
44
65
|
char *name = getlogin() ;
|
45
66
|
return name ? rb_str_new_cstr(name) : rb_str_new_cstr("") ;
|
@@ -70,6 +91,11 @@ void Init_sysconf() {
|
|
70
91
|
rb_define_module_function(_sysconf, "stream_max", getStreamMax, 0) ;
|
71
92
|
rb_define_module_function(_sysconf, "tty_name_max", getTTYNameMax, 0) ;
|
72
93
|
rb_define_module_function(_sysconf, "posix_version", getPosixVersion, 0) ;
|
94
|
+
rb_define_module_function(_sysconf, "line_max", getLineMax, 0) ;
|
95
|
+
rb_define_module_function(_sysconf, "expr_nest_max", getExprNestMax, 0) ;
|
96
|
+
|
97
|
+
rb_define_module_function(_sysconf, "processor_online", getProcessorOnline, 0) ;
|
98
|
+
rb_define_module_function(_sysconf, "processor_configured", getProcessorConfigured, 0) ;
|
73
99
|
|
74
100
|
rb_define_module_function(_sysconf, "get_uid", getUID, 0) ;
|
75
101
|
rb_define_module_function(_sysconf, "get_gid", getGID, 0) ;
|
data/ext/utsname/utsname.c
CHANGED
@@ -1,39 +1,49 @@
|
|
1
1
|
#include <sys/utsname.h>
|
2
2
|
#include "ruby.h"
|
3
3
|
|
4
|
-
#
|
5
|
-
#pragma
|
4
|
+
#ifdef __GNUC__
|
5
|
+
#pragma GCC optimize ("O3")
|
6
|
+
#pragma GCC diagnostic warning "-Wall"
|
7
|
+
#elif __clang__
|
8
|
+
#pragma clang optimize on
|
9
|
+
#pragma clang diagnostic warning "-Wall"
|
10
|
+
#endif
|
6
11
|
|
7
12
|
static struct utsname buf ;
|
8
|
-
|
13
|
+
|
14
|
+
static char *sysname = "", *nodename = "" ;
|
15
|
+
static char *release = "", *version = "", *machine = "" ;
|
9
16
|
|
10
17
|
void init_buf() {
|
11
|
-
status = uname(&buf) ;
|
18
|
+
short status = uname(&buf) ;
|
19
|
+
|
20
|
+
if (status > -1) {
|
21
|
+
sysname = buf.sysname ;
|
22
|
+
nodename = buf.nodename ;
|
23
|
+
release = buf.release ;
|
24
|
+
version = buf.version ;
|
25
|
+
machine = buf.machine ;
|
26
|
+
}
|
12
27
|
}
|
13
28
|
|
14
29
|
static VALUE getSysname(VALUE obj) {
|
15
|
-
|
16
|
-
return sysname ;
|
30
|
+
return rb_str_new_cstr(sysname) ;
|
17
31
|
}
|
18
32
|
|
19
33
|
static VALUE getNodename(VALUE obj) {
|
20
|
-
|
21
|
-
return nodename ;
|
34
|
+
return rb_str_new_cstr(nodename) ;
|
22
35
|
}
|
23
36
|
|
24
37
|
static VALUE getRelease(VALUE obj) {
|
25
|
-
|
26
|
-
return release ;
|
38
|
+
return rb_str_new_cstr(release) ;
|
27
39
|
}
|
28
40
|
|
29
41
|
static VALUE getVersion(VALUE obj) {
|
30
|
-
|
31
|
-
return version ;
|
42
|
+
return rb_str_new_cstr(version) ;
|
32
43
|
}
|
33
44
|
|
34
45
|
static VALUE getMachine(VALUE obj) {
|
35
|
-
|
36
|
-
return machine ;
|
46
|
+
return rb_str_new_cstr(machine) ;
|
37
47
|
}
|
38
48
|
|
39
49
|
void Init_utsname() {
|
data/lib/linux_stat/cpu.rb
CHANGED
@@ -25,7 +25,7 @@ module LinuxStat
|
|
25
25
|
sleep(sleep)
|
26
26
|
data2 = IO.readlines('/proc/stat').select! { |x| x[/^cpu\d*/] }.map! { |x| x.split.map!(&:to_f) }
|
27
27
|
|
28
|
-
# On devices like android, the core count can change anytime.
|
28
|
+
# On devices like android, the core count can change anytime (hotplugging).
|
29
29
|
# I had crashes on Termux.
|
30
30
|
# So better just count the min number of CPU and iterate over that
|
31
31
|
# If data.length is smaller than data2.length, we don't have enough data to compare.
|
@@ -76,12 +76,27 @@ module LinuxStat
|
|
76
76
|
end
|
77
77
|
|
78
78
|
##
|
79
|
-
# Returns the total number of CPU threads.
|
79
|
+
# Returns the total number of CPU threads online now.
|
80
|
+
#
|
81
|
+
# This value can change while a CPU is offline, due to kernel's hotplugging feature.
|
82
|
+
#
|
83
|
+
# If the information isn't available, it will return 0.
|
84
|
+
def online
|
85
|
+
# Let's rely on sysconf(_SC_NPROCESSORS_CONF), which is 100x faster than
|
86
|
+
# counting online cpu from /sys/devices/system/cpu
|
87
|
+
|
88
|
+
LinuxStat::Sysconf.processor_configured
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# Returns the total number of CPU threads configured for the sysetm.
|
80
93
|
#
|
81
94
|
# If the information isn't available, it will return 0.
|
82
95
|
def count
|
83
|
-
#
|
84
|
-
|
96
|
+
# Let's rely on sysconf(_SC_NPROCESSORS_ONLN), which is 100x faster than running:
|
97
|
+
# IO.read('/sys/devices/system/cpu/online')[-2].to_i + 1
|
98
|
+
|
99
|
+
LinuxStat::Sysconf.processor_online
|
85
100
|
end
|
86
101
|
|
87
102
|
##
|
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: 0.
|
4
|
+
version: 0.8.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: 2020-12-
|
11
|
+
date: 2020-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Linux only, efficient linux system utilization reporting and system monitoring
|
14
14
|
gem
|