linux_stat 0.2.1 → 0.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 +227 -46
- data/bin/linuxstat.rb +3 -1
- data/ext/fs_stat/extconf.rb +7 -0
- data/ext/fs_stat/fs_stat.c +31 -0
- data/ext/sysconf/extconf.rb +7 -0
- data/ext/sysconf/sysconf.c +53 -0
- data/ext/utsname/extconf.rb +7 -0
- data/ext/utsname/utsname.c +49 -0
- data/lib/linux_stat.rb +11 -5
- data/lib/linux_stat/battery.rb +2 -2
- data/lib/linux_stat/bios.rb +10 -6
- data/lib/linux_stat/cpu.rb +31 -6
- data/lib/linux_stat/filesystem.rb +92 -0
- data/lib/linux_stat/kernel.rb +17 -6
- data/lib/linux_stat/memory.rb +8 -2
- data/lib/linux_stat/mounts.rb +64 -0
- data/lib/linux_stat/os.rb +27 -8
- data/lib/linux_stat/process_info.rb +310 -0
- data/lib/linux_stat/swap.rb +6 -1
- data/lib/linux_stat/version.rb +1 -1
- metadata +16 -5
- data/Gemfile +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4f9b433758109c632c7b6358b1fd6c5cda1711e1ab6b8f4a3dae0ce6cc02f6d
|
4
|
+
data.tar.gz: c0273b6cf31ae022adfeb4b9e041426de2841899d08be49f3559ab98175be54d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e7b971800222420d9156a791de5857331c923149416a7d4b5d025d57bbb7e9d3ccea8ec47d2236f308a8675bfbcf5d0a2ee0380dab92afed29dc0ace8dcb577
|
7
|
+
data.tar.gz: 7583db616fff644f2798fe779b23ed28cc762eac3d6d8aad0e4c907b21813bcaacc058570516378e7cdf495a51b4906bb5a30221ebb60536af72d91b2795a147
|
data/README.md
CHANGED
@@ -1,10 +1,31 @@
|
|
1
1
|
# LinuxStat
|
2
|
-

