linux_stat 0.3.0 → 0.4.2

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: 3e2c68de7353a60dbdff528a65e721cc0f7632e95c5d8db2e0e1dc1b7242deb1
4
- data.tar.gz: ada661cb896983bddf8f831b55822bfb006f6167c1ea2bbbd2319bf38028bd79
3
+ metadata.gz: 62a54b165b53e0fe6fddad20ab6b39b8a0d57e1a02186f995fcf0341cc69aae0
4
+ data.tar.gz: 8bc58cc3c8b72e117892cd8f987c924337d2ab10995d14b3fb7735064e4b3685
5
5
  SHA512:
6
- metadata.gz: 1399f3b227442243558ae76d4cdbc4679f21984b8d7e2aacd7ed25c471d5588e9901877c943d4a2220583f3eb4094b00e81016e6e573ef1038052574e8306fd0
7
- data.tar.gz: 79c25491f4517ef2370b375d19177ca01b6589c6e0931e40dc0aa7c92269b605c97cab4cfe42cde51895ebe9b21d418fd301daf44dfdc496ff0b8bd24788dac6
6
+ metadata.gz: a5490c31315132793840e3e849996f0545b08b3b416eadef3ba6979dcbad89d31329b69dad403295f8cc7e17a677f6d8df032c42706162b251b6ed921a3d11e4
7
+ data.tar.gz: 0100faa162b904042e8143b8dec85b45a3cb82543c693514049df17834890b12034cb1561d8c69ba606e9ebc81fba1550b255ad6d17d70a552011eb9aaf5300f
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # LinuxStat
2
- ![logo](https://raw.githubusercontent.com/Souravgoswami/linux_stat/master/logo/logo.jpg)
2
+ ![logo](https://raw.githubusercontent.com/Souravgoswami/linux_stat/master/images/logo.jpg)
3
3
 
4
- For reading the HTML version, visit [linux_stat](https://souravgoswami.github.io/linux_stat/).
4
+ For reading the eyecandy HTML version, visit [linux_stat](https://souravgoswami.github.io/linux_stat/).
5
5
 
6
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.
7
7
 
8
8
  It only works for Linux, and detecting the OS is upto the user of this gem.
9
9
 
10
+ ---
11
+
10
12
  ## Dependencies:
11
13
  + You need to have the C compile to be able to compile the C extension.
12
14
  On Arch Linux:
@@ -26,6 +28,8 @@ On Debian based systems:
26
28
 
27
29
  + Once your are done, and you can compile the C file, you can follow the installation!
28
30
 
31
+ ---
32
+
29
33
  ## Installation
30
34
 
31
35
  Add this line to your application's Gemfile:
@@ -44,7 +48,6 @@ Or install it yourself as:
44
48
 
45
49
  ## Usage
46
50
  ### LinuxStat::BIOS
47
- ### LinuxStat::BIOS
48
51
  ```
49
52
  LinuxStat::BIOS.date
50
53
  => "04/10/2017"
@@ -100,7 +103,7 @@ LinuxStat::CPU.count
100
103
  => 4
101
104
 
102
105
  LinuxStat::CPU.cur_freq
103
- => [1998722, 1998401, 1974377, 1875264]
106
+ => [1999998, 2000003, 2000015, 2000009]
104
107
 
105
108
  LinuxStat::CPU.max_freq
106
109
  => [2000000, 2000000, 2000000, 2000000]
@@ -109,38 +112,38 @@ LinuxStat::CPU.model
109
112
  => "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
110
113
 
111
114
  LinuxStat::CPU.stat
112
- => {0=>6.45, 1=>0.0, 2=>0.0, 3=>12.5, 4=>0.0}
115
+ => {0=>14.29, 1=>25.0, 2=>0.0, 3=>25.0, 4=>14.29}
113
116
 
114
117
  LinuxStat::CPU.total_usage
115
- => 3.45
118
+ => 18.75
116
119
 
117
120
  LinuxStat::CPU.usage
118
- => 6.45
121
+ => 14.29
119
122
 
120
123
  LinuxStat::CPU.usages
121
- => {0=>9.68, 1=>11.11, 2=>12.5, 3=>14.29, 4=>12.5}
124
+ => {0=>16.67, 1=>14.29, 2=>28.57, 3=>0.0, 4=>25.0}
122
125
 
123
126
  ```
124
127
 
125
128
  ### LinuxStat::Filesystem
126
129
  ```
127
130
  LinuxStat::Filesystem.available
128
- => 43155402752
131
+ => 42144575488
129
132
 
130
133
  LinuxStat::Filesystem.free
131
- => 43155402752
134
+ => 42144575488
132
135
 
133
136
  LinuxStat::Filesystem.stat
134
- => {:total=>119981191168, :free=>43155402752, :used=>76825788416}
137
+ => {:total=>119981191168, :free=>42144575488, :used=>77836615680}
135
138
 
136
139
  LinuxStat::Filesystem.stat_raw
137
- => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>10535987, :block_avail_unpriv=>10535987, :inodes=>58612160, :free_inodes=>56718515, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
140
+ => {: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}
138
141
 
139
142
  LinuxStat::Filesystem.total
140
143
  => 119981191168
141
144
 
142
145
  LinuxStat::Filesystem.used
143
- => 76825788416
146
+ => 77836615680
144
147
 
145
148
  ```
146
149
 
@@ -155,15 +158,24 @@ LinuxStat::Kernel.build_date_string
155
158
  LinuxStat::Kernel.build_user
156
159
  => "souravgoswami@archlinux"
157
160
 
161
+ LinuxStat::Kernel.clk_tck
162
+ => 100
163
+
158
164
  LinuxStat::Kernel.compiler
159
165
  => [:gcc, "10.2.0"]
160
166
 
161
167
  LinuxStat::Kernel.compiler_version
162
168
  => "10.2.0"
163
169
 
170
+ LinuxStat::Kernel.release
171
+ => "5.9.1-xanmod1-1"
172
+
164
173
  LinuxStat::Kernel.string
165
174
  => "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"
166
175
 
176
+ LinuxStat::Kernel.ticks
177
+ => 100
178
+
167
179
  LinuxStat::Kernel.version
168
180
  => "5.9.1-xanmod1-1"
169
181
 
@@ -172,29 +184,29 @@ LinuxStat::Kernel.version
172
184
  ### LinuxStat::Memory
173
185
  ```
174
186
  LinuxStat::Memory.available
175
- => 403724
187
+ => 606548
176
188
 
177
189
  LinuxStat::Memory.percent_available
178
- => 10.52
190
+ => 15.81
179
191
 
180
192
  LinuxStat::Memory.percent_used
181
- => 89.48
193
+ => 84.19
182
194
 
183
195
  LinuxStat::Memory.stat
184
- => {:total=>3836264, :used=>3432540, :available=>403724, :percent_used=>89.48, :percent_available=>10.52}
196
+ => {:total=>3836256, :used=>3229708, :available=>606548, :percent_used=>84.19, :percent_available=>15.81}
185
197
 
186
198
  LinuxStat::Memory.total
187
- => 3836264
199
+ => 3836256
188
200
 
189
201
  LinuxStat::Memory.used
190
- => 3432540
202
+ => 3229708
191
203
 
192
204
  ```
193
205
 
194
206
  ### LinuxStat::Mounts
195
207
  ```
196
208
  LinuxStat::Mounts.list
197
- => ["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=1891796k,nr_inodes=472949,mode=755 0 0", "run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0", "...
209
+ => ["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", "...
198
210
 
199
211
  LinuxStat::Mounts.root
200
212
  => "/dev/sda2"
@@ -206,14 +218,14 @@ LinuxStat::Mounts.root_mount_options
206
218
  => "rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota"
207
219
 
208
220
  LinuxStat::Mounts.tmpfs
209
- => {"/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...
221
+ => {"/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...
210
222
 
211
223
  ```
212
224
 
213
225
  ### LinuxStat::Net
214
226
  ```
215
227
  LinuxStat::Net.ipv4_private
216
- => "192.168.0.106"
228
+ => "192.168.0.101"
217
229
 
218
230
  ```
219
231
 
@@ -231,33 +243,39 @@ LinuxStat::OS.hostname
231
243
  LinuxStat::OS.lsb_release
232
244
  => {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
233
245
 
246
+ LinuxStat::OS.machine
247
+ => "x86_64"
248
+
249
+ LinuxStat::OS.nodename
250
+ => "archlinux"
251
+
234
252
  LinuxStat::OS.os_release
235
253
  => {: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/"...
236
254
 
237
255
  LinuxStat::OS.uptime
238
- => {:hour=>10, :minute=>54, :second=>22.45}
256
+ => {:hour=>9, :minute=>10, :second=>19.41}
239
257
 
240
258
  ```
241
259
 
242
260
  ### LinuxStat::Process
243
261
  ```
244
262
  LinuxStat::Process.count
245
- => 210
263
+ => 221
246
264
 
247
265
  LinuxStat::Process.idle
248
- => [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 119, 122, 131, 134, 140, 152, 153, 179, 181, 183, 184, 191, 192, 193, 194, 195, 196, 198, 236, 286, 314, 324, 346, 385, 3540, 3541, 3542, 3543, 3544, 3545, 30463, 3...
266
+ => [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...
249
267
 
250
268
  LinuxStat::Process.list
251
- => [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, 119, 122, 131, 134,...
269
+ => [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,...
252
270
 
253
271
  LinuxStat::Process.names
254
- => {1=>"systemd", 2=>"kthreadd", 3=>"rcu_gp", 4=>"rcu_par_gp", 6=>"kworker/0:0H-events_highpri", 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...
272
+ => {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...
255
273
 
256
274
  LinuxStat::Process.running
257
- => [33736]
275
+ => [30804]
258
276
 
259
277
  LinuxStat::Process.sleeping
260
- => [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, 178, 180, 197, 225, 239, 309, 317, 329, 332, 333, 334, 338, 367, 368, 369, 370, 378, 381, 383, 384, 402,...
278
+ => [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,...
261
279
 
262
280
  LinuxStat::Process.types
263
281
  => {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...
@@ -267,34 +285,236 @@ LinuxStat::Process.zombie
267
285
 
268
286
  ```
269
287
 
288
+ ### LinuxStat::ProcessInfo
289
+ ```
290
+ LinuxStat::ProcessInfo.cmdline
291
+ => "ruby bin/linuxstat.rb -md"
292
+
293
+ LinuxStat::ProcessInfo.command_name
294
+ => "ruby"
295
+
296
+ LinuxStat::ProcessInfo.cpu_stat
297
+ => {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>2}
298
+
299
+ LinuxStat::ProcessInfo.cpu_usage
300
+ => 0.0
301
+
302
+ LinuxStat::ProcessInfo.last_executed_cpu
303
+ => 2
304
+
305
+ LinuxStat::ProcessInfo.mem_stat
306
+ => {:memory=>9644, :virtual_memory=>79568, :resident_memory=>15764}
307
+
308
+ LinuxStat::ProcessInfo.memory
309
+ => 9644
310
+
311
+ LinuxStat::ProcessInfo.resident_memory
312
+ => 15764
313
+
314
+ LinuxStat::ProcessInfo.threads
315
+ => 1
316
+
317
+ LinuxStat::ProcessInfo.total_io
318
+ => {:read_bytes=>0, :write_bytes=>0}
319
+
320
+ LinuxStat::ProcessInfo.virtual_memory
321
+ => 79568
322
+
323
+ ```
324
+
270
325
  ### LinuxStat::Swap
271
326
  ```
272
327
  LinuxStat::Swap.any?
273
328
  => true
274
329
 
275
330
  LinuxStat::Swap.available
276
- => 1913936
331
+ => 2256212
277
332
 
278
333
  LinuxStat::Swap.list
279
- => {"/dev/zram0"=>[:partition, 4194300, 2280364, -2]}
334
+ => {"/dev/zram0"=>[:partition, 4194300, 1938088, -2]}
280
335
 
281
336
  LinuxStat::Swap.percent_available
282
- => 45.63
337
+ => 53.79
283
338
 
284
339
  LinuxStat::Swap.percent_used
285
- => 54.37
340
+ => 46.21
286
341
 
287
342
  LinuxStat::Swap.stat
288
- => {:total=>4194300, :used=>2280364, :available=>1913936, :percent_used=>54.37, :percent_available=>45.63}
343
+ => {:total=>4194300, :used=>1938088, :available=>2256212, :percent_used=>46.21, :percent_available=>53.79}
289
344
 
290
345
  LinuxStat::Swap.total
291
346
  => 4194300
292
347
 
293
348
  LinuxStat::Swap.used
294
- => 2280364
349
+ => 1938088
350
+
351
+ ```
352
+
353
+ ### LinuxStat::Sysconf
354
+ ```
355
+ LinuxStat::Sysconf.child_max
356
+ => 2000000
357
+
358
+ LinuxStat::Sysconf.hostname_max
359
+ => 64
360
+
361
+ LinuxStat::Sysconf.login_name_max
362
+ => 256
363
+
364
+ LinuxStat::Sysconf.open_max
365
+ => 8192
366
+
367
+ LinuxStat::Sysconf.page_size_max
368
+ => 4096
369
+
370
+ LinuxStat::Sysconf.posix_version
371
+ => 200809
372
+
373
+ LinuxStat::Sysconf.sc_clk_tck
374
+ => 100
375
+
376
+ LinuxStat::Sysconf.stream_max
377
+ => 16
378
+
379
+ LinuxStat::Sysconf.tty_name_max
380
+ => 32
381
+
382
+ ```
383
+
384
+ ### LinuxStat::Uname
385
+ ```
386
+ LinuxStat::Uname.machine
387
+ => "x86_64"
388
+
389
+ LinuxStat::Uname.nodename
390
+ => "archlinux"
391
+
392
+ LinuxStat::Uname.release
393
+ => "5.9.1-xanmod1-1"
394
+
395
+ LinuxStat::Uname.sysname
396
+ => "Linux"
397
+
398
+ LinuxStat::Uname.version
399
+ => "#1 SMP PREEMPT Wed, 21 Oct 2020 01:11:20 +0000"
400
+
401
+ ```
402
+ ---
403
+
404
+ ## Note 1: Filesystem
405
+
406
+ Filesystem can take arguments. By default it's '/' or the root of the system...
407
+
408
+ But for the sake of example, to get the free disk space of /, you do:
409
+
410
+ ```
411
+ $ irb
412
+ irb(main):001:0> require 'linux_stat'
413
+ => true
295
414
 
415
+ irb(main):002:0> LinuxStat::Filesystem.free('/').fdiv(1024 ** 3).to_s << " GiB"
416
+ => "35.666873931884766 GiB"
296
417
  ```
297
418
 
419
+ To see the free and total space of a thumbdrive:
420
+
421
+ ```
422
+ $ irb
423
+ irb(main):001:0> require 'linux_stat'
424
+ => true
425
+
426
+ irb(main):002:0> LinuxStat::Mounts.list.find { |x| x.include?('/run/media/sourav') }.split[1]
427
+ => "/run/media/sourav/5c2b7af7-d4c3-4ab4-a035-06d18ffc8e6f"
428
+
429
+ irb(main):003:0> thumbdrive = _
430
+ => "/run/media/sourav/5c2b7af7-d4c3-4ab4-a035-06d18ffc8e6f"
431
+
432
+ irb(main):004:0> LinuxStat::Filesystem.free(thumbdrive).fdiv(1024 ** 3).to_s << " GiB"
433
+ => "2.504791259765625 GiB"
434
+
435
+ irb(main):005:0> LinuxStat::Filesystem.total(thumbdrive).fdiv(1024 ** 3).to_s << " GiB"
436
+ => "29.305004119873047 GiB"
437
+ ```
438
+
439
+ ## Note 2: ProcessInfo
440
+
441
+ All the methods LinuxStat::ProcessInfo can take an argument containing the Process ID of a process.
442
+ By default it's $$ or the PID of the current process, ruby, itself.
443
+
444
+ Example:
445
+ Say you want to see how much CPU Firefox is consuming, for that you have to do the following (firefox can create a lot of child process though):
446
+
447
+ 1. Get the PID of Firefox:
448
+ ```
449
+ LinuxStat::Process.names.find { |x| x[1].include? 'firefox' }[0]
450
+ => 770 # but this differs all the time
451
+ ```
452
+
453
+ 2. Get the CPU usage:
454
+ ```
455
+ $ irb
456
+ irb(main):001:0> require 'linux_stat'
457
+ => true
458
+
459
+ irb(main):002:0> pid = LinuxStat::Process.names.find { |x| x[1].include? 'firefox' }[0]
460
+ => 770
461
+
462
+ irb(main):003:0> LinuxStat::ProcessInfo.cpu_usage(pid: pid)
463
+ => 0.0
464
+
465
+ irb(main):004:0> LinuxStat::ProcessInfo.cpu_usage(pid: pid)
466
+ => 15.0
467
+ ```
468
+
469
+ To get the memory usage of Firefox (for example):
470
+
471
+ ```
472
+ $ irb
473
+ irb(main):001:0> require 'linux_stat'
474
+ => true
475
+
476
+ irb(main):002:0> LinuxStat::ProcessInfo.mem_stat(LinuxStat::Process.names.find { |x| x[1].include? 'firefox'.freeze }[0])
477
+ => {:memory=>468472, :virtual_memory=>4754080, :resident_memory=>814388}
478
+ ```
479
+
480
+ To get ONLY the memory usage in MiB:
481
+
482
+ ```
483
+ $ irb
484
+ irb(main):001:0> require 'linux_stat'
485
+ => true
486
+
487
+ irb(main):002:0> LinuxStat::ProcessInfo.memory(LinuxStat::Process.names.find { |x| x[1].include? 'firefox'.freeze }[0]).fdiv(1024).round(2).to_s << " MiB"
488
+ => "467.51 MiB"
489
+ ```
490
+
491
+ ## Note 3: FS
492
+
493
+ LinuxStat::FS module gives you the raw info in Hash collected from statvfs.
494
+
495
+ It's not documented above because it's not suggested to run this directly. But it shouldn't cause any issue. `LinuxStat::Filesystem.stat_raw(fs = '/')` does that automatically.
496
+
497
+ It always requires an argument, and it's very fast. It directly calls the C API without any intermediate Ruby code.
498
+
499
+ For example, to get the info about '/' or root:
500
+
501
+ ```
502
+ $ irb
503
+ irb(main):001:0> require 'linux_stat'
504
+ => true
505
+
506
+ irb(main):002:0> LinuxStat::FS.stat('/')
507
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>9349843, :block_avail_unpriv=>9349843, :inodes=>58612160, :free_inodes=>56708247, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
508
+
509
+ irb(main):003:0> t = Time.now ; puts LinuxStat::FS.stat('/') ; Time.now - t
510
+ {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>9349843, :block_avail_unpriv=>9349843, :inodes=>58612160, :free_inodes=>56708247, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
511
+ => 5.0468e-05
512
+ ```
513
+
514
+ To learn more about them, just run ri and the method name. To see all available methods:
515
+
516
+ ---
517
+
298
518
  ## Return Types
299
519
  + 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.
300
520
 
@@ -308,23 +528,34 @@ LinuxStat::Swap.used
308
528
 
309
529
  If some error is *raised* it should be reported as a bug.
310
530
 
531
+ ---
532
+
311
533
  ## Ruby on Rails
312
534
 
313
535
  1. Just add `gem linux_stat`:
314
536
 
315
537
  ```
316
- bundle add linux_stat
538
+ $ bundle add linux_stat
317
539
  ```
318
540
 
319
541
  You can use LinuxStat directly in rails.
320
542
 
321
- ![RailsApp](https://raw.githubusercontent.com/Souravgoswami/linux_stat/master/logo/rails.gif)
543
+ ![RailsApp](https://raw.githubusercontent.com/Souravgoswami/linux_stat/master/images/rails.gif)
544
+
545
+ ---
322
546
 
323
- Don't need to worry about versions if you are using anything > 0.2.1.
547
+ ## Android
324
548
 
325
- Newer versions will have bug fixes, performance improvements and new features but the return types of old methods will always be the same across upgrades > 0.2.1.
549
+ LinuxStat does support Android OS. But it's not rigorously tested on all device like android apps.
326
550
 
327
- Even if we remove something, there will be always a deprecation warning for some months or for even a year before we actually remove it.
551
+ But in Termux you can just run LinuxStat without facing issues.
552
+ Note that the CPU count can differ due to hotplugging feature. So if you see the CPU count changes, there's not really nothing to do about that.
553
+
554
+ ![termux](https://raw.githubusercontent.com/Souravgoswami/linux_stat/master/images/termux.webp)
555
+
556
+ Issues regarding running LinuxStat on termux are also welcomed.
557
+
558
+ ---
328
559
 
329
560
  ## Development
330
561
 
@@ -332,6 +563,8 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
332
563
 
333
564
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
334
565
 
566
+ ---
567
+
335
568
  ## Testing
336
569
  Like other gems, this doesn't have a test like RSpec. We suggest using the bin/linuxstat.rb file on various systems.
337
570
  If you need to test a specific module, say the CPU, just run it like this:
@@ -353,10 +586,14 @@ $ ruby bin/linuxstat.rb upc
353
586
  ```
354
587
  This is not a valid module and can't be run.
355
588
 
589
+ ---
590
+
356
591
  ## Contributing
357
592
 
358
593
  Bug reports and pull requests are welcome on GitHub at https://github.com/Souravgoswami/linux_stat.
359
594
 
595
+ ---
596
+
360
597
  ## License
361
598
 
362
599
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).