linux_stat 0.8.0 → 0.9.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: f24315a14357e71327614a2ec812f052ff71973af21e34e6a14f3a24f537083a
4
- data.tar.gz: f2c18ac10d00092ead72522700cf97d58b599890b6c6a0fd076e4ffd88ebf6b6
3
+ metadata.gz: 7f217c6dc1948f9b7c8aabc280be2944c4036369922bbf56558afb04246db731
4
+ data.tar.gz: f112e864606b82cce2172272791e2db4935b93fd594d61f8a847964e19b7155c
5
5
  SHA512:
6
- metadata.gz: 06ec57333b02c7cf239ed0f2e2cd889f95110523e642807d534ec71c9761b9f58066326ed01291871b4f7d9b692adc778db743f2c275f4485c2779ea320b1253
7
- data.tar.gz: b577d7ed448d1c5f474ab70c0fda4fd333f43049f27978cf9970032f15c05f2b2f3040d248108393bde474324b6e1d83694d7054a6f2d1f0eaba466d2c7c2b8b
6
+ metadata.gz: efb59793c28352ef4761cdefb2d4d1739568e80671ba8046f5ed618e982a25f20d49235644e0cf3780d2370481a23b21b78a8dafbfa344c483b5cd31c5469c32
7
+ data.tar.gz: d668cd782b969916e3207bb17afca44cdcd0997f65c7cc2116cf9f45858761fd847582dfb7c83892b608fc2d3daa48517e7674f4b2b3365c7f64e78a8a6f99de
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # LinuxStat [![Ruby Gem](https://badge.fury.io/rb/linux_stat.svg)](https://rubygems.org/gems/linux_stat) ![Workflow Status](https://github.com/souravgoswami/linux_stat/workflows/LinuxStat%20Test/badge.svg)
2
2
 
