linux_stat 0.7.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: a54eca551d77c1284989f5f8edeea8e363d32228e0ea5a2d28b2df9eefeedf53
4
- data.tar.gz: 407820d169fe900f639cd43730bd03eb66c43a2ec0bcd5c3d1399af741418c4a
3
+ metadata.gz: 7f217c6dc1948f9b7c8aabc280be2944c4036369922bbf56558afb04246db731
4
+ data.tar.gz: f112e864606b82cce2172272791e2db4935b93fd594d61f8a847964e19b7155c
5
5
  SHA512:
6
- metadata.gz: ff513a54d80eb9e9c101dd2fb92ff874c3e644da5752e8f7b2c9bdf535d56a1d942e64ed3b083eb051dfcb62be02cb521b51f0b1e08baef7f3ec0a261bacd1f1
7
- data.tar.gz: ef5b77eb019ab19976a5799a276f22a6967603c6d03b0219a6314e74e00a275a288102f0ab6d753e38867b96d6621e8673a9b0fa733d772c2d97118749ada933
6
+ metadata.gz: efb59793c28352ef4761cdefb2d4d1739568e80671ba8046f5ed618e982a25f20d49235644e0cf3780d2370481a23b21b78a8dafbfa344c483b5cd31c5469c32
7
+ data.tar.gz: d668cd782b969916e3207bb17afca44cdcd0997f65c7cc2116cf9f45858761fd847582dfb7c83892b608fc2d3daa48517e7674f4b2b3365c7f64e78a8a6f99de
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # LinuxStat
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
+
3
+ ---
4
+
2
5
  ![logo](https://raw.githubusercontent.com/Souravgoswami/linux_stat/master/images/logo.jpg)
3
6
 
4
7
  For reading the eyecandy HTML version, visit [linux_stat](https://souravgoswami.github.io/linux_stat/).
@@ -7,6 +10,10 @@ LinuxStat lets you read status of a Linux system. It can show you cpu stats and
7
10
 
8
11
  It only works for Linux, and detecting the OS is upto the user of this gem.
9
12
 
13
+ Programming Languages Used:
14
+
15
+ <img src="https://linuxstatloc.herokuapp.com/badge.svg" width="260px">
16
+
10
17
  ---
11
18
 
12
19
  ## Dependencies:
@@ -47,467 +54,821 @@ Or install it yourself as:
47
54
  $ gem install linux_stat
48
55
 
49
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
+
50
62
  ### LinuxStat::BIOS
51
63
  ```
52
- LinuxStat::BIOS.date
64
+ # File: bios.rb | Line: 56
65
+ # Definition: def date
66
+ LinuxStat::BIOS.date()
53
67
  => "04/10/2017"
54
68
 
55
- LinuxStat::BIOS.model
69
+ # File: bios.rb | Line: 10
70
+ # Definition: def model
71
+ LinuxStat::BIOS.model()
56
72
  => "Inspiron 5567"
57
73
 
58
- LinuxStat::BIOS.vendor
74
+ # File: bios.rb | Line: 27
75
+ # Definition: def vendor
76
+ LinuxStat::BIOS.vendor()
59
77
  => "Dell Inc."
60
78
 
61
- LinuxStat::BIOS.version
79
+ # File: bios.rb | Line: 42
80
+ # Definition: def version
81
+ LinuxStat::BIOS.version()
62
82
  => "1.1.2"
63
83
 
64
84
  ```
65
85
 
66
86
  ### LinuxStat::Battery
67
87
  ```
68
- LinuxStat::Battery.charge
88
+ # File: battery.rb | Line: 100
89
+ # Definition: def charge
90
+ LinuxStat::Battery.charge()
69
91
  => 100.0
70
92
 
71
- LinuxStat::Battery.charging?
93
+ # File: battery.rb | Line: 73
94
+ # Definition: def charging?
95
+ LinuxStat::Battery.charging?()
72
96
  => true
73
97
 
74
- LinuxStat::Battery.discharging?
98
+ # File: battery.rb | Line: 82
99
+ # Definition: def discharging?
100
+ LinuxStat::Battery.discharging?()
75
101
  => false
76
102
 
77
- LinuxStat::Battery.full?
103
+ # File: battery.rb | Line: 91
104
+ # Definition: def full?
105
+ LinuxStat::Battery.full?()
78
106
  => true
79
107
 
80
- LinuxStat::Battery.manufacturer
108
+ # File: battery.rb | Line: 45
109
+ # Definition: def manufacturer
110
+ LinuxStat::Battery.manufacturer()
81
111
  => "Samsung SDI"
82
112
 
83
- LinuxStat::Battery.model
113
+ # File: battery.rb | Line: 36
114
+ # Definition: def model
115
+ LinuxStat::Battery.model()
84
116
  => "DELL CYMGM77"
85
117
 
86
- LinuxStat::Battery.present?
118
+ # File: battery.rb | Line: 8
119
+ # Definition: def present?
120
+ LinuxStat::Battery.present?()
87
121
  => true
88
122
 
89
- LinuxStat::Battery.stat
123
+ # File: battery.rb | Line: 16
124
+ # Definition: def stat
125
+ LinuxStat::Battery.stat()
90
126
  => {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Full", :charge=>100.0, :charging=>true, :discharging=>false, :full=>true}
91
127
 
92
- LinuxStat::Battery.status
128
+ # File: battery.rb | Line: 64
129
+ # Definition: def status
130
+ LinuxStat::Battery.status()
93
131
  => "Full"
94
132
 
95
- LinuxStat::Battery.technology
133
+ # File: battery.rb | Line: 54
134
+ # Definition: def technology
135
+ LinuxStat::Battery.technology()
96
136
  => "Li-ion"
97
137
 
138
+ # File: battery.rb | Line: 114
139
+ # Definition: def voltage_now
140
+ LinuxStat::Battery.voltage_now()
141
+ => 12.477
142
+
98
143
  ```
99
144
 
100
145
  ### LinuxStat::CPU
101
146
  ```
102
- LinuxStat::CPU.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
154
+ LinuxStat::CPU.count()
103
155
  => 4
104
156
 
105
- LinuxStat::CPU.cur_freq
106
- => [2000063, 2000108, 2000332, 2000028]
157
+ # File: cpu.rb | Line: 153
158
+ # Definition: def cur_freq
159
+ LinuxStat::CPU.cur_freq()
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"}
166
+
167
+ # File: cpu.rb | Line: 197
168
+ # Definition: def max_freq
169
+ LinuxStat::CPU.max_freq()
170
+ => {"cpu0"=>2000000, "cpu1"=>2000000, "cpu2"=>2000000, "cpu3"=>2000000}
171
+
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
179
+ LinuxStat::CPU.model()
180
+ => "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
107
181
 
108
- LinuxStat::CPU.max_freq
109
- => [2000000, 2000000, 2000000, 2000000]
182
+ # File: cpu.rb | Line: 119
183
+ # Definition: def offline
184
+ LinuxStat::CPU.offline()
185
+ => []
110
186
 
111
- LinuxStat::CPU.model
112
- => "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
187
+ # File: cpu.rb | Line: 97
188
+ # Definition: def online
189
+ LinuxStat::CPU.online()
190
+ => [0, 1, 2, 3]
113
191
 
114
- LinuxStat::CPU.stat
115
- => {0=>0.0, 1=>0.0, 2=>0.0, 3=>0.0, 4=>0.0}
192
+ # File: cpu.rb | Line: 23
193
+ # Definition: def stat(sleep = ticks_to_ms_t5)
194
+ LinuxStat::CPU.stat(sleep)
195
+ => {0=>5.26, 1=>0.0, 2=>0.0, 3=>20.0, 4=>0.0}
116
196
 
117
- LinuxStat::CPU.total_usage
118
- => 0.0
197
+ # File: cpu.rb | Line: 63
198
+ # Definition: def total_usage(sleep = ticks_to_ms_t5)
199
+ LinuxStat::CPU.total_usage(sleep)
200
+ => 10.0
201
+
202
+ # File: cpu.rb | Line: 63
203
+ # Definition: def total_usage(sleep = ticks_to_ms_t5)
204
+ LinuxStat::CPU.usage(sleep)
205
+ => 5.0
119
206
 
120
- LinuxStat::CPU.usage
121
- => 20.0
207
+ # File: cpu.rb | Line: 23
208
+ # Definition: def stat(sleep = ticks_to_ms_t5)
209
+ LinuxStat::CPU.usages(sleep)
210
+ => {0=>5.56, 1=>0.0, 2=>0.0, 3=>16.67, 4=>0.0}
122
211
 
123
- LinuxStat::CPU.usages
124
- => {0=>20.0, 1=>0.0, 2=>0.0, 3=>50.0, 4=>100.0}
212
+ ```
213
+
214
+ ### LinuxStat::FS
215
+ ```
216
+ LinuxStat::FS.stat(arg = "/")
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}
125
218
 
126
219
  ```
127
220
 
128
221
  ### LinuxStat::Filesystem
129
222
  ```
130
- LinuxStat::Filesystem.available
131
- => 33120964608
223
+ # File: filesystem.rb | Line: 92
224
+ # Definition: def available(fs = ?..freeze)
225
+ LinuxStat::Filesystem.available(fs)
226
+ => 6442397696
132
227
 
133
- LinuxStat::Filesystem.free
134
- => 33120964608
228
+ # File: filesystem.rb | Line: 58
229
+ # Definition: def free(fs = ?..freeze)
230
+ LinuxStat::Filesystem.free(fs)
231
+ => 6442397696
135
232
 
136
- LinuxStat::Filesystem.stat
137
- => {:total=>119981191168, :free=>33120964608, :used=>86860226560}
233
+ # File: filesystem.rb | Line: 19
234
+ # Definition: def stat(fs = ?..freeze)
235
+ LinuxStat::Filesystem.stat(fs)
236
+ => {:total=>6442450944, :free=>6442397696, :used=>53248}
138
237
 
139
- LinuxStat::Filesystem.stat_raw
140
- => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>8086173, :block_avail_unpriv=>8086173, :inodes=>58612160, :free_inodes=>56567338, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
238
+ # File: filesystem.rb | Line: 108
239
+ # Definition: def stat_raw(fs = ?..freeze)
240
+ LinuxStat::Filesystem.stat_raw(fs)
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}
141
242
 
142
- LinuxStat::Filesystem.total
143
- => 119981191168
243
+ # File: filesystem.rb | Line: 39
244
+ # Definition: def total(fs = ?..freeze)
245
+ LinuxStat::Filesystem.total(fs)
246
+ => 6442450944
144
247
 
145
- LinuxStat::Filesystem.used
146
- => 86860226560
248
+ # File: filesystem.rb | Line: 73
249
+ # Definition: def used(fs = ?..freeze)
250
+ LinuxStat::Filesystem.used(fs)
251
+ => 53248
147
252
 
148
253
  ```
149
254
 
150
255
  ### LinuxStat::Kernel
151
256
  ```
152
- LinuxStat::Kernel.build_date
257
+ # File: kernel.rb | Line: 86
258
+ # Definition: def build_date
259
+ LinuxStat::Kernel.build_date()
153
260
  => 2020-11-20 07:44:55 +0000
154
261
 
155
- LinuxStat::Kernel.build_date_string
262
+ # File: kernel.rb | Line: 140
263
+ # Definition: def build_date_string
264
+ LinuxStat::Kernel.build_date_string()
156
265
  => "20 Nov 2020 07:44:55 +0000"
157
266
 
158
- LinuxStat::Kernel.build_user
267
+ # File: kernel.rb | Line: 21
268
+ # Definition: def build_user
269
+ LinuxStat::Kernel.build_user()
159
270
  => "souravgoswami@archlinux"
160
271
 
161
- LinuxStat::Kernel.clk_tck
272
+ # File: kernel.rb | Line: 179
273
+ # Definition: def ticks
274
+ LinuxStat::Kernel.clk_tck()
162
275
  => 100
163
276
 
164
- LinuxStat::Kernel.compiler
277
+ # File: kernel.rb | Line: 33
278
+ # Definition: def compiler
279
+ LinuxStat::Kernel.compiler()
165
280
  => [:gcc, "10.2.0"]
166
281
 
167
- LinuxStat::Kernel.compiler_version
282
+ # File: kernel.rb | Line: 55
283
+ # Definition: def compiler_version
284
+ LinuxStat::Kernel.compiler_version()
168
285
  => "10.2.0"
169
286
 
170
- LinuxStat::Kernel.release
287
+ # File: kernel.rb | Line: 10
288
+ # Definition: def version
289
+ LinuxStat::Kernel.release()
171
290
  => "5.9.9-xanmod1-1"
172
291
 
173
- LinuxStat::Kernel.string
292
+ # File: kernel.rb | Line: 169
293
+ # Definition: def string
294
+ LinuxStat::Kernel.string()
174
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"
175
296
 
176
- LinuxStat::Kernel.ticks
297
+ # File: kernel.rb | Line: 179
298
+ # Definition: def ticks
299
+ LinuxStat::Kernel.ticks()
177
300
  => 100
178
301
 
179
- LinuxStat::Kernel.version
302
+ # File: kernel.rb | Line: 10
303
+ # Definition: def version
304
+ LinuxStat::Kernel.version()
180
305
  => "5.9.9-xanmod1-1"
181
306
 
182
307
  ```
183
308
 
184
309
  ### LinuxStat::Memory
185
310
  ```
186
- LinuxStat::Memory.available
187
- => 579264
188
-
189
- LinuxStat::Memory.percent_available
190
- => 15.1
191
-
192
- LinuxStat::Memory.percent_used
193
- => 84.9
194
-
195
- LinuxStat::Memory.stat
196
- => {:total=>3836236, :used=>3256972, :available=>579264, :percent_used=>84.9, :percent_available=>15.1}
197
-
198
- LinuxStat::Memory.total
311
+ # File: memory.rb | Line: 50
312
+ # Definition: def available
313
+ LinuxStat::Memory.available()
314
+ => 589228
315
+
316
+ # File: memory.rb | Line: 81
317
+ # Definition: def percent_available
318
+ LinuxStat::Memory.percent_available()
319
+ => 15.36
320
+
321
+ # File: memory.rb | Line: 70
322
+ # Definition: def percent_used
323
+ LinuxStat::Memory.percent_used()
324
+ => 84.64
325
+
326
+ # File: memory.rb | Line: 11
327
+ # Definition: def stat
328
+ LinuxStat::Memory.stat()
329
+ => {:total=>3836236, :used=>3247008, :available=>589228, :percent_used=>84.64, :percent_available=>15.36}
330
+
331
+ # File: memory.rb | Line: 40
332
+ # Definition: def total
333
+ LinuxStat::Memory.total()
199
334
  => 3836236
200
335
 
201
- LinuxStat::Memory.used
202
- => 3256972
336
+ # File: memory.rb | Line: 60
337
+ # Definition: def used
338
+ LinuxStat::Memory.used()
339
+ => 3247008
203
340
 
204
341
  ```
205
342
 
206
343
  ### LinuxStat::Mounts
207
344
  ```
208
- LinuxStat::Mounts.device_stat
209
- => {:mountpoint=>"/", :total=>119981191168, :free=>33120964608, :available=>33120964608, :used=>86860226560, :percent_used=>72.39, :percent_free=>27.61, :percent_available=>27.61}
345
+ # File: mounts.rb | Line: 179
346
+ # Definition: def device_stat(dev = root)
347
+ LinuxStat::Mounts.device_stat(dev)
348
+ => {:mountpoint=>"/", :total=>119981191168, :free=>50242093056, :available=>50242093056, :used=>69739098112, :percent_used=>58.13, :percent_free=>41.87, :percent_available=>41.87}
210
349
 
211
- LinuxStat::Mounts.devices_stat
350
+ # File: mounts.rb | Line: 137
351
+ # Definition: def devices_stat
352
+ LinuxStat::Mounts.devices_stat()
212
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...
213
354
 
214
- LinuxStat::Mounts.list
215
- => ["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=1892908k,nr_inodes=473227,mode=755 0 0", "run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0", "...
355
+ # File: mounts.rb | Line: 11
356
+ # Definition: def list
357
+ LinuxStat::Mounts.list()
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", "...
216
359
 
217
- LinuxStat::Mounts.list_devices
218
- => ["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", "deb...
360
+ # File: mounts.rb | Line: 20
361
+ # Definition: def list_devices
362
+ LinuxStat::Mounts.list_devices()
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...
219
364
 
220
- LinuxStat::Mounts.list_devices_mount_point
221
- => {"proc"=>"/proc", "sys"=>"/sys", "dev"=>"/dev", "run"=>"/run", "/dev/sda2"=>"/", "securityfs"=>"/sys/kernel/security", "tmpfs"=>"/run/user/1000", "devpts"=>"/dev/pts", "cgroup2"=>"/sys/fs/cgroup/unified", "cgroup"=>"/sys/fs/cgroup/perf_event", "pstore...
365
+ # File: mounts.rb | Line: 109
366
+ # Definition: def list_devices_mount_point
367
+ LinuxStat::Mounts.list_devices_mount_point()
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"=>...
222
369
 
223
- LinuxStat::Mounts.mount_point
370
+ # File: mounts.rb | Line: 80
371
+ # Definition: def mount_point(dev = root)
372
+ LinuxStat::Mounts.mount_point(dev)
224
373
  => "/"
225
374
 
226
- LinuxStat::Mounts.root
375
+ # File: mounts.rb | Line: 29
376
+ # Definition: def root
377
+ LinuxStat::Mounts.root()
227
378
  => "/dev/sda2"
228
379
 
229
- LinuxStat::Mounts.root_fs
380
+ # File: mounts.rb | Line: 38
381
+ # Definition: def root_fs
382
+ LinuxStat::Mounts.root_fs()
230
383
  => "xfs"
231
384
 
232
- LinuxStat::Mounts.root_mount_options
385
+ # File: mounts.rb | Line: 47
386
+ # Definition: def root_mount_options
387
+ LinuxStat::Mounts.root_mount_options()
233
388
  => "rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota"
234
389
 
235
- LinuxStat::Mounts.tmpfs
390
+ # File: mounts.rb | Line: 56
391
+ # Definition: def tmpfs
392
+ LinuxStat::Mounts.tmpfs()
236
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...
237
394
 
238
395
  ```
239
396
 
240
397
  ### LinuxStat::Net
241
398
  ```
242
- LinuxStat::Net.current_usage
243
- => {:received=>2183400.0, :transmitted=>114860.0}
399
+ # File: net.rb | Line: 80
400
+ # Definition: def usage(interval = 0.1)
401
+ LinuxStat::Net.current_usage(interval)
402
+ => {:received=>0.0, :transmitted=>0.0}
244
403
 
245
- LinuxStat::Net.ipv4_private
404
+ # File: net.rb | Line: 10
405
+ # Definition: def ipv4_private
406
+ LinuxStat::Net.ipv4_private()
246
407
  => "192.168.0.102"
247
408
 
248
- LinuxStat::Net.total_bytes
249
- => {:received=>294316415, :transmitted=>45313147}
409
+ # File: net.rb | Line: 23
410
+ # Definition: def total_bytes
411
+ LinuxStat::Net.total_bytes()
412
+ => {:received=>154632306, :transmitted=>19636024}
413
+
414
+ # File: net.rb | Line: 41
415
+ # Definition: def total_bytes_received
416
+ LinuxStat::Net.total_bytes_received()
417
+ => 154632306
250
418
 
251
- LinuxStat::Net.total_bytes_received
252
- => 294317913
419
+ # File: net.rb | Line: 54
420
+ # Definition: def total_bytes_transmitted
421
+ LinuxStat::Net.total_bytes_transmitted()
422
+ => 19636024
253
423
 
254
- LinuxStat::Net.total_bytes_transmitted
255
- => 45313147
424
+ # File: net.rb | Line: 80
425
+ # Definition: def usage(interval = 0.1)
426
+ LinuxStat::Net.usage(interval)
427
+ => {:received=>0.0, :transmitted=>0.0}
256
428
 
257
- LinuxStat::Net.usage
258
- => {:received=>1643690.0, :transmitted=>146030.0}
429
+ ```
259
430
 
431
+ ### LinuxStat::Nproc
432
+ ```
260
433
  ```
261
434
 
262
435
  ### LinuxStat::OS
263
436
  ```
264
- LinuxStat::OS.bits
437
+ # File: os.rb | Line: 97
438
+ # Definition: def bits
439
+ LinuxStat::OS.bits()
265
440
  => 64
266
441
 
267
- LinuxStat::OS.distribution
442
+ # File: os.rb | Line: 42
443
+ # Definition: def distribution
444
+ LinuxStat::OS.distribution()
268
445
  => "Arch Linux"
269
446
 
270
- LinuxStat::OS.hostname
447
+ # File: os.rb | Line: 81
448
+ # Definition: def hostname
449
+ LinuxStat::OS.hostname()
271
450
  => "archlinux"
272
451
 
273
- LinuxStat::OS.lsb_release
452
+ # File: os.rb | Line: 30
453
+ # Definition: def lsb_release
454
+ LinuxStat::OS.lsb_release()
274
455
  => {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
275
456
 
276
- LinuxStat::OS.machine
457
+ # File: os.rb | Line: 64
458
+ # Definition: def machine
459
+ LinuxStat::OS.machine()
277
460
  => "x86_64"
278
461
 
279
- LinuxStat::OS.nodename
462
+ # File: os.rb | Line: 72
463
+ # Definition: def nodename
464
+ LinuxStat::OS.nodename()
280
465
  => "archlinux"
281
466
 
282
- LinuxStat::OS.os_release
467
+ # File: os.rb | Line: 15
468
+ # Definition: def os_release
469
+ LinuxStat::OS.os_release()
283
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/"...
284
471
 
285
- LinuxStat::OS.uptime
286
- => {:hour=>7, :minute=>44, :second=>29.92}
472
+ # File: os.rb | Line: 110
473
+ # Definition: def uptime
474
+ LinuxStat::OS.uptime()
475
+ => {:hour=>5, :minute=>59, :second=>24.24}
287
476
 
288
477
  ```
289
478
 
290
- ### LinuxStat::Process
479
+ ### LinuxStat::PrettifyBytes
291
480
  ```
292
- LinuxStat::Process.count
293
- => 205
294
-
295
- LinuxStat::Process.idle
296
- => [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, 166, 168, 172, 174, 176, 178, 182, 183, 184, 185, 186, 188, 230, 271, 324, 328, 337, 14228, 14757, 14998, 14999, 15000, 15001, 15...
481
+ # File: prettify_bytes.rb | Line: 42
482
+ # Definition: def convert_binary(n)
483
+ LinuxStat::PrettifyBytes.convert_binary(n = 303090340303942)
484
+ => "275.66 tebibytes"
297
485
 
298
- LinuxStat::Process.list
299
- => [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, 120, 122, 131, 134,...
486
+ # File: prettify_bytes.rb | Line: 19
487
+ # Definition: def convert_decimal(n)
488
+ LinuxStat::PrettifyBytes.convert_decimal(n = 805436909517676)
489
+ => "805.44 terabytes"
300
490
 
301
- LinuxStat::Process.names
302
- => {1=>"systemd", 2=>"kthreadd", 3=>"rcu_gp", 4=>"rcu_par_gp", 6=>"kworker/0:0H", 9=>"mm_percpu_wq", 10=>"ksoftirqd/0", 11=>"rcuc/0", 12=>"rcu_preempt", 13=>"rcub/0", 14=>"migration/0", 15=>"idle_inject/0", 16=>"cpuhp/0", 17=>"cpuhp/1", 18=>"idle_inject/...
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"
303
495
 
304
- LinuxStat::Process.running
305
- => [21158]
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"
306
500
 
307
- LinuxStat::Process.sleeping
308
- => [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, 165, 167, 189, 217, 231, 302, 307, 308, 309, 310, 320, 321, 322, 323, 325, 326, 350, 353, 356, 374, 394,...
501
+ ```
309
502
 
310
- LinuxStat::Process.types
503
+ ### LinuxStat::Process
504
+ ```
505
+ # File: process.rb | Line: 19
506
+ # Definition: def count
507
+ LinuxStat::Process.count()
508
+ => 214
509
+
510
+ # File: process.rb | Line: 71
511
+ # Definition: def idle
512
+ LinuxStat::Process.idle()
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,...
514
+
515
+ # File: process.rb | Line: 8
516
+ # Definition: def list
517
+ LinuxStat::Process.list()
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,...
519
+
520
+ # File: process.rb | Line: 25
521
+ # Definition: def names
522
+ LinuxStat::Process.names()
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...
524
+
525
+ # File: process.rb | Line: 97
526
+ # Definition: def running
527
+ LinuxStat::Process.running()
528
+ => [14954]
529
+
530
+ # File: process.rb | Line: 58
531
+ # Definition: def sleeping
532
+ LinuxStat::Process.sleeping()
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,...
534
+
535
+ # File: process.rb | Line: 37
536
+ # Definition: def types
537
+ LinuxStat::Process.types()
311
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...
312
539
 
313
- LinuxStat::Process.zombie
540
+ # File: process.rb | Line: 84
541
+ # Definition: def zombie
542
+ LinuxStat::Process.zombie()
314
543
  => []
315
544
 
316
545
  ```
317
546
 
318
547
  ### LinuxStat::ProcessInfo
319
548
  ```
320
- LinuxStat::ProcessInfo.cmdline
321
- => "ruby exe/linuxstat.rb -md"
549
+ # File: process_info.rb | Line: 54
550
+ # Definition: def cmdline(pid = $$)
551
+ LinuxStat::ProcessInfo.cmdline(pid)
552
+ => "ruby /usr/bin/linuxstat.rb -md"
322
553
 
323
- LinuxStat::ProcessInfo.command_name
554
+ # File: process_info.rb | Line: 78
555
+ # Definition: def command_name(pid = $$)
556
+ LinuxStat::ProcessInfo.command_name(pid)
324
557
  => "ruby"
325
558
 
326
- LinuxStat::ProcessInfo.cpu_stat
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)
566
+ LinuxStat::ProcessInfo.cpu_stat(pid:, sleep:)
327
567
  => {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>1}
328
568
 
329
- LinuxStat::ProcessInfo.cpu_usage
569
+ # File: process_info.rb | Line: 307
570
+ # Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
571
+ LinuxStat::ProcessInfo.cpu_usage(pid:, sleep:)
330
572
  => 0.0
331
573
 
332
- LinuxStat::ProcessInfo.gid
574
+ # File: process_info.rb | Line: 470
575
+ # Definition: def gid(pid = $$)
576
+ LinuxStat::ProcessInfo.gid(pid)
333
577
  => {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
334
578
 
335
- LinuxStat::ProcessInfo.last_executed_cpu
579
+ # File: process_info.rb | Line: 433
580
+ # Definition: def last_executed_cpu(pid = $$)
581
+ LinuxStat::ProcessInfo.last_executed_cpu(pid)
336
582
  => 1
337
583
 
338
- LinuxStat::ProcessInfo.mem_stat
339
- => {:memory=>10051.584, :virtual_memory=>81801.216, :resident_memory=>15986.688}
584
+ # File: process_info.rb | Line: 114
585
+ # Definition: def mem_stat(pid = $$)
586
+ LinuxStat::ProcessInfo.mem_stat(pid)
587
+ => {:memory=>12472.32, :virtual_memory=>84164.60800000001, :resident_memory=>18575.36}
340
588
 
341
- LinuxStat::ProcessInfo.memory
342
- => 10051.584
589
+ # File: process_info.rb | Line: 147
590
+ # Definition: def memory(pid = $$)
591
+ LinuxStat::ProcessInfo.memory(pid)
592
+ => 12472.32
593
+
594
+ # File: process_info.rb | Line: 607
595
+ # Definition: def nice(pid = $$)
596
+ LinuxStat::ProcessInfo.nice(pid)
597
+ => 0
343
598
 
344
- LinuxStat::ProcessInfo.owner
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 = $$)
606
+ LinuxStat::ProcessInfo.owner(pid)
345
607
  => "sourav"
346
608
 
347
- LinuxStat::ProcessInfo.resident_memory
348
- => 15986.688
609
+ # File: process_info.rb | Line: 197
610
+ # Definition: def resident_memory(pid = $$)
611
+ LinuxStat::ProcessInfo.resident_memory(pid)
612
+ => 18575.36
613
+
614
+ # File: process_info.rb | Line: 563
615
+ # Definition: def running_time(pid = $$)
616
+ LinuxStat::ProcessInfo.running_time(pid)
617
+ => 0.8
618
+
619
+ # File: process_info.rb | Line: 544
620
+ # Definition: def start_time(pid = $$)
621
+ LinuxStat::ProcessInfo.start_time(pid)
622
+ => 2020-12-22 02:34:22 +0530
623
+
624
+ # File: process_info.rb | Line: 513
625
+ # Definition: def start_time_epoch(pid = $$)
626
+ LinuxStat::ProcessInfo.start_time_epoch(pid)
627
+ => 1608584662
628
+
629
+ # File: process_info.rb | Line: 592
630
+ # Definition: def state(pid = $$)
631
+ LinuxStat::ProcessInfo.state(pid)
632
+ => "R"
633
+
634
+ # File: process_info.rb | Line: 359
635
+ # Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
636
+ LinuxStat::ProcessInfo.thread_usage(pid:, sleep:)
637
+ => 0.0
349
638
 
350
- LinuxStat::ProcessInfo.threads
639
+ # File: process_info.rb | Line: 408
640
+ # Definition: def threads(pid = $$)
641
+ LinuxStat::ProcessInfo.threads(pid)
351
642
  => 1
352
643
 
353
- LinuxStat::ProcessInfo.total_io
644
+ # File: process_info.rb | Line: 23
645
+ # Definition: def total_io(pid = $$)
646
+ LinuxStat::ProcessInfo.total_io(pid)
354
647
  => {:read_bytes=>0, :write_bytes=>0}
355
648
 
356
- LinuxStat::ProcessInfo.uid
649
+ # File: process_info.rb | Line: 446
650
+ # Definition: def uid(pid = $$)
651
+ LinuxStat::ProcessInfo.uid(pid)
357
652
  => {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
358
653
 
359
- LinuxStat::ProcessInfo.virtual_memory
360
- => 81801.216
654
+ # File: process_info.rb | Line: 172
655
+ # Definition: def virtual_memory(pid = $$)
656
+ LinuxStat::ProcessInfo.virtual_memory(pid)
657
+ => 84164.608
361
658
 
362
659
  ```
363
660
 
364
661
  ### LinuxStat::Swap
365
662
  ```
366
- LinuxStat::Swap.any?
663
+ # File: swap.rb | Line: 22
664
+ # Definition: def any?
665
+ LinuxStat::Swap.any?()
367
666
  => true
368
667
 
369
- LinuxStat::Swap.available
370
- => 3383720
371
-
372
- LinuxStat::Swap.list
373
- => {"/dev/zram0"=>[:partition, 4194300, 810580, -2]}
374
-
375
- LinuxStat::Swap.percent_available
376
- => 80.67
377
-
378
- LinuxStat::Swap.percent_used
379
- => 19.33
380
-
381
- LinuxStat::Swap.stat
382
- => {:total=>4194300, :used=>810580, :available=>3383720, :percent_used=>19.33, :percent_available=>80.67}
383
-
384
- LinuxStat::Swap.total
668
+ # File: swap.rb | Line: 68
669
+ # Definition: def available
670
+ LinuxStat::Swap.available()
671
+ => 2909408
672
+
673
+ # File: swap.rb | Line: 8
674
+ # Definition: def list
675
+ LinuxStat::Swap.list()
676
+ => {"/dev/zram0"=>[:partition, 4194300, 1284892, -2]}
677
+
678
+ # File: swap.rb | Line: 103
679
+ # Definition: def percent_available
680
+ LinuxStat::Swap.percent_available()
681
+ => 69.37
682
+
683
+ # File: swap.rb | Line: 89
684
+ # Definition: def percent_used
685
+ LinuxStat::Swap.percent_used()
686
+ => 30.63
687
+
688
+ # File: swap.rb | Line: 32
689
+ # Definition: def stat
690
+ LinuxStat::Swap.stat()
691
+ => {:total=>4194300, :used=>1284892, :available=>2909408, :percent_used=>30.63, :percent_available=>69.37}
692
+
693
+ # File: swap.rb | Line: 57
694
+ # Definition: def total
695
+ LinuxStat::Swap.total()
385
696
  => 4194300
386
697
 
387
- LinuxStat::Swap.used
388
- => 810580
698
+ # File: swap.rb | Line: 80
699
+ # Definition: def used
700
+ LinuxStat::Swap.used()
701
+ => 1284892
389
702
 
390
703
  ```
391
704
 
392
705
  ### LinuxStat::Sysconf
393
706
  ```
394
- LinuxStat::Sysconf.child_max
707
+ LinuxStat::Sysconf.child_max()
395
708
  => 2000000
396
709
 
397
- LinuxStat::Sysconf.get_euid
710
+ LinuxStat::Sysconf.expr_nest_max()
711
+ => 32
712
+
713
+ LinuxStat::Sysconf.get_euid()
398
714
  => 1000
399
715
 
400
- LinuxStat::Sysconf.get_gid
716
+ LinuxStat::Sysconf.get_gid()
401
717
  => 1000
402
718
 
403
- LinuxStat::Sysconf.get_login
719
+ LinuxStat::Sysconf.get_login()
404
720
  => "sourav"
405
721
 
406
- LinuxStat::Sysconf.get_uid
722
+ LinuxStat::Sysconf.get_uid()
407
723
  => 1000
408
724
 
409
- LinuxStat::Sysconf.get_user
725
+ LinuxStat::Sysconf.get_user()
410
726
  => "sourav"
411
727
 
412
- LinuxStat::Sysconf.hostname_max
728
+ LinuxStat::Sysconf.hostname_max()
413
729
  => 64
414
730
 
415
- LinuxStat::Sysconf.login_name_max
731
+ LinuxStat::Sysconf.line_max()
732
+ => 2048
733
+
734
+ LinuxStat::Sysconf.login_name_max()
416
735
  => 256
417
736
 
418
- LinuxStat::Sysconf.open_max
737
+ LinuxStat::Sysconf.open_max()
419
738
  => 1024
420
739
 
421
- LinuxStat::Sysconf.pagesize
740
+ LinuxStat::Sysconf.pagesize()
422
741
  => 4096
423
742
 
424
- LinuxStat::Sysconf.posix_version
743
+ LinuxStat::Sysconf.posix_version()
425
744
  => 200809
426
745
 
427
- LinuxStat::Sysconf.sc_clk_tck
746
+ LinuxStat::Sysconf.processor_configured()
747
+ => 4
748
+
749
+ LinuxStat::Sysconf.processor_online()
750
+ => 4
751
+
752
+ LinuxStat::Sysconf.sc_clk_tck()
428
753
  => 100
429
754
 
430
- LinuxStat::Sysconf.stream_max
755
+ LinuxStat::Sysconf.stream_max()
431
756
  => 16
432
757
 
433
- LinuxStat::Sysconf.tty_name_max
758
+ LinuxStat::Sysconf.tty_name_max()
434
759
  => 32
435
760
 
436
761
  ```
437
762
 
438
763
  ### LinuxStat::Uname
439
764
  ```
440
- LinuxStat::Uname.machine
765
+ LinuxStat::Uname.machine()
441
766
  => "x86_64"
442
767
 
443
- LinuxStat::Uname.nodename
768
+ LinuxStat::Uname.nodename()
444
769
  => "archlinux"
445
770
 
446
- LinuxStat::Uname.release
771
+ LinuxStat::Uname.release()
447
772
  => "5.9.9-xanmod1-1"
448
773
 
449
- LinuxStat::Uname.sysname
774
+ LinuxStat::Uname.sysname()
450
775
  => "Linux"
451
776
 
452
- LinuxStat::Uname.version
777
+ LinuxStat::Uname.version()
453
778
  => "#1 SMP PREEMPT Fri, 20 Nov 2020 07:44:55 +0000"
454
779
 
455
780
  ```
456
781
 
457
782
  ### LinuxStat::User
458
783
  ```
459
- LinuxStat::User.get_current_user
784
+ # File: user.rb | Line: 98
785
+ # Definition: def get_user
786
+ LinuxStat::User.get_current_user()
460
787
  => "sourav"
461
788
 
462
- LinuxStat::User.get_euid
789
+ # File: user.rb | Line: 137
790
+ # Definition: def get_euid
791
+ LinuxStat::User.get_euid()
463
792
  => 1000
464
793
 
465
- LinuxStat::User.get_gid
794
+ # File: user.rb | Line: 129
795
+ # Definition: def get_gid
796
+ LinuxStat::User.get_gid()
466
797
  => 1000
467
798
 
468
- LinuxStat::User.get_login
799
+ # File: user.rb | Line: 152
800
+ # Definition: def get_login
801
+ LinuxStat::User.get_login()
469
802
  => "sourav"
470
803
 
471
- LinuxStat::User.get_uid
804
+ # File: user.rb | Line: 121
805
+ # Definition: def get_uid
806
+ LinuxStat::User.get_uid()
472
807
  => 1000
473
808
 
474
- LinuxStat::User.get_user
809
+ # File: user.rb | Line: 98
810
+ # Definition: def get_user
811
+ LinuxStat::User.get_user()
475
812
  => "sourav"
476
813
 
477
- LinuxStat::User.gid_by_username
814
+ # File: user.rb | Line: 215
815
+ # Definition: def gid_by_username(username = get_user)
816
+ LinuxStat::User.gid_by_username(username)
478
817
  => 1000
479
818
 
480
- LinuxStat::User.gids
819
+ # File: user.rb | Line: 56
820
+ # Definition: def gids
821
+ LinuxStat::User.gids()
481
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, :...
482
823
 
483
- LinuxStat::User.home_by_gid
824
+ # File: user.rb | Line: 314
825
+ # Definition: def home_by_gid(id = get_gid)
826
+ LinuxStat::User.home_by_gid(id)
484
827
  => "/home/sourav"
485
828
 
486
- LinuxStat::User.home_by_username
829
+ # File: user.rb | Line: 266
830
+ # Definition: def home_by_username(user = get_user)
831
+ LinuxStat::User.home_by_username(user)
487
832
  => "/home/sourav"
488
833
 
489
- LinuxStat::User.home_directories
834
+ # File: user.rb | Line: 72
835
+ # Definition: def home_directories
836
+ LinuxStat::User.home_directories()
490
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...
491
838
 
492
- LinuxStat::User.homes_by_uid
839
+ # File: user.rb | Line: 293
840
+ # Definition: def homes_by_uid(id = get_uid)
841
+ LinuxStat::User.homes_by_uid(id)
493
842
  => ["/home/sourav"]
494
843
 
495
- LinuxStat::User.ids
844
+ # File: user.rb | Line: 23
845
+ # Definition: def ids
846
+ LinuxStat::User.ids()
496
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...
497
848
 
498
- LinuxStat::User.list
849
+ # File: user.rb | Line: 11
850
+ # Definition: def list
851
+ LinuxStat::User.list()
499
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...
500
853
 
501
- LinuxStat::User.uid_by_username
854
+ # File: user.rb | Line: 244
855
+ # Definition: def uid_by_username(username = get_user)
856
+ LinuxStat::User.uid_by_username(username)
502
857
  => 1000
503
858
 
504
- LinuxStat::User.uids
859
+ # File: user.rb | Line: 40
860
+ # Definition: def uids
861
+ LinuxStat::User.uids()
505
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...
506
863
 
507
- LinuxStat::User.username_by_gid
864
+ # File: user.rb | Line: 187
865
+ # Definition: def username_by_gid(gid = get_gid)
866
+ LinuxStat::User.username_by_gid(gid)
508
867
  => "sourav"
509
868
 
510
- LinuxStat::User.usernames_by_uid
869
+ # File: user.rb | Line: 169
870
+ # Definition: def usernames_by_uid(uid = get_uid)
871
+ LinuxStat::User.usernames_by_uid(uid)
511
872
  => ["sourav"]
512
873
 
513
874
  ```
@@ -578,7 +939,115 @@ well as soon as the Linux kernel updates the data and ruby executes the loop.
578
939
 
579
940
  Just run the linuxstat.rb command to test what method takes what time measured in microseconds.
580
941
 
581
- ## 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
582
1051
 
583
1052
  Filesystem can take arguments. By default it's '/' or the root of the system...
584
1053
 
@@ -613,7 +1082,7 @@ irb(main):005:0> LinuxStat::Filesystem.total(thumbdrive).fdiv(1024 ** 3).to_s <<
613
1082
  => "29.305004119873047 GiB"
614
1083
  ```
615
1084
 
616
- ## Note 3: ProcessInfo
1085
+ ## Note 4: ProcessInfo
617
1086
 
618
1087
  All the methods LinuxStat::ProcessInfo can take an argument containing the Process ID of a process.
619
1088
  By default it's $$ or the PID of the current process, ruby, itself.
@@ -665,7 +1134,7 @@ irb(main):002:0> LinuxStat::ProcessInfo.memory(LinuxStat::Process.names.find { |
665
1134
  => "467.51 MiB"
666
1135
  ```
667
1136
 
668
- ## Note 4: FS
1137
+ ## Note 5: FS
669
1138
 
670
1139
  LinuxStat::FS module gives you the raw info in Hash collected from statvfs.
671
1140
 
@@ -690,7 +1159,7 @@ irb(main):003:0> t = Time.now ; puts LinuxStat::FS.stat('/') ; Time.now - t
690
1159
 
691
1160
  To learn more about them, just run ri and the method name. To see all available methods.
692
1161
 
693
- ## Note 5: User
1162
+ ## Note 6: User
694
1163
  Most of the LinuxStat::User supports arguments.
695
1164
 
696
1165
  For example, to get a user's home by the username:
@@ -772,7 +1241,7 @@ irb(main):004:0> LinuxStat::User.get_login
772
1241
 
773
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.
774
1243
 
775
- ## Note 6: PrettifyBytes
1244
+ ## Note 7: PrettifyBytes
776
1245
  Often times we need to work with KB, MB GB, TB, or KiB, MiB, GiB, TiB, etc.
777
1246
  And we need some work to convert bytes to those units.
778
1247
  Because LinuxStat provides a lot of data in bytes, and kilobytes, it's quite tedious to convert them all the time.
@@ -912,6 +1381,16 @@ Issues regarding running LinuxStat on termux are also welcomed.
912
1381
 
913
1382
  ---
914
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
+
915
1394
  ## Development
916
1395
  After checking out the repo, compile and install this gem onto your local machine with `bundle exec rake install`
917
1396