linux_stat 0.8.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +524 -324
- data/exe/linuxstat.rb +34 -13
- data/ext/fs_stat/fs_stat.c +4 -2
- data/ext/nproc/extconf.rb +11 -0
- data/ext/nproc/nproc.c +31 -0
- data/ext/sysconf/sysconf.c +58 -17
- data/ext/utsname/utsname.c +4 -2
- data/lib/linux_stat.rb +8 -1
- data/lib/linux_stat/battery.rb +183 -20
- data/lib/linux_stat/cpu.rb +207 -44
- data/lib/linux_stat/filesystem.rb +12 -12
- data/lib/linux_stat/kernel.rb +1 -1
- data/lib/linux_stat/mounts.rb +4 -4
- data/lib/linux_stat/os.rb +2 -2
- data/lib/linux_stat/process.rb +1 -1
- data/lib/linux_stat/process_info.rb +70 -14
- data/lib/linux_stat/swap.rb +1 -1
- data/lib/linux_stat/usb.rb +192 -0
- data/lib/linux_stat/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2b9ce6001721fb53594609195cab131b1012257ecc8ec8705d80bbfad10e930
|
4
|
+
data.tar.gz: 0aeb2d9b11d871ffd82cd48ee8ca08b94620db5fd6e59c1d2b450c906b7da589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d0f539696f3b58aa068c97636517c3f813b3359e8f45ac4a7f08f642d2c3478be5ca8998f2a293919b703900f3e5a8ea7a7b57b72ee0f58e2c6d783760c30cb
|
7
|
+
data.tar.gz: 769195f4ea410fb4a856344632cd5fd0f191d40e3fb022ce0868c31723cdb203797c20357b9c022e1bb3e21f6c33b3a3275a852ed8abf78dc1cf7b6b1b9c6d80
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# LinuxStat [](https://rubygems.org/gems/linux_stat) 
|
2
2
|
|
3
|
+
---
|
4
|
+
|
3
5
|