3
+ ---
4
+
3
5
  ![logo](https://raw.githubusercontent.com/Souravgoswami/linux_stat/master/images/logo.jpg)
4
6
 
5
7
  For reading the eyecandy HTML version, visit [linux_stat](https://souravgoswami.github.io/linux_stat/).
@@ -8,13 +10,9 @@ LinuxStat lets you read status of a Linux system. It can show you cpu stats and
8
10
 
9
11
  It only works for Linux, and detecting the OS is upto the user of this gem.
10
12
 
11
- ---
12
-
13
- ## Source LOC (no comments / blank lines are counted):
13
+ Programming Languages Used:
14
14
 
15
- <div style="text-align:center">
16
- <img src="https://linuxstatloc.herokuapp.com/badge.svg" width="360px">
17
- </div>
15
+ <img src="https://linuxstatloc.herokuapp.com/badge.svg" width="260px">
18
16
 
19
17
  ---
20
18
 
@@ -56,25 +54,30 @@ Or install it yourself as:
56
54
  $ gem install linux_stat
57
55
 
58
56
  ## Usage
57
+ Following are the LinuxStat modules and module functions.
58
+ It's generated by linuxstat.rb command, which is available after the installation.
59
+
60
+ For ease of use, LinuxStat is also assigned to the LS constant.
61
+
59
62
  ### LinuxStat::BIOS
60
63
  ```
61
- # File: bios.rb | Line: 56
62
- # Definition: def date
64
+ # File: bios.rb | Line: 56
65
+ # Definition: def date
63
66
  LinuxStat::BIOS.date()
64
67
  => "04/10/2017"
65
68
 
66
- # File: bios.rb | Line: 10
67
- # Definition: def model
69
+ # File: bios.rb | Line: 10
70
+ # Definition: def model
68
71
  LinuxStat::BIOS.model()
69
72
  => "Inspiron 5567"
70
73
 
71
- # File: bios.rb | Line: 27
72
- # Definition: def vendor
74
+ # File: bios.rb | Line: 27
75
+ # Definition: def vendor
73
76
  LinuxStat::BIOS.vendor()
74
77
  => "Dell Inc."
75
78
 
76
- # File: bios.rb | Line: 42
77
- # Definition: def version
79
+ # File: bios.rb | Line: 42
80
+ # Definition: def version
78
81
  LinuxStat::BIOS.version()
79
82
  => "1.1.2"
80
83
 
@@ -82,197 +85,222 @@ LinuxStat::BIOS.version()
82
85
 
83
86
  ### LinuxStat::Battery
84
87
  ```
85
- # File: battery.rb | Line: 100
86
- # Definition: def charge
88
+ # File: battery.rb | Line: 100
89
+ # Definition: def charge
87
90
  LinuxStat::Battery.charge()
88
91
  => 100.0
89
92
 
90
- # File: battery.rb | Line: 73
91
- # Definition: def charging?
93
+ # File: battery.rb | Line: 73
94
+ # Definition: def charging?
92
95
  LinuxStat::Battery.charging?()
93
96
  => true
94
97
 
95
- # File: battery.rb | Line: 82
96
- # Definition: def discharging?
98
+ # File: battery.rb | Line: 82
99
+ # Definition: def discharging?
97
100
  LinuxStat::Battery.discharging?()
98
101
  => false
99
102
 
100
- # File: battery.rb | Line: 91
101
- # Definition: def full?
103
+ # File: battery.rb | Line: 91
104
+ # Definition: def full?
102
105
  LinuxStat::Battery.full?()
103
106
  => true
104
107
 
105
- # File: battery.rb | Line: 45
106
- # Definition: def manufacturer
108
+ # File: battery.rb | Line: 45
109
+ # Definition: def manufacturer
107
110
  LinuxStat::Battery.manufacturer()
108
111
  => "Samsung SDI"
109
112
 
110
- # File: battery.rb | Line: 36
111
- # Definition: def model
113
+ # File: battery.rb | Line: 36
114
+ # Definition: def model
112
115
  LinuxStat::Battery.model()
113
116
  => "DELL CYMGM77"
114
117
 
115
- # File: battery.rb | Line: 8
116
- # Definition: def present?
118
+ # File: battery.rb | Line: 8
119
+ # Definition: def present?
117
120
  LinuxStat::Battery.present?()
118
121
  => true
119
122
 
120
- # File: battery.rb | Line: 16
121
- # Definition: def stat
123
+ # File: battery.rb | Line: 16
124
+ # Definition: def stat
122
125
  LinuxStat::Battery.stat()
123
126
  => {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Full", :charge=>100.0, :charging=>true, :discharging=>false, :full=>true}
124
127
 
125
- # File: battery.rb | Line: 64
126
- # Definition: def status
128
+ # File: battery.rb | Line: 64
129
+ # Definition: def status
127
130
  LinuxStat::Battery.status()
128
131
  => "Full"
129
132
 
130
- # File: battery.rb | Line: 54
131
- # Definition: def technology
133
+ # File: battery.rb | Line: 54
134
+ # Definition: def technology
132
135
  LinuxStat::Battery.technology()
133
136
  => "Li-ion"
134
137
 
138
+ # File: battery.rb | Line: 114
139
+ # Definition: def voltage_now
140
+ LinuxStat::Battery.voltage_now()
141
+ => 12.477
142
+
135
143
  ```
136
144
 
137
145
  ### LinuxStat::CPU
138
146
  ```
139
- # File: cpu.rb | Line: 95
140
- # Definition: def count
147
+ # File: cpu.rb | Line: 243
148
+ # Definition: def available_governors
149
+ LinuxStat::CPU.available_governors()
150
+ => {"cpu0"=>["performance", "powersave"], "cpu1"=>["performance", "powersave"], "cpu2"=>["performance", "powersave"], "cpu3"=>["performance", "powersave"]}
151
+
152
+ # File: cpu.rb | Line: 86
153
+ # Definition: def count
141
154
  LinuxStat::CPU.count()
142
155
  => 4
143
156
 
144
- # File: cpu.rb | Line: 116
145
- # Definition: def cur_freq
157
+ # File: cpu.rb | Line: 153
158
+ # Definition: def cur_freq
146
159
  LinuxStat::CPU.cur_freq()
147
- => [2000141, 2000023, 1999435, 2000128]
160
+ => {"cpu0"=>1923309, "cpu1"=>2000053, "cpu2"=>2000046, "cpu3"=>2000086}
161
+
162
+ # File: cpu.rb | Line: 221
163
+ # Definition: def governor
164
+ LinuxStat::CPU.governor()
165
+ => {"cpu0"=>"performance", "cpu1"=>"performance", "cpu2"=>"performance", "cpu3"=>"performance"}
148
166
 
149
- # File: cpu.rb | Line: 131
150
- # Definition: def max_freq
167
+ # File: cpu.rb | Line: 197
168
+ # Definition: def max_freq
151
169
  LinuxStat::CPU.max_freq()
152
- => [2000000, 2000000, 2000000, 2000000]
170
+ => {"cpu0"=>2000000, "cpu1"=>2000000, "cpu2"=>2000000, "cpu3"=>2000000}
153
171
 
154
- # File: cpu.rb | Line: 108
155
- # Definition: def model
172
+ # File: cpu.rb | Line: 175
173
+ # Definition: def min_freq
174
+ LinuxStat::CPU.min_freq()
175
+ => {"cpu0"=>2000000, "cpu1"=>2000000, "cpu2"=>2000000, "cpu3"=>2000000}
176
+
177
+ # File: cpu.rb | Line: 140
178
+ # Definition: def model
156
179
  LinuxStat::CPU.model()
157
180
  => "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
158
181
 
159
- # File: cpu.rb | Line: 84
160
- # Definition: def online
182
+ # File: cpu.rb | Line: 119
183
+ # Definition: def offline
184
+ LinuxStat::CPU.offline()
185
+ => []
186
+
187
+ # File: cpu.rb | Line: 97
188
+ # Definition: def online
161
189
  LinuxStat::CPU.online()
162
- => 4
190
+ => [0, 1, 2, 3]
163
191
 
164
- # File: cpu.rb | Line: 21
165
- # Definition: def stat(sleep = ticks_to_ms_t5)
192
+ # File: cpu.rb | Line: 23
193
+ # Definition: def stat(sleep = ticks_to_ms_t5)
166
194
  LinuxStat::CPU.stat(sleep)
167
- => {0=>5.26, 1=>0.0, 2=>0.0, 3=>0.0, 4=>16.67}
195
+ => {0=>5.26, 1=>0.0, 2=>0.0, 3=>20.0, 4=>0.0}
168
196
 
169
- # File: cpu.rb | Line: 63
170
- # Definition: def total_usage(sleep = ticks_to_ms_t5)
197
+ # File: cpu.rb | Line: 63
198
+ # Definition: def total_usage(sleep = ticks_to_ms_t5)
171
199
  LinuxStat::CPU.total_usage(sleep)
172
- => 15.0
200
+ => 10.0
173
201
 
174
- # File: cpu.rb | Line: 63
175
- # Definition: def total_usage(sleep = ticks_to_ms_t5)
202
+ # File: cpu.rb | Line: 63
203
+ # Definition: def total_usage(sleep = ticks_to_ms_t5)
176
204
  LinuxStat::CPU.usage(sleep)
177
- => 10.0
205
+ => 5.0
178
206
 
179
- # File: cpu.rb | Line: 21
180
- # Definition: def stat(sleep = ticks_to_ms_t5)
207
+ # File: cpu.rb | Line: 23
208
+ # Definition: def stat(sleep = ticks_to_ms_t5)
181
209
  LinuxStat::CPU.usages(sleep)
182
- => {0=>15.0, 1=>20.0, 2=>0.0, 3=>20.0, 4=>20.0}
210
+ => {0=>5.56, 1=>0.0, 2=>0.0, 3=>16.67, 4=>0.0}
183
211
 
184
212
  ```
185
213
 
186
214
  ### LinuxStat::FS
187
215
  ```
188
216
  LinuxStat::FS.stat(arg = "/")
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}
217
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>12266136, :block_avail_unpriv=>12266136, :inodes=>58612160, :free_inodes=>56868673, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
190
218
 
191
219
  ```
192
220
 
193
221
  ### LinuxStat::Filesystem
194
222
  ```
195
- # File: filesystem.rb | Line: 92
196
- # Definition: def available(fs = ?/.freeze)
223
+ # File: filesystem.rb | Line: 92
224
+ # Definition: def available(fs = ?..freeze)
197
225
  LinuxStat::Filesystem.available(fs)
198
- => 52424663040
226
+ => 6442397696
199
227
 
200
- # File: filesystem.rb | Line: 58
201
- # Definition: def free(fs = ?/.freeze)
228
+ # File: filesystem.rb | Line: 58
229
+ # Definition: def free(fs = ?..freeze)
202
230
  LinuxStat::Filesystem.free(fs)
203
- => 52424663040
231
+ => 6442397696
204
232
 
205
- # File: filesystem.rb | Line: 19
206
- # Definition: def stat(fs = ?/.freeze)
233
+ # File: filesystem.rb | Line: 19
234
+ # Definition: def stat(fs = ?..freeze)
207
235
  LinuxStat::Filesystem.stat(fs)
208
- => {:total=>119981191168, :free=>52424663040, :used=>67556528128}
236
+ => {:total=>6442450944, :free=>6442397696, :used=>53248}
209
237
 
210
- # File: filesystem.rb | Line: 108
211
- # Definition: def stat_raw(fs = ?/.freeze)
238
+ # File: filesystem.rb | Line: 108
239
+ # Definition: def stat_raw(fs = ?..freeze)
212
240
  LinuxStat::Filesystem.stat_raw(fs)
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}
241
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>1572864, :block_free=>1572851, :block_avail_unpriv=>1572851, :inodes=>479529, :free_inodes=>479519, :filesystem_id=>0, :mount_flags=>4102, :max_filename_length=>255}
214
242
 
215
- # File: filesystem.rb | Line: 39
216
- # Definition: def total(fs = ?/.freeze)
243
+ # File: filesystem.rb | Line: 39
244
+ # Definition: def total(fs = ?..freeze)
217
245
  LinuxStat::Filesystem.total(fs)
218
- => 119981191168
246
+ => 6442450944
219
247
 
220
- # File: filesystem.rb | Line: 73
221
- # Definition: def used(fs = ?/.freeze)
248
+ # File: filesystem.rb | Line: 73
249
+ # Definition: def used(fs = ?..freeze)
222
250
  LinuxStat::Filesystem.used(fs)
