linux_stat 0.7.4 → 1.0.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: 9aaa7608b7663765621d718c95aaeedad578364aa83f09fcd678399bb7ebd783
4
- data.tar.gz: 98695af9e725d99fda2fc0209082b796247dd9fb1a72fa316b6edd1d121124c3
3
+ metadata.gz: dfecb2c10d06e8e8cc76c1b03df8a518442f63d30fc7d556cb61649d1fc11957
4
+ data.tar.gz: beb60db61f4668cf82b4f551de0c08761bd935e91c6f631cf47f79adfc4803aa
5
5
  SHA512:
6
- metadata.gz: f34856c25125b173e87df17a127b872ebf8abb3c4d0f432cf6dbcc564c3c9a5bb1ab873c9d0695156255cc1ffc994e891b84958702192fe8f2f8925b2e17dd2c
7
- data.tar.gz: b639f0c37d74d8edac8315180a196001ad387f5fefdee48e9335aa95c0dce593c63ffd00f0e100dc1222dd0c8212b7a73a93e6627c1ad8b00ee47327a1df1989
6
+ metadata.gz: 3812d0d70ce53bfb24df7941252e711c37ff3ae9ecae87009a7f0cab13c82db99bc3dfdfeae02a370e9a8337c08ab13372f33768ee09b3d01e8caf7d3e4dea50
7
+ data.tar.gz: b600994a6566b315cb6b2a69563039d203f8a8b563135491978fd0f8c81499ac6dc784f40f3ec745520c4e8e8b787efbf3019150b578842e6be933938ae786fe
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,6 +10,10 @@ 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
 
13
+ Programming Languages Used:
14
+
15
+ <img src="https://linuxstatloc.herokuapp.com/badge.svg" width="260px">
16
+
11
17
  ---
12
18
 
13
19
  ## Dependencies:
@@ -48,25 +54,30 @@ Or install it yourself as:
48
54
  $ gem install linux_stat
49
55
 
50
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
+
51
62
  ### LinuxStat::BIOS
52
63
  ```
53
- # File: bios.rb | Line: 56
54
- # Definition: def date
64
+ # File: bios.rb | Line: 56
65
+ # Definition: def date
55
66
  LinuxStat::BIOS.date()
56
67
  => "04/10/2017"
57
68
 
58
- # File: bios.rb | Line: 10
59
- # Definition: def model
69
+ # File: bios.rb | Line: 10
70
+ # Definition: def model
60
71
  LinuxStat::BIOS.model()
61
72
  => "Inspiron 5567"
62
73
 
63
- # File: bios.rb | Line: 27
64
- # Definition: def vendor
74
+ # File: bios.rb | Line: 27
75
+ # Definition: def vendor
65
76
  LinuxStat::BIOS.vendor()
66
77
  => "Dell Inc."
67
78
 
68
- # File: bios.rb | Line: 42
69
- # Definition: def version
79
+ # File: bios.rb | Line: 42
80
+ # Definition: def version
70
81
  LinuxStat::BIOS.version()
71
82
  => "1.1.2"
72
83
 
@@ -74,192 +85,242 @@ LinuxStat::BIOS.version()
74
85
 
75
86
  ### LinuxStat::Battery
76
87
  ```
77
- # File: battery.rb | Line: 100
78
- # Definition: def charge
88
+ # File: battery.rb | Line: 105
89
+ # Definition: def charge
79
90
  LinuxStat::Battery.charge()
80
91
  => 100.0
81
92
 
82
- # File: battery.rb | Line: 73
83
- # Definition: def charging?
93
+ # File: battery.rb | Line: 122
94
+ # Definition: def charge_full_design_wh
95
+ LinuxStat::Battery.charge_full_design_wh()
96
+ => 42.0
97
+
98
+ # File: battery.rb | Line: 141
99
+ # Definition: def charge_full_wh
100
+ LinuxStat::Battery.charge_full_wh()
101
+ => 23.79
102
+
103
+ # File: battery.rb | Line: 78
104
+ # Definition: def charging?
84
105
  LinuxStat::Battery.charging?()
85
106
  => true
86
107
 