|
4
6
|
|
5
7
|
For reading the eyecandy HTML version, visit [linux_stat](https://souravgoswami.github.io/linux_stat/).
|
@@ -8,13 +10,9 @@ LinuxStat lets you read status of a Linux system. It can show you cpu stats and
|
|
8
10
|
|
9
11
|
It only works for Linux, and detecting the OS is upto the user of this gem.
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
## Source LOC (no comments / blank lines are counted):
|
13
|
+
Programming Languages Used:
|
14
14
|
|
15
|
-
<
|
16
|
-
<img src="https://linuxstatloc.herokuapp.com/badge.svg" width="360px">
|
17
|
-
</div>
|
15
|
+
<img src="https://linuxstatloc.herokuapp.com/badge.svg" width="260px">
|
18
16
|
|
19
17
|
---
|
20
18
|
|
@@ -56,25 +54,30 @@ Or install it yourself as:
|
|
56
54
|
$ gem install linux_stat
|
57
55
|
|
58
56
|
## Usage
|
57
|
+
Following are the LinuxStat modules and module functions.
|
58
|
+
It's generated by linuxstat.rb command, which is available after the installation.
|
59
|
+
|
60
|
+
For ease of use, LinuxStat is also assigned to the LS constant.
|
61
|
+
|
59
62
|
### LinuxStat::BIOS
|
60
63
|
```
|
61
|
-
# File:
|
62
|
-
# Definition:
|
64
|
+
# File: bios.rb | Line: 56
|
65
|
+
# Definition: def date
|
63
66
|
LinuxStat::BIOS.date()
|
64
67
|
=> "04/10/2017"
|
65
68
|
|
66
|
-
# File:
|
67
|
-
# Definition:
|
69
|
+
# File: bios.rb | Line: 10
|
70
|
+
# Definition: def model
|
68
71
|
LinuxStat::BIOS.model()
|
69
72
|
=> "Inspiron 5567"
|
70
73
|
|
71
|
-
# File:
|
72
|
-
# Definition:
|
74
|
+
# File: bios.rb | Line: 27
|
75
|
+
# Definition: def vendor
|
73
76
|
LinuxStat::BIOS.vendor()
|
74
77
|
=> "Dell Inc."
|
75
78
|
|
76
|
-
# File:
|
77
|
-
# Definition:
|
79
|
+
# File: bios.rb | Line: 42
|
80
|
+
# Definition: def version
|
78
81
|
LinuxStat::BIOS.version()
|
79
82
|
=> "1.1.2"
|
80
83
|
|
@@ -82,197 +85,242 @@ LinuxStat::BIOS.version()
|
|
82
85
|
|
83
86
|
### LinuxStat::Battery
|
84
87
|
```
|
85
|
-
# File:
|
86
|
-
# Definition:
|
88
|
+
# File: battery.rb | Line: 105
|
89
|
+
# Definition: def charge
|
87
90
|
LinuxStat::Battery.charge()
|
88
91
|
=> 100.0
|
89
92
|
|
90
|
-
# File:
|
91
|
-
# Definition:
|
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?
|
92
105
|
LinuxStat::Battery.charging?()
|
93
106
|
=> true
|
94
107
|
|
95
|
-
# File:
|
96
|
-
# Definition:
|
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?
|
97
115
|
LinuxStat::Battery.discharging?()
|
98
116
|
=> false
|
99
117
|
|
100
|
-
# File:
|
101
|
-
# Definition:
|
118
|
+
# File: battery.rb | Line: 96
|
119
|
+
# Definition: def full?
|
102
120
|
LinuxStat::Battery.full?()
|
103
121
|
=> true
|
104
122
|
|
105
|
-
# File:
|
106
|
-
# Definition:
|
123
|
+
# File: battery.rb | Line: 47
|
124
|
+
# Definition: def manufacturer
|
107
125
|
LinuxStat::Battery.manufacturer()
|
108
126
|
=> "Samsung SDI"
|
109
127
|
|
110
|
-
# File:
|
111
|
-
# Definition:
|
128
|
+
# File: battery.rb | Line: 36
|
129
|
+
# Definition: def model
|
112
130
|
LinuxStat::Battery.model()
|
113
131
|
=> "DELL CYMGM77"
|
114
132
|
|
115
|
-
# File:
|
116
|
-
# Definition:
|
133
|
+
# File: battery.rb | Line: 8
|
134
|
+
# Definition: def present?
|
117
135
|
LinuxStat::Battery.present?()
|
118
136
|
=> true
|
119
137
|
|
120
|
-
# File:
|
121
|
-
# Definition:
|
138
|
+
# File: battery.rb | Line: 16
|
139
|
+
# Definition: def stat
|
122
140
|
LinuxStat::Battery.stat()
|
123
141
|
=> {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Full", :charge=>100.0, :charging=>true, :discharging=>false, :full=>true}
|
124
142
|
|
125
|
-
# File:
|
126
|
-
# Definition:
|
143
|
+
# File: battery.rb | Line: 68
|
144
|
+
# Definition: def status
|
127
145
|
LinuxStat::Battery.status()
|
128
146
|
=> "Full"
|
129
147
|
|
130
|
-
# File:
|
131
|
-
# Definition:
|
148
|
+
# File: battery.rb | Line: 57
|
149
|
+
# Definition: def technology
|
132
150
|
LinuxStat::Battery.technology()
|
133
151
|
=> "Li-ion"
|
134
152
|
|
153
|
+
# File: battery.rb | Line: 160
|
154
|
+
# Definition: def voltage_now
|
155
|
+
LinuxStat::Battery.voltage_now()
|
156
|
+
=> 12.453
|
157
|
+
|
135
158
|
```
|
136
159
|
|
137
160
|
### LinuxStat::CPU
|
138
161
|
```
|
139
|
-
# File:
|
140
|
-
# Definition:
|
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
|
141
169
|
LinuxStat::CPU.count()
|
142
170
|
=> 4
|
143
171
|
|
144
|
-
# File:
|
145
|
-
# Definition:
|
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
|
146
179
|
LinuxStat::CPU.cur_freq()
|
147
|
-
=>
|
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"}
|
148
186
|
|
149
|
-
# File:
|
150
|
-
# Definition:
|
187
|
+
# File: cpu.rb | Line: 241
|
188
|
+
# Definition: def max_freq
|
151
189
|
LinuxStat::CPU.max_freq()
|
152
|
-
=>
|
190
|
+
=> {"cpu0"=>2000000, "cpu1"=>2000000, "cpu2"=>2000000, "cpu3"=>2000000}
|
191
|
+
|
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}
|
153
196
|
|
154
|
-
# File:
|
155
|
-
# Definition:
|
197
|
+
# File: cpu.rb | Line: 184
|
198
|
+
# Definition: def model
|
156
199
|
LinuxStat::CPU.model()
|
157
200
|
=> "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
|
158
201
|
|
159
|
-
# File:
|
160
|
-
# Definition:
|
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
|
161
209
|
LinuxStat::CPU.online()
|
162
|
-
=>
|
210
|
+
=> [0, 1, 2, 3]
|
163
211
|
|
164
|
-
# File:
|
165
|
-
# Definition:
|
212
|
+
# File: cpu.rb | Line: 23
|
213
|
+
# Definition: def stat(sleep = ticks_to_ms_t5)
|
166
214
|
LinuxStat::CPU.stat(sleep)
|
167
|
-
=> {0=>5.
|
215
|
+
=> {0=>5.0, 1=>16.67, 2=>0.0, 3=>0.0, 4=>16.67}
|
168
216
|
|
169
|
-
# File:
|
170
|
-
# Definition:
|
217
|
+
# File: cpu.rb | Line: 63
|
218
|
+
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
171
219
|
LinuxStat::CPU.total_usage(sleep)
|
172
|
-
=>
|
220
|
+
=> 5.26
|
173
221
|
|
174
|
-
# File:
|
175
|
-
# Definition:
|
222
|
+
# File: cpu.rb | Line: 63
|
223
|
+
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
176
224
|
LinuxStat::CPU.usage(sleep)
|
177
|
-
=>
|
225
|
+
=> 9.52
|
178
226
|
|
179
|
-
# File:
|
180
|
-
# Definition:
|
227
|
+
# File: cpu.rb | Line: 23
|
228
|
+
# Definition: def stat(sleep = ticks_to_ms_t5)
|
181
229
|
LinuxStat::CPU.usages(sleep)
|
182
|
-
=> {0=>
|
230
|
+
=> {0=>5.26, 1=>16.67, 2=>0.0, 3=>0.0, 4=>0.0}
|
183
231
|
|
184
232
|
```
|
185
233
|
|
186
234
|
### LinuxStat::FS
|
187
235
|
```
|
188
236
|
LinuxStat::FS.stat(arg = "/")
|
189
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>
|
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}
|
190
238
|
|
191
239
|
```
|
192
240
|
|
193
241
|
### LinuxStat::Filesystem
|
194
242
|
```
|
195
|
-
# File:
|
196
|
-
# Definition:
|
243
|
+
# File: filesystem.rb | Line: 92
|
244
|
+
# Definition: def available(fs = ?..freeze)
|
197
245
|
LinuxStat::Filesystem.available(fs)
|
198
|
-
=>
|
246
|
+
=> 47937835008
|
199
247
|
|
200
|
-
# File:
|
201
|
-
# Definition:
|
248
|
+
# File: filesystem.rb | Line: 58
|
249
|
+
# Definition: def free(fs = ?..freeze)
|
202
250
|
LinuxStat::Filesystem.free(fs)
|
203
|
-
=>
|
251
|
+
=> 47937835008
|
204
252
|
|
205
|
-
# File:
|
206
|
-
# Definition:
|
253
|
+
# File: filesystem.rb | Line: 19
|
254
|
+
# Definition: def stat(fs = ?..freeze)
|
207
255
|
LinuxStat::Filesystem.stat(fs)
|
208
|
-
=> {:total=>119981191168, :free=>
|
256
|
+
=> {:total=>119981191168, :free=>47937835008, :used=>72043356160}
|
209
257
|
|
210
|
-
# File:
|
211
|
-
# Definition:
|
258
|
+
# File: filesystem.rb | Line: 108
|
259
|
+
# Definition: def stat_raw(fs = ?..freeze)
|
212
260
|
LinuxStat::Filesystem.stat_raw(fs)
|
213
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>
|
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}
|
214
262
|
|
215
|
-
# File:
|
216
|
-
# Definition:
|
263
|
+
# File: filesystem.rb | Line: 39
|
264
|
+
# Definition: def total(fs = ?..freeze)
|
217
265
|
LinuxStat::Filesystem.total(fs)
|
218
266
|
=> 119981191168
|
219
267
|
|
220
|
-
# File:
|
221
|
-
# Definition:
|
268
|
+
# File: filesystem.rb | Line: 73
|
269
|
+
# Definition: def used(fs = ?..freeze)
|
222
270
|
LinuxStat::Filesystem.used(fs)
|
223
|
-
=>
|
271
|
+
=> 72043356160
|
224
272
|
|
225
273
|
```
|
226
274
|
|
227
275
|
### LinuxStat::Kernel
|
228
276
|
```
|
229
|
-
# File:
|
230
|
-
# Definition:
|
277
|
+
# File: kernel.rb | Line: 86
|
278
|
+
# Definition: def build_date
|
231
279
|
LinuxStat::Kernel.build_date()
|
232
280
|
=> 2020-11-20 07:44:55 +0000
|
233
281
|
|
234
|
-
# File:
|
235
|
-
# Definition:
|
282
|
+
# File: kernel.rb | Line: 140
|
283
|
+
# Definition: def build_date_string
|
236
284
|
LinuxStat::Kernel.build_date_string()
|
237
285
|
=> "20 Nov 2020 07:44:55 +0000"
|
238
286
|
|
239
|
-
# File:
|
240
|
-
# Definition:
|
287
|
+
# File: kernel.rb | Line: 21
|
288
|
+
# Definition: def build_user
|
241
289
|
LinuxStat::Kernel.build_user()
|
242
290
|
=> "souravgoswami@archlinux"
|
243
291
|
|
244
|
-
# File:
|
245
|
-
# Definition:
|
292
|
+
# File: kernel.rb | Line: 179
|
293
|
+
# Definition: def ticks
|
246
294
|
LinuxStat::Kernel.clk_tck()
|
247
295
|
=> 100
|
248
296
|
|
249
|
-
# File:
|
250
|
-
# Definition:
|
297
|
+
# File: kernel.rb | Line: 33
|
298
|
+
# Definition: def compiler
|
251
299
|
LinuxStat::Kernel.compiler()
|
252
300
|
=> [:gcc, "10.2.0"]
|
253
301
|
|
254
|
-
# File:
|
255
|
-
# Definition:
|
302
|
+
# File: kernel.rb | Line: 55
|
303
|
+
# Definition: def compiler_version
|
256
304
|
LinuxStat::Kernel.compiler_version()
|
257
305
|
=> "10.2.0"
|
258
306
|
|
259
|
-
# File:
|
260
|
-
# Definition:
|
307
|
+
# File: kernel.rb | Line: 10
|
308
|
+
# Definition: def version
|
261
309
|
LinuxStat::Kernel.release()
|
262
310
|
=> "5.9.9-xanmod1-1"
|
263
311
|
|
264
|
-
# File:
|
265
|
-
# Definition:
|
312
|
+
# File: kernel.rb | Line: 169
|
313
|
+
# Definition: def string
|
266
314
|
LinuxStat::Kernel.string()
|
267
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"
|
268
316
|
|
269
|
-
# File:
|
270
|
-
# Definition:
|
317
|
+
# File: kernel.rb | Line: 179
|
318
|
+
# Definition: def ticks
|
271
319
|
LinuxStat::Kernel.ticks()
|
272
320
|
=> 100
|
273
321
|
|
274
|
-
# File:
|
275
|
-
# Definition:
|
322
|
+
# File: kernel.rb | Line: 10
|
323
|
+
# Definition: def version
|
276
324
|
LinuxStat::Kernel.version()
|
277
325
|
=> "5.9.9-xanmod1-1"
|
278
326
|
|
@@ -280,233 +328,233 @@ LinuxStat::Kernel.version()
|
|
280
328
|
|
281
329
|
### LinuxStat::Memory
|
282
330
|
```
|
283
|
-
# File:
|
284
|
-
# Definition:
|
331
|
+
# File: memory.rb | Line: 50
|
332
|
+
# Definition: def available
|
285
333
|
LinuxStat::Memory.available()
|
286
|
-
=>
|
334
|
+
=> 1597312
|
287
335
|
|
288
|
-
# File:
|
289
|
-
# Definition:
|
336
|
+
# File: memory.rb | Line: 81
|
337
|
+
# Definition: def percent_available
|
290
338
|
LinuxStat::Memory.percent_available()
|
291
|
-
=>
|
339
|
+
=> 41.64
|
292
340
|
|
293
|
-
# File:
|
294
|
-
# Definition:
|
341
|
+
# File: memory.rb | Line: 70
|
342
|
+
# Definition: def percent_used
|
295
343
|
LinuxStat::Memory.percent_used()
|
296
|
-
=>
|
344
|
+
=> 58.36
|
297
345
|
|
298
|
-
# File:
|
299
|
-
# Definition:
|
346
|
+
# File: memory.rb | Line: 11
|
347
|
+
# Definition: def stat
|
300
348
|
LinuxStat::Memory.stat()
|
301
|
-
=> {:total=>3836236, :used=>
|
349
|
+
=> {:total=>3836236, :used=>2238924, :available=>1597312, :percent_used=>58.36, :percent_available=>41.64}
|
302
350
|
|
303
|
-
# File:
|
304
|
-
# Definition:
|
351
|
+
# File: memory.rb | Line: 40
|
352
|
+
# Definition: def total
|
305
353
|
LinuxStat::Memory.total()
|
306
354
|
=> 3836236
|
307
355
|
|
308
|
-
# File:
|
309
|
-
# Definition:
|
356
|
+
# File: memory.rb | Line: 60
|
357
|
+
# Definition: def used
|
310
358
|
LinuxStat::Memory.used()
|
311
|
-
=>
|
359
|
+
=> 2238924
|
312
360
|
|
313
361
|
```
|
314
362
|
|
315
363
|
### LinuxStat::Mounts
|
316
364
|
```
|
317
|
-
# File:
|
318
|
-
# Definition:
|
365
|
+
# File: mounts.rb | Line: 179
|
366
|
+
# Definition: def device_stat(dev = root)
|
319
367
|
LinuxStat::Mounts.device_stat(dev)
|
320
|
-
=> {:mountpoint=>"/", :total=>119981191168, :free=>
|
368
|
+
=> {:mountpoint=>"/", :total=>119981191168, :free=>47937835008, :available=>47937835008, :used=>72043356160, :percent_used=>60.05, :percent_free=>39.95, :percent_available=>39.95}
|
321
369
|
|
322
|
-
# File:
|
323
|
-
# Definition:
|
370
|
+
# File: mounts.rb | Line: 137
|
371
|
+
# Definition: def devices_stat
|
324
372
|
LinuxStat::Mounts.devices_stat()
|
325
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...
|
326
374
|
|
327
|
-
# File:
|
328
|
-
# Definition:
|
375
|
+
# File: mounts.rb | Line: 11
|
376
|
+
# Definition: def list
|
329
377
|
LinuxStat::Mounts.list()
|
330
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", "...
|
331
379
|
|
332
|
-
# File:
|
333
|
-
# Definition:
|
380
|
+
# File: mounts.rb | Line: 20
|
381
|
+
# Definition: def list_devices
|
334
382
|
LinuxStat::Mounts.list_devices()
|
335
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...
|
336
384
|
|
337
|
-
# File:
|
338
|
-
# Definition:
|
385
|
+
# File: mounts.rb | Line: 109
|
386
|
+
# Definition: def list_devices_mount_point
|
339
387
|
LinuxStat::Mounts.list_devices_mount_point()
|
340
|
-
=> {"proc"=>"/proc", "sys"=>"/sys", "dev"=>"/dev", "run"=>"/run", "/dev/sda2"=>"/", "securityfs"=>"/sys/kernel/security", "tmpfs"=>"/run/user/1000", "devpts"=>"/dev/pts", "cgroup2"=>"/sys/fs/cgroup/unified", "cgroup"=>"/sys/fs/cgroup/
|
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"=>"...
|
341
389
|
|
342
|
-
# File:
|
343
|
-
# Definition:
|
390
|
+
# File: mounts.rb | Line: 80
|
391
|
+
# Definition: def mount_point(dev = root)
|
344
392
|
LinuxStat::Mounts.mount_point(dev)
|
345
393
|
=> "/"
|
346
394
|
|
347
|
-
# File:
|
348
|
-
# Definition:
|
395
|
+
# File: mounts.rb | Line: 29
|
396
|
+
# Definition: def root
|
349
397
|
LinuxStat::Mounts.root()
|
350
398
|
=> "/dev/sda2"
|
351
399
|
|
352
|
-
# File:
|
353
|
-
# Definition:
|
400
|
+
# File: mounts.rb | Line: 38
|
401
|
+
# Definition: def root_fs
|
354
402
|
LinuxStat::Mounts.root_fs()
|
355
403
|
=> "xfs"
|
356
404
|
|
357
|
-
# File:
|
358
|
-
# Definition:
|
405
|
+
# File: mounts.rb | Line: 47
|
406
|
+
# Definition: def root_mount_options
|
359
407
|
LinuxStat::Mounts.root_mount_options()
|
360
408
|
=> "rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota"
|
361
409
|
|
362
|
-
# File:
|
363
|
-
# Definition:
|
410
|
+
# File: mounts.rb | Line: 56
|
411
|
+
# Definition: def tmpfs
|
364
412
|
LinuxStat::Mounts.tmpfs()
|
365
|
-
=> {"/dev/shm"=>"tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0", "/sys/fs/cgroup"=>"tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755 0 0", "/cache"=>"tmpfs /cache tmpfs rw,nosuid,nodev,relatime,size=2097152k 0 0", "/
|
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...
|
366
414
|
|
367
415
|
```
|
368
416
|
|
369
417
|
### LinuxStat::Net
|
370
418
|
```
|
371
|
-
# File:
|
372
|
-
# Definition:
|
419
|
+
# File: net.rb | Line: 80
|
420
|
+
# Definition: def usage(interval = 0.1)
|
373
421
|
LinuxStat::Net.current_usage(interval)
|
374
|
-
=> {:received=>
|
422
|
+
=> {:received=>0.0, :transmitted=>0.0}
|
375
423
|
|
376
|
-
# File:
|
377
|
-
# Definition:
|
424
|
+
# File: net.rb | Line: 10
|
425
|
+
# Definition: def ipv4_private
|
378
426
|
LinuxStat::Net.ipv4_private()
|
379
427
|
=> "192.168.0.102"
|
380
428
|
|
381
|
-
# File:
|
382
|
-
# Definition:
|
429
|
+
# File: net.rb | Line: 23
|
430
|
+
# Definition: def total_bytes
|
383
431
|
LinuxStat::Net.total_bytes()
|
384
|
-
=> {:received=>
|
432
|
+
=> {:received=>687677565, :transmitted=>149550163}
|
385
433
|
|
386
|
-
# File:
|
387
|
-
# Definition:
|
434
|
+
# File: net.rb | Line: 41
|
435
|
+
# Definition: def total_bytes_received
|
388
436
|
LinuxStat::Net.total_bytes_received()
|
389
|
-
=>
|
437
|
+
=> 687677565
|
390
438
|
|
391
|
-
# File:
|
392
|
-
# Definition:
|
439
|
+
# File: net.rb | Line: 54
|
440
|
+
# Definition: def total_bytes_transmitted
|
393
441
|
LinuxStat::Net.total_bytes_transmitted()
|
394
|
-
=>
|
442
|
+
=> 149550163
|
395
443
|
|
396
|
-
# File:
|
397
|
-
# Definition:
|
444
|
+
# File: net.rb | Line: 80
|
445
|
+
# Definition: def usage(interval = 0.1)
|
398
446
|
LinuxStat::Net.usage(interval)
|
399
|
-
=> {:received=>
|
447
|
+
=> {:received=>0.0, :transmitted=>0.0}
|
400
448
|
|
401
449
|
```
|
402
450
|
|
403
451
|
### LinuxStat::OS
|
404
452
|
```
|
405
|
-
# File:
|
406
|
-
# Definition:
|
453
|
+
# File: os.rb | Line: 97
|
454
|
+
# Definition: def bits
|
407
455
|
LinuxStat::OS.bits()
|
408
456
|
=> 64
|
409
457
|
|
410
|
-
# File:
|
411
|
-
# Definition:
|
458
|
+
# File: os.rb | Line: 42
|
459
|
+
# Definition: def distribution
|
412
460
|
LinuxStat::OS.distribution()
|
413
461
|
=> "Arch Linux"
|
414
462
|
|
415
|
-
# File:
|
416
|
-
# Definition:
|
463
|
+
# File: os.rb | Line: 81
|
464
|
+
# Definition: def hostname
|
417
465
|
LinuxStat::OS.hostname()
|
418
466
|
=> "archlinux"
|
419
467
|
|
420
|
-
# File:
|
421
|
-
# Definition:
|
468
|
+
# File: os.rb | Line: 30
|
469
|
+
# Definition: def lsb_release
|
422
470
|
LinuxStat::OS.lsb_release()
|
423
471
|
=> {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
|
424
472
|
|
425
|
-
# File:
|
426
|
-
# Definition:
|
473
|
+
# File: os.rb | Line: 64
|
474
|
+
# Definition: def machine
|
427
475
|
LinuxStat::OS.machine()
|
428
476
|
=> "x86_64"
|
429
477
|
|
430
|
-
# File:
|
431
|
-
# Definition:
|
478
|
+
# File: os.rb | Line: 72
|
479
|
+
# Definition: def nodename
|
432
480
|
LinuxStat::OS.nodename()
|
433
481
|
=> "archlinux"
|
434
482
|
|
435
|
-
# File:
|
436
|
-
# Definition:
|
483
|
+
# File: os.rb | Line: 15
|
484
|
+
# Definition: def os_release
|
437
485
|
LinuxStat::OS.os_release()
|
438
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/"...
|
439
487
|
|
440
|
-
# File:
|
441
|
-
# Definition:
|
488
|
+
# File: os.rb | Line: 110
|
489
|
+
# Definition: def uptime
|
442
490
|
LinuxStat::OS.uptime()
|
443
|
-
=> {:hour=>
|
491
|
+
=> {:hour=>6, :minute=>50, :second=>39.61}
|
444
492
|
|
445
493
|
```
|
446
494
|
|
447
495
|
### LinuxStat::PrettifyBytes
|
448
496
|
```
|
449
|
-
# File:
|
450
|
-
# Definition:
|
451
|
-
LinuxStat::PrettifyBytes.convert_binary(n =
|
452
|
-
=> "
|
497
|
+
# File: prettify_bytes.rb | Line: 42
|
498
|
+
# Definition: def convert_binary(n)
|
499
|
+
LinuxStat::PrettifyBytes.convert_binary(n = 200152828322898)
|
500
|
+
=> "182.04 tebibytes"
|
453
501
|
|
454
|
-
# File:
|
455
|
-
# Definition:
|
456
|
-
LinuxStat::PrettifyBytes.convert_decimal(n =
|
457
|
-
=> "
|
502
|
+
# File: prettify_bytes.rb | Line: 19
|
503
|
+
# Definition: def convert_decimal(n)
|
504
|
+
LinuxStat::PrettifyBytes.convert_decimal(n = 434440373786022)
|
505
|
+
=> "434.44 terabytes"
|
458
506
|
|
459
|
-
# File:
|
460
|
-
# Definition:
|
461
|
-
LinuxStat::PrettifyBytes.convert_short_binary(n =
|
462
|
-
=> "
|
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"
|
463
511
|
|
464
|
-
# File:
|
465
|
-
# Definition:
|
466
|
-
LinuxStat::PrettifyBytes.convert_short_decimal(n =
|
467
|
-
=> "
|
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"
|
468
516
|
|
469
517
|
```
|
470
518
|
|
471
519
|
### LinuxStat::Process
|
472
520
|
```
|
473
|
-
# File:
|
474
|
-
# Definition:
|
521
|
+
# File: process.rb | Line: 19
|
522
|
+
# Definition: def count
|
475
523
|
LinuxStat::Process.count()
|
476
|
-
=>
|
524
|
+
=> 195
|
477
525
|
|
478
|
-
# File:
|
479
|
-
# Definition:
|
526
|
+
# File: process.rb | Line: 71
|
527
|
+
# Definition: def idle
|
480
528
|
LinuxStat::Process.idle()
|
481
|
-
=> [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 119, 121, 131, 134, 140, 152, 153,
|
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...
|
482
530
|
|
483
|
-
# File:
|
484
|
-
# Definition:
|
531
|
+
# File: process.rb | Line: 8
|
532
|
+
# Definition: def list
|
485
533
|
LinuxStat::Process.list()
|
486
|
-
=> [1, 2, 3, 4, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 46, 47, 48, 49, 50, 51, 52, 102, 103, 104, 106, 107, 108, 109, 110,
|
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,...
|
487
535
|
|
488
|
-
# File:
|
489
|
-
# Definition:
|
536
|
+
# File: process.rb | Line: 25
|
537
|
+
# Definition: def names
|
490
538
|
LinuxStat::Process.names()
|
491
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...
|
492
540
|
|
493
|
-
# File:
|
494
|
-
# Definition:
|
541
|
+
# File: process.rb | Line: 97
|
542
|
+
# Definition: def running
|
495
543
|
LinuxStat::Process.running()
|
496
|
-
=> [
|
544
|
+
=> [15978]
|
497
545
|
|
498
|
-
# File:
|
499
|
-
# Definition:
|
546
|
+
# File: process.rb | Line: 58
|
547
|
+
# Definition: def sleeping
|
500
548
|
LinuxStat::Process.sleeping()
|
501
|
-
=> [1, 2, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 38, 40, 41, 42, 46, 47, 48, 50, 51, 52,
|
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,...
|
502
550
|
|
503
|
-
# File:
|
504
|
-
# Definition:
|
551
|
+
# File: process.rb | Line: 37
|
552
|
+
# Definition: def types
|
505
553
|
LinuxStat::Process.types()
|
506
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...
|
507
555
|
|
508
|
-
# File:
|
509
|
-
# Definition:
|
556
|
+
# File: process.rb | Line: 84
|
557
|
+
# Definition: def zombie
|
510
558
|
LinuxStat::Process.zombie()
|
511
559
|
=> []
|
512
560
|
|
@@ -514,156 +562,166 @@ LinuxStat::Process.zombie()
|
|
514
562
|
|
515
563
|
### LinuxStat::ProcessInfo
|
516
564
|
```
|
517
|
-
# File:
|
518
|
-
# Definition:
|
565
|
+
# File: process_info.rb | Line: 54
|
566
|
+
# Definition: def cmdline(pid = $$)
|
519
567
|
LinuxStat::ProcessInfo.cmdline(pid)
|
520
|
-
=> "ruby /
|
568
|
+
=> "/usr/bin/ruby /home/sourav/.gem/ruby/2.7.0/bin/linuxstat.rb -md"
|
521
569
|
|
522
|
-
# File:
|
523
|
-
# Definition:
|
570
|
+
# File: process_info.rb | Line: 78
|
571
|
+
# Definition: def command_name(pid = $$)
|
524
572
|
LinuxStat::ProcessInfo.command_name(pid)
|
525
573
|
=> "ruby"
|
526
574
|
|
527
|
-
# File:
|
528
|
-
# Definition:
|
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)
|
529
582
|
LinuxStat::ProcessInfo.cpu_stat(pid:, sleep:)
|
530
|
-
=> {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>
|
583
|
+
=> {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>3}
|
531
584
|
|
532
|
-
# File:
|
533
|
-
# Definition:
|
585
|
+
# File: process_info.rb | Line: 307
|
586
|
+
# Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms_t5)
|
534
587
|
LinuxStat::ProcessInfo.cpu_usage(pid:, sleep:)
|
535
588
|
=> 0.0
|
536
589
|
|
537
|
-
# File:
|
538
|
-
# Definition:
|
590
|
+
# File: process_info.rb | Line: 470
|
591
|
+
# Definition: def gid(pid = $$)
|
539
592
|
LinuxStat::ProcessInfo.gid(pid)
|
540
593
|
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
541
594
|
|
542
|
-
# File:
|
543
|
-
# Definition:
|
595
|
+
# File: process_info.rb | Line: 433
|
596
|
+
# Definition: def last_executed_cpu(pid = $$)
|
544
597
|
LinuxStat::ProcessInfo.last_executed_cpu(pid)
|
545
|
-
=>
|
598
|
+
=> 3
|
546
599
|
|
547
|
-
# File:
|
548
|
-
# Definition:
|
600
|
+
# File: process_info.rb | Line: 114
|
601
|
+
# Definition: def mem_stat(pid = $$)
|
549
602
|
LinuxStat::ProcessInfo.mem_stat(pid)
|
550
|
-
=> {:memory=>
|
603
|
+
=> {:memory=>12627.968, :virtual_memory=>84221.952, :resident_memory=>18743.296}
|
551
604
|
|
552
|
-
# File:
|
553
|
-
# Definition:
|
605
|
+
# File: process_info.rb | Line: 147
|
606
|
+
# Definition: def memory(pid = $$)
|
554
607
|
LinuxStat::ProcessInfo.memory(pid)
|
555
|
-
=>
|
608
|
+
=> 12627.968
|
556
609
|
|
557
|
-
# File:
|
558
|
-
# Definition:
|
610
|
+
# File: process_info.rb | Line: 607
|
611
|
+
# Definition: def nice(pid = $$)
|
559
612
|
LinuxStat::ProcessInfo.nice(pid)
|
560
613
|
=> 0
|
561
614
|
|
562
|
-
# File:
|
563
|
-
# Definition:
|
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 = $$)
|
564
622
|
LinuxStat::ProcessInfo.owner(pid)
|
565
623
|
=> "sourav"
|
566
624
|
|
567
|
-
# File:
|
568
|
-
# Definition:
|
625
|
+
# File: process_info.rb | Line: 197
|
626
|
+
# Definition: def resident_memory(pid = $$)
|
569
627
|
LinuxStat::ProcessInfo.resident_memory(pid)
|
570
|
-
=>
|
628
|
+
=> 18743.296
|
571
629
|
|
572
|
-
# File:
|
573
|
-
# Definition:
|
630
|
+
# File: process_info.rb | Line: 563
|
631
|
+
# Definition: def running_time(pid = $$)
|
574
632
|
LinuxStat::ProcessInfo.running_time(pid)
|
575
|
-
=>
|
633
|
+
=> 0.8
|
576
634
|
|
577
|
-
# File:
|
578
|
-
# Definition:
|
635
|
+
# File: process_info.rb | Line: 544
|
636
|
+
# Definition: def start_time(pid = $$)
|
579
637
|
LinuxStat::ProcessInfo.start_time(pid)
|
580
|
-
=> 2020-12-
|
638
|
+
=> 2020-12-24 19:05:51 +0530
|
581
639
|
|
582
|
-
# File:
|
583
|
-
# Definition:
|
640
|
+
# File: process_info.rb | Line: 513
|
641
|
+
# Definition: def start_time_epoch(pid = $$)
|
584
642
|
LinuxStat::ProcessInfo.start_time_epoch(pid)
|
585
|
-
=>
|
643
|
+
=> 1608816951
|
586
644
|
|
587
|
-
# File:
|
588
|
-
# Definition:
|
645
|
+
# File: process_info.rb | Line: 592
|
646
|
+
# Definition: def state(pid = $$)
|
589
647
|
LinuxStat::ProcessInfo.state(pid)
|
590
648
|
=> "R"
|
591
649
|
|
592
|
-
# File:
|
593
|
-
# Definition:
|
650
|
+
# File: process_info.rb | Line: 359
|
651
|
+
# Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
|
594
652
|
LinuxStat::ProcessInfo.thread_usage(pid:, sleep:)
|
595
653
|
=> 0.0
|
596
654
|
|
597
|
-
# File:
|
598
|
-
# Definition:
|
655
|
+
# File: process_info.rb | Line: 408
|
656
|
+
# Definition: def threads(pid = $$)
|
599
657
|
LinuxStat::ProcessInfo.threads(pid)
|
600
658
|
=> 1
|
601
659
|
|
602
|
-
# File:
|
603
|
-
# Definition:
|
660
|
+
# File: process_info.rb | Line: 23
|
661
|
+
# Definition: def total_io(pid = $$)
|
604
662
|
LinuxStat::ProcessInfo.total_io(pid)
|
605
|
-
=> {:read_bytes=>
|
663
|
+
=> {:read_bytes=>0, :write_bytes=>0}
|
606
664
|
|
607
|
-
# File:
|
608
|
-
# Definition:
|
665
|
+
# File: process_info.rb | Line: 446
|
666
|
+
# Definition: def uid(pid = $$)
|
609
667
|
LinuxStat::ProcessInfo.uid(pid)
|
610
668
|
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
611
669
|
|
612
|
-
# File:
|
613
|
-
# Definition:
|
670
|
+
# File: process_info.rb | Line: 172
|
671
|
+
# Definition: def virtual_memory(pid = $$)
|
614
672
|
LinuxStat::ProcessInfo.virtual_memory(pid)
|
615
|
-
=>
|
673
|
+
=> 84221.952
|
616
674
|
|
617
675
|
```
|
618
676
|
|
619
677
|
### LinuxStat::Swap
|
620
678
|
```
|
621
|
-
# File:
|
622
|
-
# Definition:
|
679
|
+
# File: swap.rb | Line: 22
|
680
|
+
# Definition: def any?
|
623
681
|
LinuxStat::Swap.any?()
|
624
682
|
=> true
|
625
683
|
|
626
|
-
# File:
|
627
|
-
# Definition:
|
684
|
+
# File: swap.rb | Line: 68
|
685
|
+
# Definition: def available
|
628
686
|
LinuxStat::Swap.available()
|
629
|
-
=>
|
687
|
+
=> 4064380
|
630
688
|
|
631
|
-
# File:
|
632
|
-
# Definition:
|
689
|
+
# File: swap.rb | Line: 8
|
690
|
+
# Definition: def list
|
633
691
|
LinuxStat::Swap.list()
|
634
|
-
=> {"/dev/zram0"=>[:partition, 4194300,
|
692
|
+
=> {"/dev/zram0"=>[:partition, 4194300, 129920, -2]}
|
635
693
|
|
636
|
-
# File:
|
637
|
-
# Definition:
|
694
|
+
# File: swap.rb | Line: 103
|
695
|
+
# Definition: def percent_available
|
638
696
|
LinuxStat::Swap.percent_available()
|
639
|
-
=>
|
697
|
+
=> 96.9
|
640
698
|
|
641
|
-
# File:
|
642
|
-
# Definition:
|
699
|
+
# File: swap.rb | Line: 89
|
700
|
+
# Definition: def percent_used
|
643
701
|
LinuxStat::Swap.percent_used()
|
644
|
-
=>
|
702
|
+
=> 3.1
|
645
703
|
|
646
|
-
# File:
|
647
|
-
# Definition:
|
704
|
+
# File: swap.rb | Line: 32
|
705
|
+
# Definition: def stat
|
648
706
|
LinuxStat::Swap.stat()
|
649
|
-
=> {:total=>4194300, :used=>
|
707
|
+
=> {:total=>4194300, :used=>129920, :available=>4064380, :percent_used=>3.1, :percent_available=>96.9}
|
650
708
|
|
651
|
-
# File:
|
652
|
-
# Definition:
|
709
|
+
# File: swap.rb | Line: 57
|
710
|
+
# Definition: def total
|
653
711
|
LinuxStat::Swap.total()
|
654
712
|
=> 4194300
|
655
713
|
|
656
|
-
# File:
|
657
|
-
# Definition:
|
714
|
+
# File: swap.rb | Line: 80
|
715
|
+
# Definition: def used
|
658
716
|
LinuxStat::Swap.used()
|
659
|
-
=>
|
717
|
+
=> 129920
|
660
718
|
|
661
719
|
```
|
662
720
|
|
663
721
|
### LinuxStat::Sysconf
|
664
722
|
```
|
665
723
|
LinuxStat::Sysconf.child_max()
|
666
|
-
=>
|
724
|
+
=> nil
|
667
725
|
|
668
726
|
LinuxStat::Sysconf.expr_nest_max()
|
669
727
|
=> 32
|
@@ -699,7 +757,7 @@ LinuxStat::Sysconf.pagesize()
|
|
699
757
|
=> 4096
|
700
758
|
|
701
759
|
LinuxStat::Sysconf.posix_version()
|
702
|
-
=>
|
760
|
+
=> 4201
|
703
761
|
|
704
762
|
LinuxStat::Sysconf.processor_configured()
|
705
763
|
=> 4
|
@@ -718,6 +776,25 @@ LinuxStat::Sysconf.tty_name_max()
|
|
718
776
|
|
719
777
|
```
|
720
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
|
+
|
721
798
|
### LinuxStat::Uname
|
722
799
|
```
|
723
800
|
LinuxStat::Uname.machine()
|
@@ -739,93 +816,93 @@ LinuxStat::Uname.version()
|
|
739
816
|
|
740
817
|
### LinuxStat::User
|
741
818
|
```
|
742
|
-
# File:
|
743
|
-
# Definition:
|
819
|
+
# File: user.rb | Line: 98
|
820
|
+
# Definition: def get_user
|
744
821
|
LinuxStat::User.get_current_user()
|
745
822
|
=> "sourav"
|
746
823
|
|
747
|
-
# File:
|
748
|
-
# Definition:
|
824
|
+
# File: user.rb | Line: 137
|
825
|
+
# Definition: def get_euid
|
749
826
|
LinuxStat::User.get_euid()
|
750
827
|
=> 1000
|
751
828
|
|
752
|
-
# File:
|
753
|
-
# Definition:
|
829
|
+
# File: user.rb | Line: 129
|
830
|
+
# Definition: def get_gid
|
754
831
|
LinuxStat::User.get_gid()
|
755
832
|
=> 1000
|
756
833
|
|
757
|
-
# File:
|
758
|
-
# Definition:
|
834
|
+
# File: user.rb | Line: 152
|
835
|
+
# Definition: def get_login
|
759
836
|
LinuxStat::User.get_login()
|
760
837
|
=> "sourav"
|
761
838
|
|
762
|
-
# File:
|
763
|
-
# Definition:
|
839
|
+
# File: user.rb | Line: 121
|
840
|
+
# Definition: def get_uid
|
764
841
|
LinuxStat::User.get_uid()
|
765
842
|
=> 1000
|
766
843
|
|
767
|
-
# File:
|
768
|
-
# Definition:
|
844
|
+
# File: user.rb | Line: 98
|
845
|
+
# Definition: def get_user
|
769
846
|
LinuxStat::User.get_user()
|
770
847
|
=> "sourav"
|
771
848
|
|
772
|
-
# File:
|
773
|
-
# Definition:
|
849
|
+
# File: user.rb | Line: 215
|
850
|
+
# Definition: def gid_by_username(username = get_user)
|
774
851
|
LinuxStat::User.gid_by_username(username)
|
775
852
|
=> 1000
|
776
853
|
|
777
|
-
# File:
|
778
|
-
# Definition:
|
854
|
+
# File: user.rb | Line: 56
|
855
|
+
# Definition: def gids
|
779
856
|
LinuxStat::User.gids()
|
780
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, :...
|
781
858
|
|
782
|
-
# File:
|
783
|
-
# Definition:
|
859
|
+
# File: user.rb | Line: 314
|
860
|
+
# Definition: def home_by_gid(id = get_gid)
|
784
861
|
LinuxStat::User.home_by_gid(id)
|
785
862
|
=> "/home/sourav"
|
786
863
|
|
787
|
-
# File:
|
788
|
-
# Definition:
|
864
|
+
# File: user.rb | Line: 266
|
865
|
+
# Definition: def home_by_username(user = get_user)
|
789
866
|
LinuxStat::User.home_by_username(user)
|
790
867
|
=> "/home/sourav"
|
791
868
|
|
792
|
-
# File:
|
793
|
-
# Definition:
|
869
|
+
# File: user.rb | Line: 72
|
870
|
+
# Definition: def home_directories
|
794
871
|
LinuxStat::User.home_directories()
|
795
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...
|
796
873
|
|
797
|
-
# File:
|
798
|
-
# Definition:
|
874
|
+
# File: user.rb | Line: 293
|
875
|
+
# Definition: def homes_by_uid(id = get_uid)
|
799
876
|
LinuxStat::User.homes_by_uid(id)
|
800
877
|
=> ["/home/sourav"]
|
801
878
|
|
802
|
-
# File:
|
803
|
-
# Definition:
|
879
|
+
# File: user.rb | Line: 23
|
880
|
+
# Definition: def ids
|
804
881
|
LinuxStat::User.ids()
|
805
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...
|
806
883
|
|
807
|
-
# File:
|
808
|
-
# Definition:
|
884
|
+
# File: user.rb | Line: 11
|
885
|
+
# Definition: def list
|
809
886
|
LinuxStat::User.list()
|
810
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...
|
811
888
|
|
812
|
-
# File:
|
813
|
-
# Definition:
|
889
|
+
# File: user.rb | Line: 244
|
890
|
+
# Definition: def uid_by_username(username = get_user)
|
814
891
|
LinuxStat::User.uid_by_username(username)
|
815
892
|
=> 1000
|
816
893
|
|
817
|
-
# File:
|
818
|
-
# Definition:
|
894
|
+
# File: user.rb | Line: 40
|
895
|
+
# Definition: def uids
|
819
896
|
LinuxStat::User.uids()
|
820
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...
|
821
898
|
|
822
|
-
# File:
|
823
|
-
# Definition:
|
899
|
+
# File: user.rb | Line: 187
|
900
|
+
# Definition: def username_by_gid(gid = get_gid)
|
824
901
|
LinuxStat::User.username_by_gid(gid)
|
825
902
|
=> "sourav"
|
826
903
|
|
827
|
-
# File:
|
828
|
-
# Definition:
|
904
|
+
# File: user.rb | Line: 169
|
905
|
+
# Definition: def usernames_by_uid(uid = get_uid)
|
829
906
|
LinuxStat::User.usernames_by_uid(uid)
|
830
907
|
=> ["sourav"]
|
831
908
|
|
@@ -897,7 +974,120 @@ well as soon as the Linux kernel updates the data and ruby executes the loop.
|
|
897
974
|
|
898
975
|
Just run the linuxstat.rb command to test what method takes what time measured in microseconds.
|
899
976
|
|
900
|
-
## Note 2:
|
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
|
901
1091
|
|
902
1092
|
Filesystem can take arguments. By default it's '/' or the root of the system...
|
903
1093
|
|
@@ -932,7 +1122,7 @@ irb(main):005:0> LinuxStat::Filesystem.total(thumbdrive).fdiv(1024 ** 3).to_s <<
|
|
932
1122
|
=> "29.305004119873047 GiB"
|
933
1123
|
```
|
934
1124
|
|
935
|
-
## Note
|
1125
|
+
## Note 4: ProcessInfo
|
936
1126
|
|
937
1127
|
All the methods LinuxStat::ProcessInfo can take an argument containing the Process ID of a process.
|
938
1128
|
By default it's $$ or the PID of the current process, ruby, itself.
|
@@ -984,7 +1174,7 @@ irb(main):002:0> LinuxStat::ProcessInfo.memory(LinuxStat::Process.names.find { |
|
|
984
1174
|
=> "467.51 MiB"
|
985
1175
|
```
|
986
1176
|
|
987
|
-
## Note
|
1177
|
+
## Note 5: FS
|
988
1178
|
|
989
1179
|
LinuxStat::FS module gives you the raw info in Hash collected from statvfs.
|
990
1180
|
|
@@ -1009,7 +1199,7 @@ irb(main):003:0> t = Time.now ; puts LinuxStat::FS.stat('/') ; Time.now - t
|
|
1009
1199
|
|
1010
1200
|
To learn more about them, just run ri and the method name. To see all available methods.
|
1011
1201
|
|
1012
|
-
## Note
|
1202
|
+
## Note 6: User
|
1013
1203
|
Most of the LinuxStat::User supports arguments.
|
1014
1204
|
|
1015
1205
|
For example, to get a user's home by the username:
|
@@ -1091,7 +1281,7 @@ irb(main):004:0> LinuxStat::User.get_login
|
|
1091
1281
|
|
1092
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.
|
1093
1283
|
|
1094
|
-
## Note
|
1284
|
+
## Note 7: PrettifyBytes
|
1095
1285
|
Often times we need to work with KB, MB GB, TB, or KiB, MiB, GiB, TiB, etc.
|
1096
1286
|
And we need some work to convert bytes to those units.
|
1097
1287
|
Because LinuxStat provides a lot of data in bytes, and kilobytes, it's quite tedious to convert them all the time.
|
@@ -1231,6 +1421,16 @@ Issues regarding running LinuxStat on termux are also welcomed.
|
|
1231
1421
|
|
1232
1422
|
---
|
1233
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
|
+
|
1234
1434
|
## Development
|
1235
1435
|
After checking out the repo, compile and install this gem onto your local machine with `bundle exec rake install`
|
1236
1436
|
|