223
- => 67556528128
251
+ => 53248
224
252
 
225
253
  ```
226
254
 
227
255
  ### LinuxStat::Kernel
228
256
  ```
229
- # File: kernel.rb | Line: 86
230
- # Definition: def build_date
257
+ # File: kernel.rb | Line: 86
258
+ # Definition: def build_date
231
259
  LinuxStat::Kernel.build_date()
232
260
  => 2020-11-20 07:44:55 +0000
233
261
 
234
- # File: kernel.rb | Line: 140
235
- # Definition: def build_date_string
262
+ # File: kernel.rb | Line: 140
263
+ # Definition: def build_date_string
236
264
  LinuxStat::Kernel.build_date_string()
237
265
  => "20 Nov 2020 07:44:55 +0000"
238
266
 
239
- # File: kernel.rb | Line: 21
240
- # Definition: def build_user
267
+ # File: kernel.rb | Line: 21
268
+ # Definition: def build_user
241
269
  LinuxStat::Kernel.build_user()
242
270
  => "souravgoswami@archlinux"
243
271
 
244
- # File: kernel.rb | Line: 179
245
- # Definition: def ticks
272
+ # File: kernel.rb | Line: 179
273
+ # Definition: def ticks
246
274
  LinuxStat::Kernel.clk_tck()
247
275
  => 100
248
276
 
249
- # File: kernel.rb | Line: 33
250
- # Definition: def compiler
277
+ # File: kernel.rb | Line: 33
278
+ # Definition: def compiler
251
279
  LinuxStat::Kernel.compiler()
252
280
  => [:gcc, "10.2.0"]
253
281
 
254
- # File: kernel.rb | Line: 55
255
- # Definition: def compiler_version
282
+ # File: kernel.rb | Line: 55
283
+ # Definition: def compiler_version
256
284
  LinuxStat::Kernel.compiler_version()
257
285
  => "10.2.0"
258
286
 
259
- # File: kernel.rb | Line: 10
260
- # Definition: def version
287
+ # File: kernel.rb | Line: 10
288
+ # Definition: def version
261
289
  LinuxStat::Kernel.release()
262
290
  => "5.9.9-xanmod1-1"
263
291
 
264
- # File: kernel.rb | Line: 169
265
- # Definition: def string
292
+ # File: kernel.rb | Line: 169
293
+ # Definition: def string
266
294
  LinuxStat::Kernel.string()
267
295
  => "Linux version 5.9.9-xanmod1-1 (souravgoswami@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Fri, 20 Nov 2020 07:44:55 +0000"
268
296
 
269
- # File: kernel.rb | Line: 179
270
- # Definition: def ticks
297
+ # File: kernel.rb | Line: 179
298
+ # Definition: def ticks
271
299
  LinuxStat::Kernel.ticks()
272
300
  => 100
273
301
 
274
- # File: kernel.rb | Line: 10
275
- # Definition: def version
302
+ # File: kernel.rb | Line: 10
303
+ # Definition: def version
276
304
  LinuxStat::Kernel.version()
277
305
  => "5.9.9-xanmod1-1"
278
306
 
@@ -280,233 +308,237 @@ LinuxStat::Kernel.version()
280
308
 
281
309
  ### LinuxStat::Memory
282
310
  ```
283
- # File: memory.rb | Line: 50
284
- # Definition: def available
311
+ # File: memory.rb | Line: 50
312
+ # Definition: def available
285
313
  LinuxStat::Memory.available()
286
- => 842868
314
+ => 589228
287
315
 
288
- # File: memory.rb | Line: 81
289
- # Definition: def percent_available
316
+ # File: memory.rb | Line: 81
317
+ # Definition: def percent_available
290
318
  LinuxStat::Memory.percent_available()
291
- => 21.97
319
+ => 15.36
292
320
 
293
- # File: memory.rb | Line: 70
294
- # Definition: def percent_used
321
+ # File: memory.rb | Line: 70
322
+ # Definition: def percent_used
295
323
  LinuxStat::Memory.percent_used()
296
- => 78.03
324
+ => 84.64
297
325
 
298
- # File: memory.rb | Line: 11
299
- # Definition: def stat
326
+ # File: memory.rb | Line: 11
327
+ # Definition: def stat
300
328
  LinuxStat::Memory.stat()
301
- => {:total=>3836236, :used=>2993368, :available=>842868, :percent_used=>78.03, :percent_available=>21.97}
329
+ => {:total=>3836236, :used=>3247008, :available=>589228, :percent_used=>84.64, :percent_available=>15.36}
302
330
 
303
- # File: memory.rb | Line: 40
304
- # Definition: def total
331
+ # File: memory.rb | Line: 40
332
+ # Definition: def total
305
333
  LinuxStat::Memory.total()
306
334
  => 3836236
307
335
 
308
- # File: memory.rb | Line: 60
309
- # Definition: def used
336
+ # File: memory.rb | Line: 60
337
+ # Definition: def used
310
338
  LinuxStat::Memory.used()
311
- => 2993368
339
+ => 3247008
312
340
 
313
341
  ```
314
342
 
315
343
  ### LinuxStat::Mounts