|
3
|
+
|
4
|
+
For reading the HTML version, visit [linux_stat](https://souravgoswami.github.io/linux_stat/).
|
3
5
|
|
4
6
|
LinuxStat lets you read status of a Linux system. It can show you cpu stats and usages, memory stats and usages, swap stats and usages, battery usage, bios info, kernel details, local ip, os details and parse os-release + lsb-release, etc.
|
5
7
|
|
6
8
|
It only works for Linux, and detecting the OS is upto the user of this gem.
|
7
9
|
|
10
|
+
## Dependencies:
|
11
|
+
+ You need to have the C compile to be able to compile the C extension.
|
12
|
+
On Arch Linux:
|
13
|
+
```
|
14
|
+
# pacman -S gcc
|
15
|
+
```
|
16
|
+
|
17
|
+
On Debian based systems:
|
18
|
+
```
|
19
|
+
# apt install gcc
|
20
|
+
```
|
21
|
+
|
22
|
+
+ You might also require ruby-dev in Debian based systems which provides support for ruby.h header file:
|
23
|
+
```
|
24
|
+
# apt install ruby-dev
|
25
|
+
```
|
26
|
+
|
27
|
+
+ Once your are done, and you can compile the C file, you can follow the installation!
|
28
|
+
|
8
29
|
## Installation
|
9
30
|
|
10
31
|
Add this line to your application's Gemfile:
|
@@ -78,7 +99,7 @@ LinuxStat::CPU.count
|
|
78
99
|
=> 4
|
79
100
|
|
80
101
|
LinuxStat::CPU.cur_freq
|
81
|
-
=> [
|
102
|
+
=> [1999998, 2000003, 2000015, 2000009]
|
82
103
|
|
83
104
|
LinuxStat::CPU.max_freq
|
84
105
|
=> [2000000, 2000000, 2000000, 2000000]
|
@@ -87,16 +108,38 @@ LinuxStat::CPU.model
|
|
87
108
|
=> "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
|
88
109
|
|
89
110
|
LinuxStat::CPU.stat
|
90
|
-
=> {0=>
|
111
|
+
=> {0=>14.29, 1=>25.0, 2=>0.0, 3=>25.0, 4=>14.29}
|
91
112
|
|
92
113
|
LinuxStat::CPU.total_usage
|
93
|
-
=>
|
114
|
+
=> 18.75
|
94
115
|
|
95
116
|
LinuxStat::CPU.usage
|
96
|
-
=>
|
117
|
+
=> 14.29
|
97
118
|
|
98
119
|
LinuxStat::CPU.usages
|
99
|
-
=> {0=>
|
120
|
+
=> {0=>16.67, 1=>14.29, 2=>28.57, 3=>0.0, 4=>25.0}
|
121
|
+
|
122
|
+
```
|
123
|
+
|
124
|
+
### LinuxStat::Filesystem
|
125
|
+
```
|
126
|
+
LinuxStat::Filesystem.available
|
127
|
+
=> 42144575488
|
128
|
+
|
129
|
+
LinuxStat::Filesystem.free
|
130
|
+
=> 42144575488
|
131
|
+
|
132
|
+
LinuxStat::Filesystem.stat
|
133
|
+
=> {:total=>119981191168, :free=>42144575488, :used=>77836615680}
|
134
|
+
|
135
|
+
LinuxStat::Filesystem.stat_raw
|
136
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>10289203, :block_avail_unpriv=>10289203, :inodes=>58612160, :free_inodes=>56716465, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
137
|
+
|
138
|
+
LinuxStat::Filesystem.total
|
139
|
+
=> 119981191168
|
140
|
+
|
141
|
+
LinuxStat::Filesystem.used
|
142
|
+
=> 77836615680
|
100
143
|
|
101
144
|
```
|
102
145
|
|
@@ -111,15 +154,24 @@ LinuxStat::Kernel.build_date_string
|
|
111
154
|
LinuxStat::Kernel.build_user
|
112
155
|
=> "souravgoswami@archlinux"
|
113
156
|
|
157
|
+
LinuxStat::Kernel.clk_tck
|
158
|
+
=> 100
|
159
|
+
|
114
160
|
LinuxStat::Kernel.compiler
|
115
161
|
=> [:gcc, "10.2.0"]
|
116
162
|
|
117
163
|
LinuxStat::Kernel.compiler_version
|
118
164
|
=> "10.2.0"
|
119
165
|
|
166
|
+
LinuxStat::Kernel.release
|
167
|
+
=> "5.9.1-xanmod1-1"
|
168
|
+
|
120
169
|
LinuxStat::Kernel.string
|
121
170
|
=> "Linux version 5.9.1-xanmod1-1 (souravgoswami@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Wed, 21 Oct 2020 01:11:20 +0000"
|
122
171
|
|
172
|
+
LinuxStat::Kernel.ticks
|
173
|
+
=> 100
|
174
|
+
|
123
175
|
LinuxStat::Kernel.version
|
124
176
|
=> "5.9.1-xanmod1-1"
|
125
177
|
|
@@ -128,29 +180,48 @@ LinuxStat::Kernel.version
|
|
128
180
|
### LinuxStat::Memory
|
129
181
|
```
|
130
182
|
LinuxStat::Memory.available
|
131
|
-
=>
|
183
|
+
=> 606548
|
132
184
|
|
133
185
|
LinuxStat::Memory.percent_available
|
134
|
-
=>
|
186
|
+
=> 15.81
|
135
187
|
|
136
188
|
LinuxStat::Memory.percent_used
|
137
|
-
=>
|
189
|
+
=> 84.19
|
138
190
|
|
139
191
|
LinuxStat::Memory.stat
|
140
|
-
=> {:total=>
|
192
|
+
=> {:total=>3836256, :used=>3229708, :available=>606548, :percent_used=>84.19, :percent_available=>15.81}
|
141
193
|
|
142
194
|
LinuxStat::Memory.total
|
143
|
-
=>
|
195
|
+
=> 3836256
|
144
196
|
|
145
197
|
LinuxStat::Memory.used
|
146
|
-
=>
|
198
|
+
=> 3229708
|
199
|
+
|
200
|
+
```
|
201
|
+
|
202
|
+
### LinuxStat::Mounts
|
203
|
+
```
|
204
|
+
LinuxStat::Mounts.list
|
205
|
+
=> ["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=1891804k,nr_inodes=472951,mode=755 0 0", "run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0", "...
|
206
|
+
|
207
|
+
LinuxStat::Mounts.root
|
208
|
+
=> "/dev/sda2"
|
209
|
+
|
210
|
+
LinuxStat::Mounts.root_fs
|
211
|
+
=> "xfs"
|
212
|
+
|
213
|
+
LinuxStat::Mounts.root_mount_options
|
214
|
+
=> "rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota"
|
215
|
+
|
216
|
+
LinuxStat::Mounts.tmpfs
|
217
|
+
=> {"/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", "/cache"=>"tmpfs /cache tmpfs rw,nosuid,nodev,relatime,size=2097152k 0 0", "/ramdisk...
|
147
218
|
|
148
219
|
```
|
149
220
|
|
150
221
|
### LinuxStat::Net
|
151
222
|
```
|
152
223
|
LinuxStat::Net.ipv4_private
|
153
|
-
=> "192.168.0.
|
224
|
+
=> "192.168.0.101"
|
154
225
|
|
155
226
|
```
|
156
227
|
|
@@ -168,33 +239,39 @@ LinuxStat::OS.hostname
|
|
168
239
|
LinuxStat::OS.lsb_release
|
169
240
|
=> {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
|
170
241
|
|
242
|
+
LinuxStat::OS.machine
|
243
|
+
=> "x86_64"
|
244
|
+
|
245
|
+
LinuxStat::OS.nodename
|
246
|
+
=> "archlinux"
|
247
|
+
|
171
248
|
LinuxStat::OS.os_release
|
172
249
|
=> {:NAME=>"Arch Linux", :PRETTY_NAME=>"Arch Linux", :ID=>"arch", :BUILD_ID=>"rolling", :ANSI_COLOR=>"38;2;23;147;209", :HOME_URL=>"https://www.archlinux.org/", :DOCUMENTATION_URL=>"https://wiki.archlinux.org/", :SUPPORT_URL=>"https://bbs.archlinux.org/"...
|
173
250
|
|
174
251
|
LinuxStat::OS.uptime
|
175
|
-
=> {:hour=>
|
252
|
+
=> {:hour=>9, :minute=>10, :second=>19.41}
|
176
253
|
|
177
254
|
```
|
178
255
|
|
179
256
|
### LinuxStat::Process
|
180
257
|
```
|
181
258
|
LinuxStat::Process.count
|
182
|
-
=>
|
259
|
+
=> 221
|
183
260
|
|
184
261
|
LinuxStat::Process.idle
|
185
|
-
=> [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 120, 122, 131, 134, 140, 152, 153,
|
262
|
+
=> [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 120, 122, 131, 134, 140, 152, 153, 168, 170, 173, 174, 182, 183, 184, 185, 186, 187, 214, 224, 268, 308, 313, 314, 330, 2357, 2358, 2359, 2360, 2361, 2362, 25094, 2...
|
186
263
|
|
187
264
|
LinuxStat::Process.list
|
188
|
-
=> [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,
|
265
|
+
=> [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, 112, 114, 115, 117, 118, 120, 122, 131, 134,...
|
189
266
|
|
190
267
|
LinuxStat::Process.names
|
191
|
-
=> {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=>"
|
268
|
+
=> {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...
|
192
269
|
|
193
270
|
LinuxStat::Process.running
|
194
|
-
=> [
|
271
|
+
=> [30804]
|
195
272
|
|
196
273
|
LinuxStat::Process.sleeping
|
197
|
-
=> [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,
|
274
|
+
=> [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, 167, 169, 188, 215, 228, 307, 309, 311, 316, 317, 319, 320, 354, 355, 356, 357, 364, 368, 370, 384, 397,...
|
198
275
|
|
199
276
|
LinuxStat::Process.types
|
200
277
|
=> {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...
|
@@ -204,45 +281,157 @@ LinuxStat::Process.zombie
|
|
204
281
|
|
205
282
|
```
|
206
283
|
|
284
|
+
### LinuxStat::ProcessInfo
|
285
|
+
```
|
286
|
+
LinuxStat::ProcessInfo.cmdline
|
287
|
+
=> "ruby bin/linuxstat.rb -md"
|
288
|
+
|
289
|
+
LinuxStat::ProcessInfo.command_name
|
290
|
+
=> "ruby"
|
291
|
+
|
292
|
+
LinuxStat::ProcessInfo.cpu_stat
|
293
|
+
=> {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>2}
|
294
|
+
|
295
|
+
LinuxStat::ProcessInfo.cpu_usage
|
296
|
+
=> 0.0
|
297
|
+
|
298
|
+
LinuxStat::ProcessInfo.last_executed_cpu
|
299
|
+
=> 2
|
300
|
+
|
301
|
+
LinuxStat::ProcessInfo.mem_stat
|
302
|
+
=> {:memory=>9644, :virtual_memory=>79568, :resident_memory=>15764}
|
303
|
+
|
304
|
+
LinuxStat::ProcessInfo.memory
|
305
|
+
=> 9644
|
306
|
+
|
307
|
+
LinuxStat::ProcessInfo.resident_memory
|
308
|
+
=> 15764
|
309
|
+
|
310
|
+
LinuxStat::ProcessInfo.threads
|
311
|
+
=> 1
|
312
|
+
|
313
|
+
LinuxStat::ProcessInfo.total_io
|
314
|
+
=> {:read_bytes=>0, :write_bytes=>0}
|
315
|
+
|
316
|
+
LinuxStat::ProcessInfo.virtual_memory
|
317
|
+
=> 79568
|
318
|
+
|
319
|
+
```
|
320
|
+
|
207
321
|
### LinuxStat::Swap
|
208
322
|
```
|
209
323
|
LinuxStat::Swap.any?
|
210
324
|
=> true
|
211
325
|
|
212
326
|
LinuxStat::Swap.available
|
213
|
-
=>
|
327
|
+
=> 2256212
|
214
328
|
|
215
329
|
LinuxStat::Swap.list
|
216
|
-
=> {"/dev/zram0"=>[:partition, 4194300,
|
330
|
+
=> {"/dev/zram0"=>[:partition, 4194300, 1938088, -2]}
|
217
331
|
|
218
332
|
LinuxStat::Swap.percent_available
|
219
|
-
=>
|
333
|
+
=> 53.79
|
220
334
|
|
221
335
|
LinuxStat::Swap.percent_used
|
222
|
-
=>
|
336
|
+
=> 46.21
|
223
337
|
|
224
338
|
LinuxStat::Swap.stat
|
225
|
-
=> {:total=>4194300, :used=>
|
339
|
+
=> {:total=>4194300, :used=>1938088, :available=>2256212, :percent_used=>46.21, :percent_available=>53.79}
|
226
340
|
|
227
341
|
LinuxStat::Swap.total
|
228
342
|
=> 4194300
|
229
343
|
|
230
344
|
LinuxStat::Swap.used
|
231
|
-
=>
|
345
|
+
=> 1938088
|
346
|
+
|
347
|
+
```
|
348
|
+
|
349
|
+
### LinuxStat::Sysconf
|
350
|
+
```
|
351
|
+
LinuxStat::Sysconf.child_max
|
352
|
+
=> 2000000
|
353
|
+
|
354
|
+
LinuxStat::Sysconf.hostname_max
|
355
|
+
=> 64
|
356
|
+
|
357
|
+
LinuxStat::Sysconf.login_name_max
|
358
|
+
=> 256
|
359
|
+
|
360
|
+
LinuxStat::Sysconf.open_max
|
361
|
+
=> 8192
|
362
|
+
|
363
|
+
LinuxStat::Sysconf.page_size_max
|
364
|
+
=> 4096
|
365
|
+
|
366
|
+
LinuxStat::Sysconf.posix_version
|
367
|
+
=> 200809
|
368
|
+
|
369
|
+
LinuxStat::Sysconf.sc_clk_tck
|
370
|
+
=> 100
|
371
|
+
|
372
|
+
LinuxStat::Sysconf.stream_max
|
373
|
+
=> 16
|
374
|
+
|
375
|
+
LinuxStat::Sysconf.tty_name_max
|
376
|
+
=> 32
|
377
|
+
|
378
|
+
```
|
379
|
+
|
380
|
+
### LinuxStat::Uname
|
381
|
+
```
|
382
|
+
LinuxStat::Uname.machine
|
383
|
+
=> "x86_64"
|
384
|
+
|
385
|
+
LinuxStat::Uname.nodename
|
386
|
+
=> "archlinux"
|
387
|
+
|
388
|
+
LinuxStat::Uname.release
|
389
|
+
=> "5.9.1-xanmod1-1"
|
390
|
+
|
391
|
+
LinuxStat::Uname.sysname
|
392
|
+
=> "Linux"
|
393
|
+
|
394
|
+
LinuxStat::Uname.version
|
395
|
+
=> "#1 SMP PREEMPT Wed, 21 Oct 2020 01:11:20 +0000"
|
232
396
|
|
233
397
|
```
|
234
398
|
|
235
|
-
|
236
|
-
In general, if a method returns either a Float or a Integer or a Time, it will return
|
237
|
-
|
238
|
-
If the method returns a
|
399
|
+
## Return Types
|
400
|
+
+ In general, if a method returns either a Float or a Integer or a Time, it will return a Float or Integer or Time in all cases. But if the status isn't available, it will return nil.
|
401
|
+
|
402
|
+
+ If the method returns a Hash / Array, it will return return Hash / Array in all cases. If the status isn't available, it will return an empty Hash / Array.
|
403
|
+
|
404
|
+
+ If the method returns a String, it will return return String in all cases. If the status isn't available, it will return an empty *frozen* String.
|
405
|
+
|
406
|
+
+ It doesn't have implementation of any Error that gets raised in runtime for the ease of use.
|
239
407
|
|
240
|
-
|
241
|
-
If you need to check some stat that returns an integer or float, and you get nil, you know it's not available, so you can work accordingly.
|
242
|
-
But if you need the integer or float value in 0 to whatever format, you can use the .to_i or .to_f method on the object, nil will get converted to number then.
|
408
|
+
+ If you need to check some stat that returns an integer or float, and you get nil, you know it's not available, so you can work accordingly. But if you need the integer or float value in 0 to whatever format, you can use the .to_i or .to_f method on the object, nil will get converted to number then.
|
243
409
|
|
244
410
|
If some error is *raised* it should be reported as a bug.
|
245
411
|
|
412
|
+
## Ruby on Rails
|
413
|
+
|
414
|
+
1. Just add `gem linux_stat`:
|
415
|
+
|
416
|
+
```
|
417
|
+
$ bundle add linux_stat
|
418
|
+
```
|
419
|
+
|
420
|
+
You can use LinuxStat directly in rails.
|
421
|
+
|
422
|
+

|
423
|
+
|
424
|
+
|
425
|
+
## Android
|
426
|
+
|
427
|
+
LinuxStat does support Android OS. But it's not rigorously tested on all device like android apps.
|
428
|
+
|
429
|
+
But in Termux you can just run LinuxStat without facing issues.
|
430
|
+
|
431
|
+

|
432
|
+
|
433
|
+
Issues regarding running LinuxStat on termux are also welcomed.
|
434
|
+
|
246
435
|
## Development
|
247
436
|
|
248
437
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -254,34 +443,26 @@ Like other gems, this doesn't have a test like RSpec. We suggest using the bin/l
|
|
254
443
|
If you need to test a specific module, say the CPU, just run it like this:
|
255
444
|
|
256
445
|
```
|
257
|
-
ruby bin/linuxstat.rb CPU
|
446
|
+
$ ruby bin/linuxstat.rb CPU
|
258
447
|
```
|
259
448
|
|
260
449
|
Or:
|
261
450
|
```
|
262
|
-
ruby bin/linuxstat.rb cpu
|
451
|
+
$ ruby bin/linuxstat.rb cpu
|
263
452
|
```
|
264
453
|
|
265
454
|
That is, the argument passed is not case-sensitive.
|
266
|
-
But if the
|
455
|
+
But if the argument passed isn't available and outright wrong, it will run all the module methods. For example, you can't do:
|
267
456
|
|
268
457
|
```
|
269
|
-
ruby bin/linuxstat.rb upc
|
458
|
+
$ ruby bin/linuxstat.rb upc
|
270
459
|
```
|
271
|
-
|
272
|
-
You can run `rake` to test all the modules.
|
273
|
-
You can also use `rake cpu` to test the CPU module or `rake memory` to test the memory module. But this is case-sensitive.
|
274
|
-
|
275
460
|
This is not a valid module and can't be run.
|
276
461
|
|
277
462
|
## Contributing
|
278
463
|
|
279
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/Souravgoswami/linux_stat.
|
464
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Souravgoswami/linux_stat.
|
280
465
|
|
281
466
|
## License
|
282
467
|
|
283
468
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
284
|
-
|
285
|
-
## Code of Conduct
|
286
|
-
|
287
|
-
Everyone interacting in the LinuxStat project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Souravgoswami/linux_stat/blob/master/CODE_OF_CONDUCT.md).
|
data/bin/linuxstat.rb
CHANGED
@@ -29,6 +29,7 @@ execute.sort.each do |c|
|
|
29
29
|
next if e.class != Module && e.class != Class
|
30
30
|
|
31
31
|
meths = e.methods(false).sort
|
32
|
+
next if meths.any? { |a| e.method(a).arity > 0 }
|
32
33
|
|
33
34
|
if meths.length > 0
|
34
35
|
if MARKDOWN
|
@@ -41,7 +42,8 @@ execute.sort.each do |c|
|
|
41
42
|
meths.each do |meth|
|
42
43
|
time = Time.now
|
43
44
|
v = e.send(meth)
|
44
|
-
|
45
|
+
time2 = Time.now
|
46
|
+
time = time2.-(time).*(1_000_000).round(3)
|
45
47
|
|
46
48
|
v = v.inspect
|
47
49
|
dis = v.length > 253 ? v[0..250].strip + '...'.freeze : v
|