87
- # File: battery.rb | Line: 82
88
- # Definition: def discharging?
108
+ # File: battery.rb | Line: 184
109
+ # Definition: def devices_stat
110
+ LinuxStat::Battery.devices_stat()
111
+ => {:AC=>{:type=>"Mains", :online=>1}, :BAT0=>{:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :type=>"Battery", :status=>"Full", :capacity=>100, :voltage_min_design=>11.4, :charge_full_design=>3.684, :charge_full_design_wh=>42.0, :voltage_now=>12....
112
+
113
+ # File: battery.rb | Line: 87
114
+ # Definition: def discharging?
89
115
  LinuxStat::Battery.discharging?()
90
116
  => false
91
117
 
92
- # File: battery.rb | Line: 91
93
- # Definition: def full?
118
+ # File: battery.rb | Line: 96
119
+ # Definition: def full?
94
120
  LinuxStat::Battery.full?()
95
121
  => true
96
122
 
97
- # File: battery.rb | Line: 45
98
- # Definition: def manufacturer
123
+ # File: battery.rb | Line: 47
124
+ # Definition: def manufacturer
99
125
  LinuxStat::Battery.manufacturer()
100
126
  => "Samsung SDI"
101
127
 
102
- # File: battery.rb | Line: 36
103
- # Definition: def model
128
+ # File: battery.rb | Line: 36
129
+ # Definition: def model
104
130
  LinuxStat::Battery.model()
105
131
  => "DELL CYMGM77"
106
132
 
107
- # File: battery.rb | Line: 8
108
- # Definition: def present?
133
+ # File: battery.rb | Line: 8
134
+ # Definition: def present?
109
135
  LinuxStat::Battery.present?()
110
136
  => true
111
137
 
112
- # File: battery.rb | Line: 16
113
- # Definition: def stat
138
+ # File: battery.rb | Line: 16
139
+ # Definition: def stat
114
140
  LinuxStat::Battery.stat()
115
141
  => {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Full", :charge=>100.0, :charging=>true, :discharging=>false, :full=>true}
116
142
 
117
- # File: battery.rb | Line: 64
118
- # Definition: def status
143
+ # File: battery.rb | Line: 68
144
+ # Definition: def status
119
145
  LinuxStat::Battery.status()
120
146
  => "Full"
121
147
 
122
- # File: battery.rb | Line: 54
123
- # Definition: def technology
148
+ # File: battery.rb | Line: 57
149
+ # Definition: def technology
124
150
  LinuxStat::Battery.technology()
125
151
  => "Li-ion"
126
152
 
153
+ # File: battery.rb | Line: 160
154
+ # Definition: def voltage_now
155
+ LinuxStat::Battery.voltage_now()
156
+ => 12.453
157
+
127
158
  ```
128
159
 
129
160
  ### LinuxStat::CPU
130
161
  ```
131
- # File: cpu.rb | Line: 82
132
- # Definition: def count
162
+ # File: cpu.rb | Line: 287
163
+ # Definition: def available_governors
164
+ LinuxStat::CPU.available_governors()
165
+ => {"cpu0"=>["performance", "powersave"], "cpu1"=>["performance", "powersave"], "cpu2"=>["performance", "powersave"], "cpu3"=>["performance", "powersave"]}
166
+
167
+ # File: cpu.rb | Line: 86
168
+ # Definition: def count
133
169
  LinuxStat::CPU.count()
134
170
  => 4
135
171
 
136
- # File: cpu.rb | Line: 101
137
- # Definition: def cur_freq
172
+ # File: cpu.rb | Line: 103
173
+ # Definition: def count_online
174
+ LinuxStat::CPU.count_online()
175
+ => 4
176
+
177
+ # File: cpu.rb | Line: 197
178
+ # Definition: def cur_freq
138
179
  LinuxStat::CPU.cur_freq()
139
- => [2000052, 2000013, 2000012, 1960509]
180
+ => {"cpu0"=>1971347, "cpu1"=>2000253, "cpu2"=>1916631, "cpu3"=>2000064}
181
+
182
+ # File: cpu.rb | Line: 265
183
+ # Definition: def governor
184
+ LinuxStat::CPU.governor()
185
+ => {"cpu0"=>"performance", "cpu1"=>"performance", "cpu2"=>"performance", "cpu3"=>"performance"}
140
186
 
141
- # File: cpu.rb | Line: 116
142
- # Definition: def max_freq
187
+ # File: cpu.rb | Line: 241
188
+ # Definition: def max_freq
143
189
  LinuxStat::CPU.max_freq()
144
- => [2000000, 2000000, 2000000, 2000000]
190
+ => {"cpu0"=>2000000, "cpu1"=>2000000, "cpu2"=>2000000, "cpu3"=>2000000}
145
191
 
146
- # File: cpu.rb | Line: 93
147
- # Definition: def model
192
+ # File: cpu.rb | Line: 219
193
+ # Definition: def min_freq
194
+ LinuxStat::CPU.min_freq()
195
+ => {"cpu0"=>2000000, "cpu1"=>2000000, "cpu2"=>2000000, "cpu3"=>2000000}
196
+
197
+ # File: cpu.rb | Line: 184
198
+ # Definition: def model
148
199
  LinuxStat::CPU.model()
149
200
  => "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
150
201
 
151
- # File: cpu.rb | Line: 21
152
- # Definition: def stat(sleep = ticks_to_ms)
202
+ # File: cpu.rb | Line: 163
203
+ # Definition: def offline
204
+ LinuxStat::CPU.offline()
205
+ => []
206
+
207
+ # File: cpu.rb | Line: 132
208
+ # Definition: def online
209
+ LinuxStat::CPU.online()
210
+ => [0, 1, 2, 3]
211
+
212
+ # File: cpu.rb | Line: 23
213
+ # Definition: def stat(sleep = ticks_to_ms_t5)
153
214
  LinuxStat::CPU.stat(sleep)
154
- => {0=>20.0, 1=>0.0, 2=>0.0, 3=>0.0, 4=>0.0}
215
+ => {0=>5.0, 1=>16.67, 2=>0.0, 3=>0.0, 4=>16.67}
155
216
 
156
- # File: cpu.rb | Line: 63
157
- # Definition: def total_usage(sleep = ticks_to_ms)
158
- LinuxStat::CPU.usage(sleep)
159
- => 50.0
217
+ # File: cpu.rb | Line: 63
218
+ # Definition: def total_usage(sleep = ticks_to_ms_t5)
219
+ LinuxStat::CPU.total_usage(sleep)
220
+ => 5.26
160
221
 
161
- # File: cpu.rb | Line: 63
162
- # Definition: def total_usage(sleep = ticks_to_ms)
222
+ # File: cpu.rb | Line: 63
223
+ # Definition: def total_usage(sleep = ticks_to_ms_t5)
163
224
  LinuxStat::CPU.usage(sleep)
164
- => 20.0
225
+ => 9.52
165
226
 
166
- # File: cpu.rb | Line: 21
167
- # Definition: def stat(sleep = ticks_to_ms)
227
+ # File: cpu.rb | Line: 23
228
+ # Definition: def stat(sleep = ticks_to_ms_t5)
168
229
  LinuxStat::CPU.usages(sleep)
169
- => {0=>0.0, 1=>0.0, 2=>0.0, 3=>0.0, 4=>0.0}
230
+ => {0=>5.26, 1=>16.67, 2=>0.0, 3=>0.0, 4=>0.0}
170
231
 
171
232
  ```
172
233
 
173
234
  ### LinuxStat::FS
174
235
  ```
175
236
  LinuxStat::FS.stat(arg = "/")
176
- => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>12825937, :block_avail_unpriv=>12825937, :inodes=>58612160, :free_inodes=>56967681, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
237
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>11703573, :block_avail_unpriv=>11703573, :inodes=>58612160, :free_inodes=>56863418, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
177
238
 
178
239
  ```
179
240
 
180
241
  ### LinuxStat::Filesystem
181
242
  ```
182
- # File: filesystem.rb | Line: 92
183
- # Definition: def available(fs = ?/.freeze)
243
+ # File: filesystem.rb | Line: 92
244
+ # Definition: def available(fs = ?..freeze)
184
245
  LinuxStat::Filesystem.available(fs)
185
- => 52544036864
246
+ => 47937835008
186
247
 
187
- # File: filesystem.rb | Line: 58
188
- # Definition: def free(fs = ?/.freeze)
248
+ # File: filesystem.rb | Line: 58
249
+ # Definition: def free(fs = ?..freeze)
189
250
  LinuxStat::Filesystem.free(fs)
190
- => 52544036864
251
+ => 47937835008
191
252
 
192
- # File: filesystem.rb | Line: 19
193
- # Definition: def stat(fs = ?/.freeze)
253
+ # File: filesystem.rb | Line: 19
254
+ # Definition: def stat(fs = ?..freeze)
194
255
  LinuxStat::Filesystem.stat(fs)
195
- => {:total=>119981191168, :free=>52544036864, :used=>67437154304}
256
+ => {:total=>119981191168, :free=>47937835008, :used=>72043356160}
196
257
 
197
- # File: filesystem.rb | Line: 108
198
- # Definition: def stat_raw(fs = ?/.freeze)
258
+ # File: filesystem.rb | Line: 108
259
+ # Definition: def stat_raw(fs = ?..freeze)
199
260
  LinuxStat::Filesystem.stat_raw(fs)
200
- => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>12828134, :block_avail_unpriv=>12828134, :inodes=>58612160, :free_inodes=>56968284, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
261
+ => {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>11703573, :block_avail_unpriv=>11703573, :inodes=>58612160, :free_inodes=>56863418, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
201
262
 
202
- # File: filesystem.rb | Line: 39
203
- # Definition: def total(fs = ?/.freeze)
263
+ # File: filesystem.rb | Line: 39
264
+ # Definition: def total(fs = ?..freeze)
204
265
  LinuxStat::Filesystem.total(fs)
205
266
  => 119981191168
206
267
 
207
- # File: filesystem.rb | Line: 73
208
- # Definition: def used(fs = ?/.freeze)
268
+ # File: filesystem.rb | Line: 73
269
+ # Definition: def used(fs = ?..freeze)
209
270
  LinuxStat::Filesystem.used(fs)
210
- => 67437154304
271
+ => 72043356160
211
272
 
212
273
  ```
213
274
 
214
275
  ### LinuxStat::Kernel
215
276
  ```
216
- # File: kernel.rb | Line: 86
217
- # Definition: def build_date
277
+ # File: kernel.rb | Line: 86
278
+ # Definition: def build_date
218
279
  LinuxStat::Kernel.build_date()
219
280
  => 2020-11-20 07:44:55 +0000
220
281
 
221
- # File: kernel.rb | Line: 140
222
- # Definition: def build_date_string
282
+ # File: kernel.rb | Line: 140
283
+ # Definition: def build_date_string
223
284
  LinuxStat::Kernel.build_date_string()
224
285
  => "20 Nov 2020 07:44:55 +0000"
225
286
 
226
- # File: kernel.rb | Line: 21
227
- # Definition: def build_user
287
+ # File: kernel.rb | Line: 21
288
+ # Definition: def build_user
228
289
  LinuxStat::Kernel.build_user()
229
290
  => "souravgoswami@archlinux"
230
291
 
231
- # File: kernel.rb | Line: 179
232
- # Definition: def ticks
292
+ # File: kernel.rb | Line: 179
293
+ # Definition: def ticks
233
294
  LinuxStat::Kernel.clk_tck()
234
295
  => 100
235
296
 
236
- # File: kernel.rb | Line: 33
237
- # Definition: def compiler
297
+ # File: kernel.rb | Line: 33
298
+ # Definition: def compiler
238
299
  LinuxStat::Kernel.compiler()
239
300
  => [:gcc, "10.2.0"]
240
301
 
241
- # File: kernel.rb | Line: 55
242
- # Definition: def compiler_version
302
+ # File: kernel.rb | Line: 55
303
+ # Definition: def compiler_version
243
304
  LinuxStat::Kernel.compiler_version()
244
305
  => "10.2.0"
245
306
 
246
- # File: kernel.rb | Line: 10
247
- # Definition: def version
307
+ # File: kernel.rb | Line: 10
308
+ # Definition: def version
248
309
  LinuxStat::Kernel.release()
249
310
  => "5.9.9-xanmod1-1"
250
311
 
251
- # File: kernel.rb | Line: 169
252
- # Definition: def string
312
+ # File: kernel.rb | Line: 169
313
+ # Definition: def string
253
314
  LinuxStat::Kernel.string()
254
315
  => "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"
255
316
 
256
- # File: kernel.rb | Line: 179
257
- # Definition: def ticks
317
+ # File: kernel.rb | Line: 179
318
+ # Definition: def ticks
258
319
  LinuxStat::Kernel.ticks()
259
320
  => 100
260
321
 
261
- # File: kernel.rb | Line: 10
262
- # Definition: def version
322
+ # File: kernel.rb | Line: 10
323
+ # Definition: def version
263
324
  LinuxStat::Kernel.version()
264
325
  => "5.9.9-xanmod1-1"
265
326
 
@@ -267,121 +328,121 @@ LinuxStat::Kernel.version()
267
328
 
268
329
  ### LinuxStat::Memory
269
330
  ```
270
- # File: memory.rb | Line: 50
271
- # Definition: def available
331
+ # File: memory.rb | Line: 50
332
+ # Definition: def available
272
333
  LinuxStat::Memory.available()
273
- => 342000
334
+ => 1597312
274
335
 
275
- # File: memory.rb | Line: 81
276
- # Definition: def percent_available
336
+ # File: memory.rb | Line: 81
337
+ # Definition: def percent_available
277
338
  LinuxStat::Memory.percent_available()
278
- => 8.91
339
+ => 41.64
279
340
 
280
- # File: memory.rb | Line: 70
281
- # Definition: def percent_used
341
+ # File: memory.rb | Line: 70
342
+ # Definition: def percent_used
282
343
  LinuxStat::Memory.percent_used()
283
- => 91.09
344
+ => 58.36
284
345
 
285
- # File: memory.rb | Line: 11
286
- # Definition: def stat
346
+ # File: memory.rb | Line: 11
347
+ # Definition: def stat
287
348
  LinuxStat::Memory.stat()
288
- => {:total=>3836236, :used=>3494236, :available=>342000, :percent_used=>91.09, :percent_available=>8.91}
349
+ => {:total=>3836236, :used=>2238924, :available=>1597312, :percent_used=>58.36, :percent_available=>41.64}
289
350
 
290
- # File: memory.rb | Line: 40
291
- # Definition: def total
351
+ # File: memory.rb | Line: 40
352
+ # Definition: def total
292
353
  LinuxStat::Memory.total()
293
354
  => 3836236
294
355
 
295
- # File: memory.rb | Line: 60
296
- # Definition: def used
356
+ # File: memory.rb | Line: 60
357
+ # Definition: def used
297
358
  LinuxStat::Memory.used()
298
- => 3494236
359
+ => 2238924
299
360
 
300
361
  ```
301
362
 
302
363
  ### LinuxStat::Mounts
303
364
  ```
304
- # File: mounts.rb | Line: 179
305
- # Definition: def device_stat(dev = root)
365
+ # File: mounts.rb | Line: 179
366
+ # Definition: def device_stat(dev = root)
306
367
  LinuxStat::Mounts.device_stat(dev)
307
- => {:mountpoint=>"/", :total=>119981191168, :free=>52544036864, :available=>52544036864, :used=>67437154304, :percent_used=>56.21, :percent_free=>43.79, :percent_available=>43.79}
368
+ => {:mountpoint=>"/", :total=>119981191168, :free=>47937835008, :available=>47937835008, :used=>72043356160, :percent_used=>60.05, :percent_free=>39.95, :percent_available=>39.95}
308
369
 
309
- # File: mounts.rb | Line: 137
310
- # Definition: def devices_stat
370
+ # File: mounts.rb | Line: 137
371
+ # Definition: def devices_stat
311
372
  LinuxStat::Mounts.devices_stat()
312
373
  => {"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...
313
374
 
314
- # File: mounts.rb | Line: 11
315
- # Definition: def list
375
+ # File: mounts.rb | Line: 11
376
+ # Definition: def list
316
377
  LinuxStat::Mounts.list()
317
378
  => ["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", "...
318
379
 
319
- # File: mounts.rb | Line: 20
320
- # Definition: def list_devices
380
+ # File: mounts.rb | Line: 20
381
+ # Definition: def list_devices
321
382
  LinuxStat::Mounts.list_devices()
322
383
  => ["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...
323
384
 
324
- # File: mounts.rb | Line: 109
325
- # Definition: def list_devices_mount_point
385
+ # File: mounts.rb | Line: 109
386
+ # Definition: def list_devices_mount_point
326
387
  LinuxStat::Mounts.list_devices_mount_point()
327
- => {"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"=>"/...
388
+ => {"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/memory", "pstore"=>"...
328
389
 
329
- # File: mounts.rb | Line: 80
330
- # Definition: def mount_point(dev = root)
390
+ # File: mounts.rb | Line: 80
391
+ # Definition: def mount_point(dev = root)
331
392
  LinuxStat::Mounts.mount_point(dev)
332
393
  => "/"
333
394
 
334
- # File: mounts.rb | Line: 29
335
- # Definition: def root
395
+ # File: mounts.rb | Line: 29
396
+ # Definition: def root
336
397
  LinuxStat::Mounts.root()
337
398
  => "/dev/sda2"
338
399
 
339
- # File: mounts.rb | Line: 38
340
- # Definition: def root_fs
400
+ # File: mounts.rb | Line: 38
401
+ # Definition: def root_fs
341
402
  LinuxStat::Mounts.root_fs()
342
403
  => "xfs"
343
404
 
344
- # File: mounts.rb | Line: 47
345
- # Definition: def root_mount_options
405
+ # File: mounts.rb | Line: 47
406
+ # Definition: def root_mount_options
346
407
  LinuxStat::Mounts.root_mount_options()
347
408
  => "rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota"
348
409
 
349
- # File: mounts.rb | Line: 56
350
- # Definition: def tmpfs
410
+ # File: mounts.rb | Line: 56
411
+ # Definition: def tmpfs
351
412
  LinuxStat::Mounts.tmpfs()
352
- => {"/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"=>"...
413
+ => {"/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...
353
414
 
354
415
  ```
355
416
 
356
417
  ### LinuxStat::Net
357
418
  ```
358
- # File: net.rb | Line: 80
359
- # Definition: def usage(interval = 0.1)
419
+ # File: net.rb | Line: 80
420
+ # Definition: def usage(interval = 0.1)
360
421
  LinuxStat::Net.current_usage(interval)
361
422
  => {:received=>0.0, :transmitted=>0.0}
362
423
 
363
- # File: net.rb | Line: 10
364
- # Definition: def ipv4_private
424
+ # File: net.rb | Line: 10
425
+ # Definition: def ipv4_private
365
426
  LinuxStat::Net.ipv4_private()
366
427
  => "192.168.0.102"
367
428
 
368
- # File: net.rb | Line: 23
369
- # Definition: def total_bytes
429
+ # File: net.rb | Line: 23
430
+ # Definition: def total_bytes
370
431
  LinuxStat::Net.total_bytes()
371
- => {:received=>509728604, :transmitted=>38480016}
432
+ => {:received=>687677565, :transmitted=>149550163}
372
433
 
373
- # File: net.rb | Line: 41
374
- # Definition: def total_bytes_received
434
+ # File: net.rb | Line: 41
435
+ # Definition: def total_bytes_received
375
436
  LinuxStat::Net.total_bytes_received()
376
- => 509728604
437
+ => 687677565
377
438
 
378
- # File: net.rb | Line: 54
379
- # Definition: def total_bytes_transmitted
439
+ # File: net.rb | Line: 54
440
+ # Definition: def total_bytes_transmitted
380
441
  LinuxStat::Net.total_bytes_transmitted()
381
- => 38480016
442
+ => 149550163
382
443
 
383
- # File: net.rb | Line: 80
384
- # Definition: def usage(interval = 0.1)
444
+ # File: net.rb | Line: 80
445
+ # Definition: def usage(interval = 0.1)
385
446
  LinuxStat::Net.usage(interval)
386
447
  => {:received=>0.0, :transmitted=>0.0}
387
448
 
@@ -389,111 +450,111 @@ LinuxStat::Net.usage(interval)
389
450
 
390
451
  ### LinuxStat::OS
391
452
  ```
392
- # File: os.rb | Line: 97
393
- # Definition: def bits
453
+ # File: os.rb | Line: 97
454
+ # Definition: def bits
394
455
  LinuxStat::OS.bits()
395
456
  => 64
396
457
 
397
- # File: os.rb | Line: 42
398
- # Definition: def distribution
458
+ # File: os.rb | Line: 42
459
+ # Definition: def distribution
399
460
  LinuxStat::OS.distribution()
400
461
  => "Arch Linux"
401
462
 
402
- # File: os.rb | Line: 81
403
- # Definition: def hostname
463
+ # File: os.rb | Line: 81
464
+ # Definition: def hostname
404
465
  LinuxStat::OS.hostname()
405
466
  => "archlinux"
406
467
 
407
- # File: os.rb | Line: 30
408
- # Definition: def lsb_release
468
+ # File: os.rb | Line: 30
469
+ # Definition: def lsb_release
409
470
  LinuxStat::OS.lsb_release()
410
471
  => {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
411
472
 
412
- # File: os.rb | Line: 64
413
- # Definition: def machine
473
+ # File: os.rb | Line: 64
474
+ # Definition: def machine
414
475
  LinuxStat::OS.machine()
415
476
  => "x86_64"
416
477
 
417
- # File: os.rb | Line: 72
418
- # Definition: def nodename
478
+ # File: os.rb | Line: 72
479
+ # Definition: def nodename
419
480
  LinuxStat::OS.nodename()
420
481
  => "archlinux"
421
482
 
422
- # File: os.rb | Line: 15
423
- # Definition: def os_release
483
+ # File: os.rb | Line: 15
484
+ # Definition: def os_release
424
485
  LinuxStat::OS.os_release()
425
486
  => {: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/"...
426
487
 
427
- # File: os.rb | Line: 110
428
- # Definition: def uptime
488
+ # File: os.rb | Line: 110
489
+ # Definition: def uptime
429
490
  LinuxStat::OS.uptime()
430
- => {:hour=>5, :minute=>29, :second=>14.23}
491
+ => {:hour=>6, :minute=>50, :second=>39.61}
431
492
 
432
493
  ```
433
494
 
434
495
  ### LinuxStat::PrettifyBytes
435
496
  ```
436
- # File: prettify_bytes.rb | Line: 42
437
- # Definition: def convert_binary(n)
438
- LinuxStat::PrettifyBytes.convert_binary( = 139259240343413)
439
- => "126.66 tebibytes"
497
+ # File: prettify_bytes.rb | Line: 42
498
+ # Definition: def convert_binary(n)
499
+ LinuxStat::PrettifyBytes.convert_binary(n = 200152828322898)
500
+ => "182.04 tebibytes"
440
501
 
441
- # File: prettify_bytes.rb | Line: 19
442
- # Definition: def convert_decimal(n)
443
- LinuxStat::PrettifyBytes.convert_decimal( = 9064429892244)
444
- => "9.06 terabytes"
502
+ # File: prettify_bytes.rb | Line: 19
503
+ # Definition: def convert_decimal(n)
504
+ LinuxStat::PrettifyBytes.convert_decimal(n = 434440373786022)
505
+ => "434.44 terabytes"
445
506
 
446
- # File: prettify_bytes.rb | Line: 90
447
- # Definition: def convert_short_binary(n)
448
- LinuxStat::PrettifyBytes.convert_short_binary( = 768519163615746)
449
- => "698.96 TiB"
507
+ # File: prettify_bytes.rb | Line: 90
508
+ # Definition: def convert_short_binary(n)
509
+ LinuxStat::PrettifyBytes.convert_short_binary(n = 88309228425306)
510
+ => "80.32 TiB"
450
511
 
451
- # File: prettify_bytes.rb | Line: 65
452
- # Definition: def convert_short_decimal(n)
453
- LinuxStat::PrettifyBytes.convert_short_decimal( = 125226567793596)
454
- => "125.23 TB"
512
+ # File: prettify_bytes.rb | Line: 65
513
+ # Definition: def convert_short_decimal(n)
514
+ LinuxStat::PrettifyBytes.convert_short_decimal(n = 238518247519978)
515
+ => "238.52 TB"
455
516
 
456
517
  ```
457
518
 
458
519
  ### LinuxStat::Process
459
520
  ```
460
- # File: process.rb | Line: 19
461
- # Definition: def count
521
+ # File: process.rb | Line: 19
522
+ # Definition: def count
462
523
  LinuxStat::Process.count()
463
- => 202
524
+ => 195
464
525
 
465
- # File: process.rb | Line: 71
466
- # Definition: def idle
526
+ # File: process.rb | Line: 71
527
+ # Definition: def idle
467
528
  LinuxStat::Process.idle()
468
- => [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 119, 121, 131, 134, 140, 152, 153, 169, 171, 173, 174, 177, 178, 183, 184, 185, 186, 187, 188, 231, 271, 373, 383, 1001, 2553, 2554, 2555, 2556, 2557, 2558, 7770, 1...
529
+ => [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, 173, 175, 177, 180, 182, 186, 187, 188, 189, 190, 191, 193, 237, 273, 325, 329, 335, 9051, 9055, 9056, 9057, 9058, 9059, 9060, 13...
469
530
 
470
- # File: process.rb | Line: 8
471
- # Definition: def list
531
+ # File: process.rb | Line: 8
532
+ # Definition: def list
472
533
  LinuxStat::Process.list()
473
- => [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,...
534
+ => [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,...
474
535
 
475
- # File: process.rb | Line: 25
476
- # Definition: def names
536
+ # File: process.rb | Line: 25
537
+ # Definition: def names
477
538
  LinuxStat::Process.names()
478
539
  => {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...
479
540
 
480
- # File: process.rb | Line: 97
481
- # Definition: def running
541
+ # File: process.rb | Line: 97
542
+ # Definition: def running
482
543
  LinuxStat::Process.running()
483
- => [13667]
544
+ => [15978]
484
545
 
485
- # File: process.rb | Line: 58
486
- # Definition: def sleeping
546
+ # File: process.rb | Line: 58
547
+ # Definition: def sleeping
487
548
  LinuxStat::Process.sleeping()
488
- => [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,...
549
+ => [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, 172, 174, 192, 222, 238, 310, 311, 312, 313, 315, 324, 327, 332, 333, 334, 336, 347, 349, 351, 384, 412,...
489
550
 
490
- # File: process.rb | Line: 37
491
- # Definition: def types
551
+ # File: process.rb | Line: 37
552
+ # Definition: def types
492
553
  LinuxStat::Process.types()
493
554
  => {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...
494
555
 
495
- # File: process.rb | Line: 84
496
- # Definition: def zombie
556
+ # File: process.rb | Line: 84
557
+ # Definition: def zombie
497
558
  LinuxStat::Process.zombie()
498
559
  => []
499
560
 
@@ -501,151 +562,169 @@ LinuxStat::Process.zombie()
501
562
 
502
563
  ### LinuxStat::ProcessInfo
503
564
  ```
504
- # File: process_info.rb | Line: 54
505
- # Definition: def cmdline(pid = $$)
565
+ # File: process_info.rb | Line: 54
566
+ # Definition: def cmdline(pid = $$)
506
567
  LinuxStat::ProcessInfo.cmdline(pid)
507
- => "ruby /usr/bin/linuxstat.rb -md"
568
+ => "/usr/bin/ruby /home/sourav/.gem/ruby/2.7.0/bin/linuxstat.rb -md"
508
569
 
509
- # File: process_info.rb | Line: 78
510
- # Definition: def command_name(pid = $$)
570
+ # File: process_info.rb | Line: 78
571
+ # Definition: def command_name(pid = $$)
511
572
  LinuxStat::ProcessInfo.command_name(pid)
512
573
  => "ruby"
513
574
 
514
- # File: process_info.rb | Line: 247
515
- # Definition: def cpu_stat(pid: $$, sleep: ticks_to_ms)
575
+ # File: process_info.rb | Line: 640
576
+ # Definition: def nproc(pid = $$)
577
+ LinuxStat::ProcessInfo.count_cpu(pid)
578
+ => 4
579
+
580
+ # File: process_info.rb | Line: 247
581
+ # Definition: def cpu_stat(pid: $$, sleep: ticks_to_ms_t5)
516
582
  LinuxStat::ProcessInfo.cpu_stat(pid:, sleep:)
517
- => {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>1}
583
+ => {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>3}
518
584
 
519
- # File: process_info.rb | Line: 301
520
- # Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms)
585
+ # File: process_info.rb | Line: 307
586
+ # Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
521
587
  LinuxStat::ProcessInfo.cpu_usage(pid:, sleep:)
522
588
  => 0.0
523
589
 
524
- # File: process_info.rb | Line: 406
525
- # Definition: def gid(pid = $$)
590
+ # File: process_info.rb | Line: 470
591
+ # Definition: def gid(pid = $$)
526
592
  LinuxStat::ProcessInfo.gid(pid)
527
593
  => {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
528
594
 
529
- # File: process_info.rb | Line: 369
530
- # Definition: def last_executed_cpu(pid = $$)
595
+ # File: process_info.rb | Line: 433
596
+ # Definition: def last_executed_cpu(pid = $$)
531
597
  LinuxStat::ProcessInfo.last_executed_cpu(pid)
532
- => 1
598
+ => 3
533
599
 
534
- # File: process_info.rb | Line: 114
535
- # Definition: def mem_stat(pid = $$)
600
+ # File: process_info.rb | Line: 114
601
+ # Definition: def mem_stat(pid = $$)
536
602
  LinuxStat::ProcessInfo.mem_stat(pid)
537
- => {:memory=>12247.04, :virtual_memory=>83943.424, :resident_memory=>18116.608}
603
+ => {:memory=>12627.968, :virtual_memory=>84221.952, :resident_memory=>18743.296}
538
604
 
539
- # File: process_info.rb | Line: 147
540
- # Definition: def memory(pid = $$)
605
+ # File: process_info.rb | Line: 147
606
+ # Definition: def memory(pid = $$)
541
607
  LinuxStat::ProcessInfo.memory(pid)
542
- => 12247.04
608
+ => 12627.968
543
609
 
544
- # File: process_info.rb | Line: 540
545
- # Definition: def nice(pid = $$)
610
+ # File: process_info.rb | Line: 607
611
+ # Definition: def nice(pid = $$)
546
612
  LinuxStat::ProcessInfo.nice(pid)
547
613
  => 0
548
614
 
549
- # File: process_info.rb | Line: 427
550
- # Definition: def owner(pid = $$)
615
+ # File: process_info.rb | Line: 640
616
+ # Definition: def nproc(pid = $$)
617
+ LinuxStat::ProcessInfo.nproc(pid)
618
+ => 4
619
+
620
+ # File: process_info.rb | Line: 491
621
+ # Definition: def owner(pid = $$)
551
622
  LinuxStat::ProcessInfo.owner(pid)
552
623
  => "sourav"
553
624
 
554
- # File: process_info.rb | Line: 197
555
- # Definition: def resident_memory(pid = $$)
625
+ # File: process_info.rb | Line: 197
626
+ # Definition: def resident_memory(pid = $$)
556
627
  LinuxStat::ProcessInfo.resident_memory(pid)
557
- => 18116.608
628
+ => 18743.296
558
629
 
559
- # File: process_info.rb | Line: 497
560
- # Definition: def running_time(pid = $$)
630
+ # File: process_info.rb | Line: 563
631
+ # Definition: def running_time(pid = $$)
561
632
  LinuxStat::ProcessInfo.running_time(pid)
562
- => 1.2999999999992724
633
+ => 0.8
563
634
 
564
- # File: process_info.rb | Line: 480
565
- # Definition: def start_time(pid = $$)
635
+ # File: process_info.rb | Line: 544
636
+ # Definition: def start_time(pid = $$)
566
637
  LinuxStat::ProcessInfo.start_time(pid)
567
- => 2020-12-17 16:36:46 +0530
638
+ => 2020-12-24 19:05:51 +0530
568
639
 
569
- # File: process_info.rb | Line: 449
570
- # Definition: def start_time_epoch(pid = $$)
640
+ # File: process_info.rb | Line: 513
641
+ # Definition: def start_time_epoch(pid = $$)
571
642
  LinuxStat::ProcessInfo.start_time_epoch(pid)
572
- => 1608203206
643
+ => 1608816951
573
644
 
574
- # File: process_info.rb | Line: 525
575
- # Definition: def state(pid = $$)
645
+ # File: process_info.rb | Line: 592
646
+ # Definition: def state(pid = $$)
576
647
  LinuxStat::ProcessInfo.state(pid)
577
648
  => "R"
578
649
 
579
- # File: process_info.rb | Line: 344
580
- # Definition: def threads(pid = $$)
650
+ # File: process_info.rb | Line: 359
651
+ # Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
652
+ LinuxStat::ProcessInfo.thread_usage(pid:, sleep:)
653
+ => 0.0
654
+
655
+ # File: process_info.rb | Line: 408
656
+ # Definition: def threads(pid = $$)
581
657
  LinuxStat::ProcessInfo.threads(pid)
582
658
  => 1
583
659
 
584
- # File: process_info.rb | Line: 23
585
- # Definition: def total_io(pid = $$)
660
+ # File: process_info.rb | Line: 23
661
+ # Definition: def total_io(pid = $$)
586
662
  LinuxStat::ProcessInfo.total_io(pid)
587
663
  => {:read_bytes=>0, :write_bytes=>0}
588
664
 
589
- # File: process_info.rb | Line: 382
590
- # Definition: def uid(pid = $$)
665
+ # File: process_info.rb | Line: 446
666
+ # Definition: def uid(pid = $$)
591
667
  LinuxStat::ProcessInfo.uid(pid)
592
668
  => {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
593
669
 
594
- # File: process_info.rb | Line: 172
595
- # Definition: def virtual_memory(pid = $$)
670
+ # File: process_info.rb | Line: 172
671
+ # Definition: def virtual_memory(pid = $$)
596
672
  LinuxStat::ProcessInfo.virtual_memory(pid)
597
- => 83943.424
673
+ => 84221.952
598
674
 
599
675
  ```
600
676
 
601
677
  ### LinuxStat::Swap
602
678
  ```
603
- # File: swap.rb | Line: 22
604
- # Definition: def any?
679
+ # File: swap.rb | Line: 22
680
+ # Definition: def any?
605
681
  LinuxStat::Swap.any?()
606
682
  => true
607
683
 
608
- # File: swap.rb | Line: 68
609
- # Definition: def available
684
+ # File: swap.rb | Line: 68
685
+ # Definition: def available
610
686
  LinuxStat::Swap.available()
611
- => 3100412
687
+ => 4064380
612
688
 
613
- # File: swap.rb | Line: 8
614
- # Definition: def list
689
+ # File: swap.rb | Line: 8
690
+ # Definition: def list
615
691
  LinuxStat::Swap.list()
616
- => {"/dev/zram0"=>[:partition, 4194300, 1093888, -2]}
692
+ => {"/dev/zram0"=>[:partition, 4194300, 129920, -2]}
617
693
 
618
- # File: swap.rb | Line: 103
619
- # Definition: def percent_available
694
+ # File: swap.rb | Line: 103
695
+ # Definition: def percent_available
620
696
  LinuxStat::Swap.percent_available()
621
- => 73.92
697
+ => 96.9
622
698
 
623
- # File: swap.rb | Line: 89
624
- # Definition: def percent_used
699
+ # File: swap.rb | Line: 89
700
+ # Definition: def percent_used
625
701
  LinuxStat::Swap.percent_used()
626
- => 26.08
702
+ => 3.1
627
703
 
628
- # File: swap.rb | Line: 32
629
- # Definition: def stat
704
+ # File: swap.rb | Line: 32
705
+ # Definition: def stat
630
706
  LinuxStat::Swap.stat()
631
- => {:total=>4194300, :used=>1093888, :available=>3100412, :percent_used=>26.08, :percent_available=>73.92}
707
+ => {:total=>4194300, :used=>129920, :available=>4064380, :percent_used=>3.1, :percent_available=>96.9}
632
708
 
633
- # File: swap.rb | Line: 57
634
- # Definition: def total
709
+ # File: swap.rb | Line: 57
710
+ # Definition: def total
635
711
  LinuxStat::Swap.total()
636
712
  => 4194300
637
713
 
638
- # File: swap.rb | Line: 80
639
- # Definition: def used
714
+ # File: swap.rb | Line: 80
715
+ # Definition: def used
640
716
  LinuxStat::Swap.used()
641
- => 1093888
717
+ => 129920
642
718
 
643
719
  ```
644
720
 
645
721
  ### LinuxStat::Sysconf
646
722
  ```
647
723
  LinuxStat::Sysconf.child_max()
648
- => 2000000
724
+ => nil
725
+
726
+ LinuxStat::Sysconf.expr_nest_max()
727
+ => 32
649
728
 
650
729
  LinuxStat::Sysconf.get_euid()
651
730
  => 1000
@@ -665,17 +744,26 @@ LinuxStat::Sysconf.get_user()
665
744
  LinuxStat::Sysconf.hostname_max()
666
745
  => 64
667
746
 
747
+ LinuxStat::Sysconf.line_max()
748
+ => 2048
749
+
668
750
  LinuxStat::Sysconf.login_name_max()
669
751
  => 256
670
752
 
671
753
  LinuxStat::Sysconf.open_max()
672
- => 8192
754
+ => 1024
673
755
 
674
756
  LinuxStat::Sysconf.pagesize()
675
757
  => 4096
676
758
 
677
759
  LinuxStat::Sysconf.posix_version()
678
- => 200809
760
+ => 4201
761
+
762
+ LinuxStat::Sysconf.processor_configured()
763
+ => 4
764
+
765
+ LinuxStat::Sysconf.processor_online()
766
+ => 4
679
767
 
680
768
  LinuxStat::Sysconf.sc_clk_tck()
681
769
  => 100
@@ -688,6 +776,25 @@ LinuxStat::Sysconf.tty_name_max()
688
776
 
689
777
  ```
690
778
 
779
+ ### LinuxStat::USB
780
+ ```
781
+ # File: usb.rb | Line: 74
782
+ # Definition: def count
783
+ LinuxStat::USB.count()
784
+ => 10
785
+
786
+ # File: usb.rb | Line: 74
787
+ # Definition: def count
788
+ LinuxStat::USB.count_devices()
789
+ => 10
790
+
791
+ # File: usb.rb | Line: 4
792
+ # Definition: def devices_stat(hwdata: true)
793
+ LinuxStat::USB.devices_stat(hwdata:)
794
+ => [{:path=>"/sys/bus/usb/devices/1-1.2/", :id=>"04d9:1203", :vendor_id=>"04d9", :product_id=>"1203", :bus_num=>1, :dev_num=>4, :hwdata=>{:vendor=>"Holtek Semiconductor, Inc.", :product=>"Keyboard"}, :authorized=>true, :b_max_power=>"100mA", :b_max_packe...
795
+
796
+ ```
797
+
691
798
  ### LinuxStat::Uname
692
799
  ```
693
800
  LinuxStat::Uname.machine()
@@ -709,93 +816,93 @@ LinuxStat::Uname.version()
709
816
 
710
817
  ### LinuxStat::User
711
818
  ```
712
- # File: user.rb | Line: 98
713
- # Definition: def get_user
819
+ # File: user.rb | Line: 98
820
+ # Definition: def get_user
714
821
  LinuxStat::User.get_current_user()
715
822
  => "sourav"
716
823
 
717
- # File: user.rb | Line: 137
718
- # Definition: def get_euid
824
+ # File: user.rb | Line: 137
825
+ # Definition: def get_euid
719
826
  LinuxStat::User.get_euid()
720
827
  => 1000
721
828
 
722
- # File: user.rb | Line: 129
723
- # Definition: def get_gid
829
+ # File: user.rb | Line: 129
830
+ # Definition: def get_gid
724
831
  LinuxStat::User.get_gid()
725
832
  => 1000
726
833
 
727
- # File: user.rb | Line: 152
728
- # Definition: def get_login
834
+ # File: user.rb | Line: 152
835
+ # Definition: def get_login
729
836
  LinuxStat::User.get_login()
730
837
  => "sourav"
731
838
 
732
- # File: user.rb | Line: 121
733
- # Definition: def get_uid
839
+ # File: user.rb | Line: 121
840
+ # Definition: def get_uid
734
841
  LinuxStat::User.get_uid()
735
842
  => 1000
736
843
 
737
- # File: user.rb | Line: 98
738
- # Definition: def get_user
844
+ # File: user.rb | Line: 98
845
+ # Definition: def get_user
739
846
  LinuxStat::User.get_user()
740
847
  => "sourav"
741
848
 
742
- # File: user.rb | Line: 215
743
- # Definition: def gid_by_username(username = get_user)
849
+ # File: user.rb | Line: 215
850
+ # Definition: def gid_by_username(username = get_user)
744
851
  LinuxStat::User.gid_by_username(username)
745
852
  => 1000
746
853
 
747
- # File: user.rb | Line: 56
748
- # Definition: def gids
854
+ # File: user.rb | Line: 56
855
+ # Definition: def gids
749
856
  LinuxStat::User.gids()
750
857
  => {: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, :...
751
858
 
752
- # File: user.rb | Line: 314
753
- # Definition: def home_by_gid(id = get_gid)
859
+ # File: user.rb | Line: 314
860
+ # Definition: def home_by_gid(id = get_gid)
754
861
  LinuxStat::User.home_by_gid(id)
755
862
  => "/home/sourav"
756
863
 
757
- # File: user.rb | Line: 266
758
- # Definition: def home_by_username(user = get_user)
864
+ # File: user.rb | Line: 266
865
+ # Definition: def home_by_username(user = get_user)
759
866
  LinuxStat::User.home_by_username(user)
760
867
  => "/home/sourav"
761
868
 
762
- # File: user.rb | Line: 72
763
- # Definition: def home_directories
869
+ # File: user.rb | Line: 72
870
+ # Definition: def home_directories
764
871
  LinuxStat::User.home_directories()
765
872
  => {: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...
766
873
 
767
- # File: user.rb | Line: 293
768
- # Definition: def homes_by_uid(id = get_uid)
874
+ # File: user.rb | Line: 293
875
+ # Definition: def homes_by_uid(id = get_uid)
769
876
  LinuxStat::User.homes_by_uid(id)
770
877
  => ["/home/sourav"]
771
878
 
772
- # File: user.rb | Line: 23
773
- # Definition: def ids
879
+ # File: user.rb | Line: 23
880
+ # Definition: def ids
774
881
  LinuxStat::User.ids()
775
882
  => {: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...
776
883
 
777
- # File: user.rb | Line: 11
778
- # Definition: def list
884
+ # File: user.rb | Line: 11
885
+ # Definition: def list
779
886
  LinuxStat::User.list()
780
887
  => ["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...
781
888
 
782
- # File: user.rb | Line: 244
783
- # Definition: def uid_by_username(username = get_user)
889
+ # File: user.rb | Line: 244
890
+ # Definition: def uid_by_username(username = get_user)
784
891
  LinuxStat::User.uid_by_username(username)
785
892
  => 1000
786
893
 
787
- # File: user.rb | Line: 40
788
- # Definition: def uids
894
+ # File: user.rb | Line: 40
895
+ # Definition: def uids
789
896
  LinuxStat::User.uids()
790
897
  => {: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...
791
898
 
792
- # File: user.rb | Line: 187
793
- # Definition: def username_by_gid(gid = get_gid)
899
+ # File: user.rb | Line: 187
900
+ # Definition: def username_by_gid(gid = get_gid)
794
901
  LinuxStat::User.username_by_gid(gid)
795
902
  => "sourav"
796
903
 
797
- # File: user.rb | Line: 169
798
- # Definition: def usernames_by_uid(uid = get_uid)
904
+ # File: user.rb | Line: 169
905
+ # Definition: def usernames_by_uid(uid = get_uid)
799
906
  LinuxStat::User.usernames_by_uid(uid)
800
907
  => ["sourav"]
801
908
 
@@ -867,7 +974,120 @@ well as soon as the Linux kernel updates the data and ruby executes the loop.
867
974
 
868
975
  Just run the linuxstat.rb command to test what method takes what time measured in microseconds.
869
976
 
870
- ## Note 2: Filesystem
977
+ ## Note 2: Count CPU
978
+
979
+ There are confusingly 6 different methods to count the number of CPU. But they are here for a reason!
980
+
981
+ Well this section actually demystifies the methods.
982
+
983
+ 1. The good old `LinuxStat::CPU.count()`:
984
+
985
+ It gets the configured CPU for the system. It doesn't count for hotplugged CPU.
986
+ If 3 out of 4 CPU are hotplugged out, it will still show 4. It calles `sysconf(_SC_NPROCESSORS_CONF)`
987
+
988
+ 2. The mysterious `LinuxStat::ProcessInfo.nproc(pid = $$)`:
989
+
990
+ [ Also aliased to `LinuxStat::ProcessInfo.count_cpu()` ]
991
+
992
+ It returns the number of processors, like the other 3 methods.
993
+ Without any arguments, it's like running `require 'etc' ; puts Etc.nprocessors`
994
+
995
+ So there the caveat of checking what the number of processors are actually allocated to the pid.
996
+
997
+ For example:
998
+
999
+ ```
1000
+ $ ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
1001
+ 4
1002
+
1003
+ $ taskset -c 0 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
1004
+ 1
1005
+
1006
+ $ taskset -c 0-1 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
1007
+ 2
1008
+
1009
+ $ taskset -c 0-1,3 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
1010
+ 3
1011
+
1012
+ $ taskset -c 0-1,3 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc "
1013
+ 3
1014
+ ```
1015
+
1016
+ Or with argument:
1017
+
1018
+ ```
1019
+ irb(main):001:0> require 'linux_stat'
1020
+ => true
1021
+
1022
+ irb(main):002:0> LinuxStat::ProcessInfo.command_name 4775
1023
+ => "electron"
1024
+
1025
+ irb(main):003:0> LinuxStat::ProcessInfo.nproc 4775
1026
+ => 4
1027
+ ```
1028
+
1029
+ 3. The `LinuxStat::CPU.online()`:
1030
+
1031
+ This returns the number of online CPU as an Array. It doesn't get affected by taskset or anything.
1032
+
1033
+ For example:
1034
+
1035
+ ```
1036
+ irb(main):001:0> require 'linux_stat'
1037
+ => true
1038
+
1039
+ irb(main):002:0> LinuxStat::CPU.online
1040
+ => [0, 1, 3]
1041
+ ```
1042
+
1043
+ By using `LinuxStat::CPU.online.count` you count the actual online CPU on your system.
1044
+
1045
+ Any n number of CPU can get hotplugged in and out, and this will report that correctly.
1046
+
1047
+ It just gets the info from /proc/stat; but if it fails it will read /sys/devices/system/cpu/online
1048
+ and parse the output to get an array.
1049
+
1050
+ 4. The `LinuxStat::CPU.count_online`
1051
+ It's a more robust method that counts the online CPU. It shouldn't fail in most if not all cases!
1052
+ But if it fails for some really spooky reasons, it will return nil.
1053
+
1054
+ 4. The `LinuxStat::CPU.offline()`:
1055
+
1056
+ This returns the number of offline CPU as an Array. It doesn't get affected by taskset or anything.
1057
+
1058
+ For example:
1059
+
1060
+ ```
1061
+ irb(main):001:0> require 'linux_stat'
1062
+ => true
1063
+
1064
+ irb(main):002:0> LinuxStat::CPU.offline
1065
+ => [2]
1066
+ ```
1067
+
1068
+ Any n number of CPU can get hotplugged in and out, and this will report that correctly.
1069
+
1070
+ It just gets the info from /sys/devices/system/cpu/offline, and parses the output.
1071
+
1072
+ 5. The `LinuxStat::Sysconf.processor_configured()`:
1073
+
1074
+ Sounds repetitive! Actually yes, this is written in C, and it is called by `LinuxStat::CPU.count`.
1075
+
1076
+ The difference is that `LinuxStat::CPU.count` caches the return value, and this method doesn't.
1077
+
1078
+ 6. The `LinuxStat::Sysconf.processor_online()`:
1079
+
1080
+ This may again sound repititive to LinuxStat::CPU.online, but it's actually not!
1081
+
1082
+ If you are using while loops, it might not report the correct number of CPU everytime.
1083
+
1084
+ Worst, it can take a long time to update the total number of CPU.
1085
+
1086
+ The benefit is, it's quite fast!
1087
+
1088
+ It's mostly here just for the sake of completeness to sysconf.
1089
+
1090
+ ## Note 3: Filesystem
871
1091
 
872
1092
  Filesystem can take arguments. By default it's '/' or the root of the system...
873
1093
 
@@ -902,7 +1122,7 @@ irb(main):005:0> LinuxStat::Filesystem.total(thumbdrive).fdiv(1024 ** 3).to_s <<
902
1122
  => "29.305004119873047 GiB"
903
1123
  ```
904
1124
 
905
- ## Note 3: ProcessInfo
1125
+ ## Note 4: ProcessInfo
906
1126
 
907
1127
  All the methods LinuxStat::ProcessInfo can take an argument containing the Process ID of a process.
908
1128
  By default it's $$ or the PID of the current process, ruby, itself.
@@ -954,7 +1174,7 @@ irb(main):002:0> LinuxStat::ProcessInfo.memory(LinuxStat::Process.names.find { |
954
1174
  => "467.51 MiB"
955
1175
  ```
956
1176
 
957
- ## Note 4: FS
1177
+ ## Note 5: FS
958
1178
 
959
1179
  LinuxStat::FS module gives you the raw info in Hash collected from statvfs.
960
1180
 
@@ -979,7 +1199,7 @@ irb(main):003:0> t = Time.now ; puts LinuxStat::FS.stat('/') ; Time.now - t
979
1199
 
980
1200
  To learn more about them, just run ri and the method name. To see all available methods.
981
1201
 
982
- ## Note 5: User
1202
+ ## Note 6: User
983
1203
  Most of the LinuxStat::User supports arguments.
984
1204
 
985
1205
  For example, to get a user's home by the username:
@@ -1061,7 +1281,7 @@ irb(main):004:0> LinuxStat::User.get_login
1061
1281
 
1062
1282
  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.
1063
1283
 
1064
- ## Note 6: PrettifyBytes
1284
+ ## Note 7: PrettifyBytes
1065
1285
  Often times we need to work with KB, MB GB, TB, or KiB, MiB, GiB, TiB, etc.
1066
1286
  And we need some work to convert bytes to those units.
1067
1287
  Because LinuxStat provides a lot of data in bytes, and kilobytes, it's quite tedious to convert them all the time.
@@ -1201,6 +1421,16 @@ Issues regarding running LinuxStat on termux are also welcomed.
1201
1421
 
1202
1422
  ---
1203
1423
 
1424
+ ## Cloning this Repo
1425
+ Users of this gem are requested to follow the above installation step to install this gem.
1426
+
1427
+ This repo is only for development purpose. It has C extensions that could do worst to your stable app.
1428
+ Cloning, compiling code from this repo for a production app may seg fault and crash the whole app directly.
1429
+
1430
+ Gems on Rubygems are released after various tests.
1431
+
1432
+ 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.
1433
+
1204
1434
  ## Development
1205
1435
  After checking out the repo, compile and install this gem onto your local machine with `bundle exec rake install`
1206
1436