316
344
  ```
317
- # File: mounts.rb | Line: 179
318
- # Definition: def device_stat(dev = root)
345
+ # File: mounts.rb | Line: 179
346
+ # Definition: def device_stat(dev = root)
319
347
  LinuxStat::Mounts.device_stat(dev)
320
- => {:mountpoint=>"/", :total=>119981191168, :free=>52424663040, :available=>52424663040, :used=>67556528128, :percent_used=>56.31, :percent_free=>43.69, :percent_available=>43.69}
348
+ => {:mountpoint=>"/", :total=>119981191168, :free=>50242093056, :available=>50242093056, :used=>69739098112, :percent_used=>58.13, :percent_free=>41.87, :percent_available=>41.87}
321
349
 
322
- # File: mounts.rb | Line: 137
323
- # Definition: def devices_stat
350
+ # File: mounts.rb | Line: 137
351
+ # Definition: def devices_stat
324
352
  LinuxStat::Mounts.devices_stat()
325
353
  => {"proc"=>{:mountpoint=>"/proc", :total=>0, :free=>0, :available=>0, :used=>0, :percent_used=>NaN, :percent_free=>NaN, :percent_available=>NaN}, "sys"=>{:mountpoint=>"/sys", :total=>0, :free=>0, :available=>0, :used=>0, :percent_used=>NaN, :percent_fre...
326
354
 
327
- # File: mounts.rb | Line: 11
328
- # Definition: def list
355
+ # File: mounts.rb | Line: 11
356
+ # Definition: def list
329
357
  LinuxStat::Mounts.list()
330
358
  => ["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=1892904k,nr_inodes=473226,mode=755 0 0", "run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0", "...
331
359
 
332
- # File: mounts.rb | Line: 20
333
- # Definition: def list_devices
360
+ # File: mounts.rb | Line: 20
361
+ # Definition: def list_devices
334
362
  LinuxStat::Mounts.list_devices()
335
- => ["proc", "sys", "dev", "run", "/dev/sda2", "securityfs", "tmpfs", "devpts", "tmpfs", "cgroup2", "cgroup", "pstore", "none", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "systemd-1", "tra...
363
+ => ["proc", "sys", "dev", "run", "/dev/sda2", "securityfs", "tmpfs", "devpts", "tmpfs", "cgroup2", "cgroup", "pstore", "none", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "systemd-1", "mqu...
336
364
 
337
- # File: mounts.rb | Line: 109
338
- # Definition: def list_devices_mount_point
365
+ # File: mounts.rb | Line: 109
366
+ # Definition: def list_devices_mount_point
339
367
  LinuxStat::Mounts.list_devices_mount_point()
340
- => {"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/blkio", "pstore"=>"/...
368
+ => {"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/freezer", "pstore"=>...
341
369
 
342
- # File: mounts.rb | Line: 80
343
- # Definition: def mount_point(dev = root)
370
+ # File: mounts.rb | Line: 80
371
+ # Definition: def mount_point(dev = root)
344
372
  LinuxStat::Mounts.mount_point(dev)
345
373
  => "/"
346
374
 
347
- # File: mounts.rb | Line: 29
348
- # Definition: def root
375
+ # File: mounts.rb | Line: 29
376
+ # Definition: def root
349
377
  LinuxStat::Mounts.root()
350
378
  => "/dev/sda2"
351
379
 
352
- # File: mounts.rb | Line: 38
353
- # Definition: def root_fs
380
+ # File: mounts.rb | Line: 38
381
+ # Definition: def root_fs
354
382
  LinuxStat::Mounts.root_fs()
355
383
  => "xfs"
356
384
 
357
- # File: mounts.rb | Line: 47
358
- # Definition: def root_mount_options
385
+ # File: mounts.rb | Line: 47
386
+ # Definition: def root_mount_options
359
387
  LinuxStat::Mounts.root_mount_options()
360
388
  => "rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota"
361
389
 
362
- # File: mounts.rb | Line: 56
363
- # Definition: def tmpfs
390
+ # File: mounts.rb | Line: 56
391
+ # Definition: def tmpfs
364
392
  LinuxStat::Mounts.tmpfs()
365
- => {"/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", "/tmp"=>"...
393
+ => {"/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...
366
394
 
367
395
  ```
368
396
 
369
397
  ### LinuxStat::Net
370
398
  ```
371
- # File: net.rb | Line: 80
372
- # Definition: def usage(interval = 0.1)
399
+ # File: net.rb | Line: 80
400
+ # Definition: def usage(interval = 0.1)
373
401
  LinuxStat::Net.current_usage(interval)
374
- => {:received=>61200.0, :transmitted=>1880.0}
402
+ => {:received=>0.0, :transmitted=>0.0}
375
403
 
376
- # File: net.rb | Line: 10
377
- # Definition: def ipv4_private
404
+ # File: net.rb | Line: 10
405
+ # Definition: def ipv4_private
378
406
  LinuxStat::Net.ipv4_private()
379
407
  => "192.168.0.102"
380
408
 
381
- # File: net.rb | Line: 23
382
- # Definition: def total_bytes
409
+ # File: net.rb | Line: 23
410
+ # Definition: def total_bytes
383
411
  LinuxStat::Net.total_bytes()
384
- => {:received=>1112357335, :transmitted=>289215998}
412
+ => {:received=>154632306, :transmitted=>19636024}
385
413
 
386
- # File: net.rb | Line: 41
387
- # Definition: def total_bytes_received
414
+ # File: net.rb | Line: 41
415
+ # Definition: def total_bytes_received
388
416
  LinuxStat::Net.total_bytes_received()
389
- => 1112357335
417
+ => 154632306
390
418
 
391
- # File: net.rb | Line: 54
392
- # Definition: def total_bytes_transmitted
419
+ # File: net.rb | Line: 54
420
+ # Definition: def total_bytes_transmitted
393
421
  LinuxStat::Net.total_bytes_transmitted()
394
- => 289215998
422
+ => 19636024
395
423
 
396
- # File: net.rb | Line: 80
397
- # Definition: def usage(interval = 0.1)
424
+ # File: net.rb | Line: 80
425
+ # Definition: def usage(interval = 0.1)
398
426
  LinuxStat::Net.usage(interval)
399
- => {:received=>61200.0, :transmitted=>1880.0}
427
+ => {:received=>0.0, :transmitted=>0.0}
400
428
 
401
429
  ```
402
430
 
431
+ ### LinuxStat::Nproc
432
+ ```
433
+ ```
434
+
403
435
  ### LinuxStat::OS
404
436
  ```
405
- # File: os.rb | Line: 97
406
- # Definition: def bits
437
+ # File: os.rb | Line: 97
438
+ # Definition: def bits
407
439
  LinuxStat::OS.bits()
408
440
  => 64
409
441
 
410
- # File: os.rb | Line: 42
411
- # Definition: def distribution
442
+ # File: os.rb | Line: 42
443
+ # Definition: def distribution
412
444
  LinuxStat::OS.distribution()
413
445
  => "Arch Linux"
414
446
 
415
- # File: os.rb | Line: 81
416
- # Definition: def hostname
447
+ # File: os.rb | Line: 81
448
+ # Definition: def hostname
417
449
  LinuxStat::OS.hostname()
418
450
  => "archlinux"
419
451
 
420
- # File: os.rb | Line: 30
421
- # Definition: def lsb_release
452
+ # File: os.rb | Line: 30
453
+ # Definition: def lsb_release
422
454
  LinuxStat::OS.lsb_release()
423
455
  => {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
424
456
 
425
- # File: os.rb | Line: 64
426
- # Definition: def machine
457
+ # File: os.rb | Line: 64
458
+ # Definition: def machine
427
459
  LinuxStat::OS.machine()
428
460
  => "x86_64"
429
461
 
430
- # File: os.rb | Line: 72
431
- # Definition: def nodename
462
+ # File: os.rb | Line: 72
463
+ # Definition: def nodename
432
464
  LinuxStat::OS.nodename()
433
465
  => "archlinux"
434
466
 
435
- # File: os.rb | Line: 15
436
- # Definition: def os_release
467
+ # File: os.rb | Line: 15
468
+ # Definition: def os_release
437
469
  LinuxStat::OS.os_release()
438
470
  => {: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/"...
439
471
 
440
- # File: os.rb | Line: 110
441
- # Definition: def uptime
472
+ # File: os.rb | Line: 110
473
+ # Definition: def uptime
442
474
  LinuxStat::OS.uptime()
443
- => {:hour=>10, :minute=>49, :second=>25.48}
475
+ => {:hour=>5, :minute=>59, :second=>24.24}
444
476
 
445
477
  ```
446
478
 
447
479
  ### LinuxStat::PrettifyBytes
448
480
  ```
449
- # File: prettify_bytes.rb | Line: 42
450
- # Definition: def convert_binary(n)
451
- LinuxStat::PrettifyBytes.convert_binary(n = 304432464364884)
452
- => "276.88 tebibytes"
481
+ # File: prettify_bytes.rb | Line: 42
482
+ # Definition: def convert_binary(n)
483
+ LinuxStat::PrettifyBytes.convert_binary(n = 303090340303942)
484
+ => "275.66 tebibytes"
453
485
 
454
- # File: prettify_bytes.rb | Line: 19
455
- # Definition: def convert_decimal(n)
456
- LinuxStat::PrettifyBytes.convert_decimal(n = 49306758655424)
457
- => "49.31 terabytes"
486
+ # File: prettify_bytes.rb | Line: 19
487
+ # Definition: def convert_decimal(n)
488
+ LinuxStat::PrettifyBytes.convert_decimal(n = 805436909517676)
489
+ => "805.44 terabytes"
458
490
 
459
- # File: prettify_bytes.rb | Line: 90
460
- # Definition: def convert_short_binary(n)
461
- LinuxStat::PrettifyBytes.convert_short_binary(n = 361176129377179)
462
- => "328.49 TiB"
491
+ # File: prettify_bytes.rb | Line: 90
492
+ # Definition: def convert_short_binary(n)
493
+ LinuxStat::PrettifyBytes.convert_short_binary(n = 652441756135644)
494
+ => "593.39 TiB"
463
495
 
464
- # File: prettify_bytes.rb | Line: 65
465
- # Definition: def convert_short_decimal(n)
466
- LinuxStat::PrettifyBytes.convert_short_decimal(n = 293690574885959)
467
- => "293.69 TB"
496
+ # File: prettify_bytes.rb | Line: 65
497
+ # Definition: def convert_short_decimal(n)
498
+ LinuxStat::PrettifyBytes.convert_short_decimal(n = 957289578618866)
499
+ => "957.29 TB"
468
500
 
469
501
  ```
470
502
 
471
503
  ### LinuxStat::Process
472
504
  ```
473
- # File: process.rb | Line: 19
474
- # Definition: def count
505
+ # File: process.rb | Line: 19
506
+ # Definition: def count
475
507
  LinuxStat::Process.count()
476
- => 215
508
+ => 214
477
509
 
478
- # File: process.rb | Line: 71
479
- # Definition: def idle
510
+ # File: process.rb | Line: 71
511
+ # Definition: def idle
480
512
  LinuxStat::Process.idle()
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,...
513
+ => [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, 182, 184, 186, 187, 190, 195, 196, 197, 198, 199, 200, 229, 245, 288, 368, 382, 2013, 6607, 6608, 6609, 6610, 6611, 6612, 11958,...
482
514
 
483
- # File: process.rb | Line: 8
484
- # Definition: def list
515
+ # File: process.rb | Line: 8
516
+ # Definition: def list
485
517
  LinuxStat::Process.list()
486
- => [1, 2, 3, 4, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 46, 47, 48, 49, 50, 51, 52, 102, 103, 104, 106, 107, 108, 109, 110, 111, 114, 115, 117, 118, 119, 121, 131, 134,...
518
+ => [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, 121, 131, 134,...
487
519
 
488
- # File: process.rb | Line: 25
489
- # Definition: def names
520
+ # File: process.rb | Line: 25
521
+ # Definition: def names
490
522
  LinuxStat::Process.names()
491
523
  => {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...
492
524
 
493
- # File: process.rb | Line: 97
494
- # Definition: def running
525
+ # File: process.rb | Line: 97
526
+ # Definition: def running
495
527
  LinuxStat::Process.running()
496
- => [25641, 33756]
528
+ => [14954]
497
529
 
498
- # File: process.rb | Line: 58
499
- # Definition: def sleeping
530
+ # File: process.rb | Line: 58
531
+ # Definition: def sleeping
500
532
  LinuxStat::Process.sleeping()
501
- => [1, 2, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 38, 40, 41, 42, 46, 47, 48, 50, 51, 52, 111, 114, 115, 168, 170, 189, 218, 235, 301, 305, 309, 310, 311, 314, 315, 316, 317, 331, 334, 337, 403, 407, 409, 410,...
533
+ => [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, 181, 183, 201, 232, 247, 308, 319, 321, 322, 323, 325, 326, 327, 328, 343, 346, 349, 403, 433, 435, 436,...
502
534
 
503
- # File: process.rb | Line: 37
504
- # Definition: def types
535
+ # File: process.rb | Line: 37
536
+ # Definition: def types
505
537
  LinuxStat::Process.types()
506
538
  => {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...
507
539
 
508
- # File: process.rb | Line: 84
509
- # Definition: def zombie
540
+ # File: process.rb | Line: 84
541
+ # Definition: def zombie
510
542
  LinuxStat::Process.zombie()
511
543
  => []
512
544
 
@@ -514,149 +546,159 @@ LinuxStat::Process.zombie()
514
546
 
515
547
  ### LinuxStat::ProcessInfo
516
548
  ```
517
- # File: process_info.rb | Line: 54
518
- # Definition: def cmdline(pid = $$)
549
+ # File: process_info.rb | Line: 54
550
+ # Definition: def cmdline(pid = $$)
519
551
  LinuxStat::ProcessInfo.cmdline(pid)
520
552
  => "ruby /usr/bin/linuxstat.rb -md"
521
553
 
522
- # File: process_info.rb | Line: 78
523
- # Definition: def command_name(pid = $$)
554
+ # File: process_info.rb | Line: 78
555
+ # Definition: def command_name(pid = $$)
524
556
  LinuxStat::ProcessInfo.command_name(pid)
525
557
  => "ruby"
526
558
 
527
- # File: process_info.rb | Line: 247
528
- # Definition: def cpu_stat(pid: $$, sleep: ticks_to_ms_t5)
559
+ # File: process_info.rb | Line: 640
560
+ # Definition: def nproc(pid = $$)
561
+ LinuxStat::ProcessInfo.count_cpu(pid)
562
+ => 4
563
+
564
+ # File: process_info.rb | Line: 247
565
+ # Definition: def cpu_stat(pid: $$, sleep: ticks_to_ms_t5)
529
566
  LinuxStat::ProcessInfo.cpu_stat(pid:, sleep:)
530
- => {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>2}
567
+ => {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>1}
531
568
 
532
- # File: process_info.rb | Line: 301
533
- # Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
569
+ # File: process_info.rb | Line: 307
570
+ # Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
534
571
  LinuxStat::ProcessInfo.cpu_usage(pid:, sleep:)
535
572
  => 0.0
536
573
 
537
- # File: process_info.rb | Line: 454
538
- # Definition: def gid(pid = $$)
574
+ # File: process_info.rb | Line: 470
575
+ # Definition: def gid(pid = $$)
539
576
  LinuxStat::ProcessInfo.gid(pid)
540
577
  => {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
541
578
 
542
- # File: process_info.rb | Line: 417
543
- # Definition: def last_executed_cpu(pid = $$)
579
+ # File: process_info.rb | Line: 433
580
+ # Definition: def last_executed_cpu(pid = $$)
544
581
  LinuxStat::ProcessInfo.last_executed_cpu(pid)
545
- => 2
582
+ => 1
546
583
 
547
- # File: process_info.rb | Line: 114
548
- # Definition: def mem_stat(pid = $$)
584
+ # File: process_info.rb | Line: 114
585
+ # Definition: def mem_stat(pid = $$)
549
586
  LinuxStat::ProcessInfo.mem_stat(pid)
550
- => {:memory=>12292.096, :virtual_memory=>84049.92, :resident_memory=>18128.896}
587
+ => {:memory=>12472.32, :virtual_memory=>84164.60800000001, :resident_memory=>18575.36}
551
588
 
552
- # File: process_info.rb | Line: 147
553
- # Definition: def memory(pid = $$)
589
+ # File: process_info.rb | Line: 147
590
+ # Definition: def memory(pid = $$)
554
591
  LinuxStat::ProcessInfo.memory(pid)
555
- => 12292.096
592
+ => 12472.32
556
593
 
557
- # File: process_info.rb | Line: 588
558
- # Definition: def nice(pid = $$)
594
+ # File: process_info.rb | Line: 607
595
+ # Definition: def nice(pid = $$)
559
596
  LinuxStat::ProcessInfo.nice(pid)
560
597
  => 0
561
598
 
562
- # File: process_info.rb | Line: 475
563
- # Definition: def owner(pid = $$)
599
+ # File: process_info.rb | Line: 640
600
+ # Definition: def nproc(pid = $$)
601
+ LinuxStat::ProcessInfo.nproc(pid)
602
+ => 4
603
+
604
+ # File: process_info.rb | Line: 491
605
+ # Definition: def owner(pid = $$)
564
606
  LinuxStat::ProcessInfo.owner(pid)
565
607
  => "sourav"
566
608
 
567
- # File: process_info.rb | Line: 197
568
- # Definition: def resident_memory(pid = $$)
609
+ # File: process_info.rb | Line: 197
610
+ # Definition: def resident_memory(pid = $$)
569
611
  LinuxStat::ProcessInfo.resident_memory(pid)
570
- => 18128.896
612
+ => 18575.36
571
613
 
572
- # File: process_info.rb | Line: 545
573
- # Definition: def running_time(pid = $$)
614
+ # File: process_info.rb | Line: 563
615
+ # Definition: def running_time(pid = $$)
574
616
  LinuxStat::ProcessInfo.running_time(pid)
575
- => 1.639999999999418
617
+ => 0.8
576
618
 
577
- # File: process_info.rb | Line: 528
578
- # Definition: def start_time(pid = $$)
619
+ # File: process_info.rb | Line: 544
620
+ # Definition: def start_time(pid = $$)
579
621
  LinuxStat::ProcessInfo.start_time(pid)
580
- => 2020-12-17 21:56:57 +0530
622
+ => 2020-12-22 02:34:22 +0530
581
623
 
582
- # File: process_info.rb | Line: 497
583
- # Definition: def start_time_epoch(pid = $$)
624
+ # File: process_info.rb | Line: 513
625
+ # Definition: def start_time_epoch(pid = $$)
584
626
  LinuxStat::ProcessInfo.start_time_epoch(pid)
585
- => 1608222417
627
+ => 1608584662
586
628
 
587
- # File: process_info.rb | Line: 573
588
- # Definition: def state(pid = $$)
629
+ # File: process_info.rb | Line: 592
630
+ # Definition: def state(pid = $$)
589
631
  LinuxStat::ProcessInfo.state(pid)
590
632
  => "R"
591
633
 
592
- # File: process_info.rb | Line: 349
593
- # Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
634
+ # File: process_info.rb | Line: 359
635
+ # Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
594
636
  LinuxStat::ProcessInfo.thread_usage(pid:, sleep:)
595
637
  => 0.0
596
638
 
597
- # File: process_info.rb | Line: 392
598
- # Definition: def threads(pid = $$)
639
+ # File: process_info.rb | Line: 408
640
+ # Definition: def threads(pid = $$)
599
641
  LinuxStat::ProcessInfo.threads(pid)
600
642
  => 1
601
643
 
602
- # File: process_info.rb | Line: 23
603
- # Definition: def total_io(pid = $$)
644
+ # File: process_info.rb | Line: 23
645
+ # Definition: def total_io(pid = $$)
604
646
  LinuxStat::ProcessInfo.total_io(pid)
605
- => {:read_bytes=>253952, :write_bytes=>0}
647
+ => {:read_bytes=>0, :write_bytes=>0}
606
648
 
607
- # File: process_info.rb | Line: 430
608
- # Definition: def uid(pid = $$)
649
+ # File: process_info.rb | Line: 446
650
+ # Definition: def uid(pid = $$)
609
651
  LinuxStat::ProcessInfo.uid(pid)
610
652
  => {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
611
653
 
612
- # File: process_info.rb | Line: 172
613
- # Definition: def virtual_memory(pid = $$)
654
+ # File: process_info.rb | Line: 172
655
+ # Definition: def virtual_memory(pid = $$)
614
656
  LinuxStat::ProcessInfo.virtual_memory(pid)
615
- => 84049.92
657
+ => 84164.608
616
658
 
617
659
  ```
618
660
 
619
661
  ### LinuxStat::Swap
620
662
  ```
621
- # File: swap.rb | Line: 22
622
- # Definition: def any?
663
+ # File: swap.rb | Line: 22
664
+ # Definition: def any?
623
665
  LinuxStat::Swap.any?()
624
666
  => true
625
667
 
626
- # File: swap.rb | Line: 68
627
- # Definition: def available
668
+ # File: swap.rb | Line: 68
669
+ # Definition: def available
628
670
  LinuxStat::Swap.available()
629
- => 3681532
671
+ => 2909408
630
672
 
631
- # File: swap.rb | Line: 8
632
- # Definition: def list
673
+ # File: swap.rb | Line: 8
674
+ # Definition: def list
633
675
  LinuxStat::Swap.list()
634
- => {"/dev/zram0"=>[:partition, 4194300, 512768, -2]}
676
+ => {"/dev/zram0"=>[:partition, 4194300, 1284892, -2]}
635
677
 
636
- # File: swap.rb | Line: 103
637
- # Definition: def percent_available
678
+ # File: swap.rb | Line: 103
679
+ # Definition: def percent_available
638
680
  LinuxStat::Swap.percent_available()
639
- => 87.77
681
+ => 69.37
640
682
 
641
- # File: swap.rb | Line: 89
642
- # Definition: def percent_used
683
+ # File: swap.rb | Line: 89
684
+ # Definition: def percent_used
643
685
  LinuxStat::Swap.percent_used()
644
- => 12.23
686
+ => 30.63
645
687
 
646
- # File: swap.rb | Line: 32
647
- # Definition: def stat
688
+ # File: swap.rb | Line: 32
689
+ # Definition: def stat
648
690
  LinuxStat::Swap.stat()
649
- => {:total=>4194300, :used=>512768, :available=>3681532, :percent_used=>12.23, :percent_available=>87.77}
691
+ => {:total=>4194300, :used=>1284892, :available=>2909408, :percent_used=>30.63, :percent_available=>69.37}
650
692
 
651
- # File: swap.rb | Line: 57
652
- # Definition: def total
693
+ # File: swap.rb | Line: 57
694
+ # Definition: def total
653
695
  LinuxStat::Swap.total()
654
696
  => 4194300
655
697
 
656
- # File: swap.rb | Line: 80
657
- # Definition: def used
698
+ # File: swap.rb | Line: 80
699
+ # Definition: def used
658
700
  LinuxStat::Swap.used()
659
- => 512768
701
+ => 1284892
660
702
 
661
703
  ```
662
704
 
@@ -739,93 +781,93 @@ LinuxStat::Uname.version()
739
781
 
740
782
  ### LinuxStat::User
741
783
  ```
742
- # File: user.rb | Line: 98
743
- # Definition: def get_user
784
+ # File: user.rb | Line: 98
785
+ # Definition: def get_user
744
786
  LinuxStat::User.get_current_user()
745
787
  => "sourav"
746
788
 
747
- # File: user.rb | Line: 137
748
- # Definition: def get_euid
789
+ # File: user.rb | Line: 137
790
+ # Definition: def get_euid
749
791
  LinuxStat::User.get_euid()
750
792
  => 1000
751
793
 
752
- # File: user.rb | Line: 129
753
- # Definition: def get_gid
794
+ # File: user.rb | Line: 129
795
+ # Definition: def get_gid
754
796
  LinuxStat::User.get_gid()
755
797
  => 1000
756
798
 
757
- # File: user.rb | Line: 152
758
- # Definition: def get_login
799
+ # File: user.rb | Line: 152
800
+ # Definition: def get_login
759
801
  LinuxStat::User.get_login()
760
802
  => "sourav"
761
803
 
762
- # File: user.rb | Line: 121
763
- # Definition: def get_uid
804
+ # File: user.rb | Line: 121
805
+ # Definition: def get_uid
764
806
  LinuxStat::User.get_uid()
765
807
  => 1000
766
808
 
767
- # File: user.rb | Line: 98
768
- # Definition: def get_user
809
+ # File: user.rb | Line: 98
810
+ # Definition: def get_user
769
811
  LinuxStat::User.get_user()
770
812
  => "sourav"
771
813
 
772
- # File: user.rb | Line: 215
773
- # Definition: def gid_by_username(username = get_user)
814
+ # File: user.rb | Line: 215
815
+ # Definition: def gid_by_username(username = get_user)
774
816
  LinuxStat::User.gid_by_username(username)
775
817
  => 1000
776
818
 
777
- # File: user.rb | Line: 56
778
- # Definition: def gids
819
+ # File: user.rb | Line: 56
820
+ # Definition: def gids
779
821
  LinuxStat::User.gids()
780
822
  => {:root=>0, :bin=>1, :daemon=>2, :mail=>12, :ftp=>11, :http=>33, :nobody=>65534, :dbus=>81, :"systemd-journal-remote"=>982, :"systemd-network"=>981, :"systemd-resolve"=>980, :"systemd-timesync"=>979, :"systemd-coredump"=>978, :uuidd=>68, :avahi=>977, :...
781
823
 
782
- # File: user.rb | Line: 314
783
- # Definition: def home_by_gid(id = get_gid)
824
+ # File: user.rb | Line: 314
825
+ # Definition: def home_by_gid(id = get_gid)
784
826
  LinuxStat::User.home_by_gid(id)
785
827
  => "/home/sourav"
786
828
 
787
- # File: user.rb | Line: 266
788
- # Definition: def home_by_username(user = get_user)
829
+ # File: user.rb | Line: 266
830
+ # Definition: def home_by_username(user = get_user)
789
831
  LinuxStat::User.home_by_username(user)
790
832
  => "/home/sourav"
791
833
 
792
- # File: user.rb | Line: 72
793
- # Definition: def home_directories
834
+ # File: user.rb | Line: 72
835
+ # Definition: def home_directories
794
836
  LinuxStat::User.home_directories()
795
837
  => {:root=>"/root", :bin=>"/", :daemon=>"/", :mail=>"/var/spool/mail", :ftp=>"/srv/ftp", :http=>"/srv/http", :nobody=>"/", :dbus=>"/", :"systemd-journal-remote"=>"/", :"systemd-network"=>"/", :"systemd-resolve"=>"/", :"systemd-timesync"=>"/", :"systemd-c...
796
838
 
797
- # File: user.rb | Line: 293
798
- # Definition: def homes_by_uid(id = get_uid)
839
+ # File: user.rb | Line: 293
840
+ # Definition: def homes_by_uid(id = get_uid)
799
841
  LinuxStat::User.homes_by_uid(id)
800
842
  => ["/home/sourav"]
801
843
 
802
- # File: user.rb | Line: 23
803
- # Definition: def ids
844
+ # File: user.rb | Line: 23
845
+ # Definition: def ids
804
846
  LinuxStat::User.ids()
805
847
  => {:root=>{:uid=>0, :gid=>0}, :bin=>{:uid=>1, :gid=>1}, :daemon=>{:uid=>2, :gid=>2}, :mail=>{:uid=>8, :gid=>12}, :ftp=>{:uid=>14, :gid=>11}, :http=>{:uid=>33, :gid=>33}, :nobody=>{:uid=>65534, :gid=>65534}, :dbus=>{:uid=>81, :gid=>81}, :"systemd-journal...
806
848
 
807
- # File: user.rb | Line: 11
808
- # Definition: def list
849
+ # File: user.rb | Line: 11
850
+ # Definition: def list
809
851
  LinuxStat::User.list()
810
852
  => ["root", "bin", "daemon", "mail", "ftp", "http", "nobody", "dbus", "systemd-journal-remote", "systemd-network", "systemd-resolve", "systemd-timesync", "systemd-coredump", "uuidd", "avahi", "colord", "git", "lxdm", "polkitd", "rtkit", "usbmux", "sourav...
811
853
 
812
- # File: user.rb | Line: 244
813
- # Definition: def uid_by_username(username = get_user)
854
+ # File: user.rb | Line: 244
855
+ # Definition: def uid_by_username(username = get_user)
814
856
  LinuxStat::User.uid_by_username(username)
815
857
  => 1000
816
858
 
817
- # File: user.rb | Line: 40
818
- # Definition: def uids
859
+ # File: user.rb | Line: 40
860
+ # Definition: def uids
819
861
  LinuxStat::User.uids()
820
862
  => {:root=>0, :bin=>1, :daemon=>2, :mail=>8, :ftp=>14, :http=>33, :nobody=>65534, :dbus=>81, :"systemd-journal-remote"=>982, :"systemd-network"=>981, :"systemd-resolve"=>980, :"systemd-timesync"=>979, :"systemd-coredump"=>978, :uuidd=>68, :avahi=>977, :c...
821
863
 
822
- # File: user.rb | Line: 187
823
- # Definition: def username_by_gid(gid = get_gid)
864
+ # File: user.rb | Line: 187
865
+ # Definition: def username_by_gid(gid = get_gid)
824
866
  LinuxStat::User.username_by_gid(gid)
825
867
  => "sourav"
826
868
 
827
- # File: user.rb | Line: 169
828
- # Definition: def usernames_by_uid(uid = get_uid)
869
+ # File: user.rb | Line: 169
870
+ # Definition: def usernames_by_uid(uid = get_uid)
829
871
  LinuxStat::User.usernames_by_uid(uid)
830
872
  => ["sourav"]
831
873
 
@@ -897,7 +939,115 @@ well as soon as the Linux kernel updates the data and ruby executes the loop.
897
939
 
898
940
  Just run the linuxstat.rb command to test what method takes what time measured in microseconds.
899
941
 
900
- ## Note 2: Filesystem
942
+ ## Note 2: Count CPU
943
+
944
+ There are confusingly 6 different methods to count the number of CPU. But they are here for a reason!
945
+
946
+ Well this section actually demystifies the methods.
947
+
948
+ 1. The good old `LinuxStat::CPU.count()`:
949
+
950
+ It gets the configured CPU for the system. It doesn't count for hotplugged CPU.
951
+ If 3 out of 4 CPU are hotplugged out, it will still show 4. It calles `sysconf(_SC_NPROCESSORS_CONF)`
952
+
953
+ 2. The mysterious `LinuxStat::ProcessInfo.nproc(pid = $$)`:
954
+
955
+ [ Also aliased to `LinuxStat::ProcessInfo.count_cpu()` ]
956
+
957
+ It returns the number of processors, like the other 3 methods.
958
+ Without any arguments, it's like running `require 'etc' ; puts Etc.nprocessors`
959
+
960
+ So there the caveat of checking what the number of processors are actually allocated to the pid.
961
+
962
+ For example:
963
+
964
+ ```
965
+ $ ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
966
+ 4
967
+
968
+ $ taskset -c 0 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
969
+ 1
970
+
971
+ $ taskset -c 0-1 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
972
+ 2
973
+
974
+ $ taskset -c 0-1,3 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
975
+ 3
976
+
977
+ $ taskset -c 0-1,3 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc "
978
+ 3
979
+ ```
980
+
981
+ Or with argument:
982
+
983
+ ```
984
+ irb(main):001:0> require 'linux_stat'
985
+ => true
986
+
987
+ irb(main):002:0> LinuxStat::ProcessInfo.command_name 4775
988
+ => "electron"
989
+
990
+ irb(main):003:0> LinuxStat::ProcessInfo.nproc 4775
991
+ => 4
992
+ ```
993
+
994
+ 3. The `LinuxStat::CPU.online()`:
995
+
996
+ This returns the number of online CPU as an Array. It doesn't get affected by taskset or anything.
997
+
998
+ For example:
999
+
1000
+ ```
1001
+ irb(main):001:0> require 'linux_stat'
1002
+ => true
1003
+
1004
+ irb(main):002:0> LinuxStat::CPU.online
1005
+ => [0, 1, 3]
1006
+ ```
1007
+
1008
+ By using `LinuxStat::CPU.online.count` you count the actual online CPU on your system.
1009
+
1010
+ Any n number of CPU can get hotplugged in and out, and this will report that correctly.
1011
+
1012
+ It just gets the info from /sys/devices/system/cpu/online, and parses the output.
1013
+
1014
+ 4. The `LinuxStat::CPU.offline()`:
1015
+
1016
+ This returns the number of offline CPU as an Array. It doesn't get affected by taskset or anything.
1017
+
1018
+ For example:
1019
+
1020
+ ```
1021
+ irb(main):001:0> require 'linux_stat'
1022
+ => true
1023
+
1024
+ irb(main):002:0> LinuxStat::CPU.offline
1025
+ => [2]
1026
+ ```
1027
+
1028
+ Any n number of CPU can get hotplugged in and out, and this will report that correctly.
1029
+
1030
+ It just gets the info from /sys/devices/system/cpu/offline, and parses the output.
1031
+
1032
+ 5. The `LinuxStat::Sysconf.processor_configured()`:
1033
+
1034
+ Sounds repetitive! Actually yes, this is written in C, and it is called by `LinuxStat::CPU.count`.
1035
+
1036
+ The difference is that `LinuxStat::CPU.count` caches the return value, and this method doesn't.
1037
+
1038
+ 6. The `LinuxStat::Sysconf.processor_online()`:
1039
+
1040
+ This may again sound repititive to LinuxStat::CPU.online, but it's actually not!
1041
+
1042
+ If you are using while loops, it might not report the correct number of CPU everytime.
1043
+
1044
+ Worst, it can take a long time to update the total number of CPU.
1045
+
1046
+ The benefit is, it's quite fast!
1047
+
1048
+ It's mostly here just for the sake of completeness to sysconf.
1049
+
1050
+ ## Note 3: Filesystem
901
1051
 
902
1052
  Filesystem can take arguments. By default it's '/' or the root of the system...
903
1053
 
@@ -932,7 +1082,7 @@ irb(main):005:0> LinuxStat::Filesystem.total(thumbdrive).fdiv(1024 ** 3).to_s <<
932
1082
  => "29.305004119873047 GiB"
933
1083
  ```
934
1084
 
935
- ## Note 3: ProcessInfo
1085
+ ## Note 4: ProcessInfo
936
1086
 
937
1087
  All the methods LinuxStat::ProcessInfo can take an argument containing the Process ID of a process.
938
1088
  By default it's $$ or the PID of the current process, ruby, itself.
@@ -984,7 +1134,7 @@ irb(main):002:0> LinuxStat::ProcessInfo.memory(LinuxStat::Process.names.find { |
984
1134
  => "467.51 MiB"
985
1135
  ```
986
1136
 
987
- ## Note 4: FS
1137
+ ## Note 5: FS
988
1138
 
989
1139
  LinuxStat::FS module gives you the raw info in Hash collected from statvfs.
990
1140
 
@@ -1009,7 +1159,7 @@ irb(main):003:0> t = Time.now ; puts LinuxStat::FS.stat('/') ; Time.now - t
1009
1159
 
1010
1160
  To learn more about them, just run ri and the method name. To see all available methods.
1011
1161
 
1012
- ## Note 5: User
1162
+ ## Note 6: User
1013
1163
  Most of the LinuxStat::User supports arguments.
1014
1164
 
1015
1165
  For example, to get a user's home by the username:
@@ -1091,7 +1241,7 @@ irb(main):004:0> LinuxStat::User.get_login
1091
1241
 
1092
1242
  Right, the get_login() can return an empty string. But LinuxStat::User.get_user also aliased as LinuxStat::User.get_current_user shouldn't return an empty string under most circumstances.
1093
1243
 
1094
- ## Note 6: PrettifyBytes
1244
+ ## Note 7: PrettifyBytes
1095
1245
  Often times we need to work with KB, MB GB, TB, or KiB, MiB, GiB, TiB, etc.
1096
1246
  And we need some work to convert bytes to those units.
1097
1247
  Because LinuxStat provides a lot of data in bytes, and kilobytes, it's quite tedious to convert them all the time.
@@ -1231,6 +1381,16 @@ Issues regarding running LinuxStat on termux are also welcomed.
1231
1381
 
1232
1382
  ---
1233
1383
 
1384
+ ## Cloning this Repo
1385
+ Users of this gem are requested to follow the above installation step to install this gem.
1386
+
1387
+ This repo is only for development purpose. It has C extensions that could do worst to your stable app.
1388
+ Cloning, compiling code from this repo for a production app may seg fault and crash the whole app directly.
1389
+
1390
+ Gems on Rubygems are released after various tests.
1391
+
1392
+ So just install the gem, don't clone this repo just because the version is bumped here with new features, and the gem is not out on Rubygems.org.
1393
+
1234
1394
  ## Development
1235
1395
  After checking out the repo, compile and install this gem onto your local machine with `bundle exec rake install`
1236
1396