linux_stat 0.7.4 → 0.9.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 +527 -316
- data/exe/linuxstat.rb +34 -13
- data/ext/fs_stat/fs_stat.c +9 -2
- data/ext/nproc/extconf.rb +11 -0
- data/ext/nproc/nproc.c +31 -0
- data/ext/sysconf/sysconf.c +78 -11
- data/ext/utsname/utsname.c +26 -14
- data/lib/linux_stat.rb +7 -1
- data/lib/linux_stat/battery.rb +183 -20
- data/lib/linux_stat/cpu.rb +222 -41
- data/lib/linux_stat/filesystem.rb +12 -12
- data/lib/linux_stat/kernel.rb +1 -1
- data/lib/linux_stat/os.rb +2 -2
- data/lib/linux_stat/prettify_bytes.rb +1 -4
- data/lib/linux_stat/process.rb +1 -1
- data/lib/linux_stat/process_info.rb +124 -18
- data/lib/linux_stat/swap.rb +1 -1
- data/lib/linux_stat/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51a901fa3464ea37e42bdc1f798be4feb01bbdf58bc3c00c939166c302f65fc7
|
4
|
+
data.tar.gz: 8edfc5a3d31ae3be01848ad0984314702940e34ad14bbb7016144f2208f9bfb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ebcdc193d240a363b7563ddac6c4de631927bd2617f5ec69a7cf4858cda63ec3e712b1b518625729a875b676b74bdf1ca5e6522bbf78bda10eb7abf8aff0efb
|
7
|
+
data.tar.gz: a5903aa2b5a941ac23fb090c6577997383bb8435a41d8c52a4532c174e910b5901a94687a55373bf0f9b0ae87faf91547c1d30507781bbd8b3401e792ad05549
|
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,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:
|
54
|
-
# Definition:
|
64
|
+
# File: bios.rb | Line: 56
|
65
|
+
# Definition: def date
|
55
66
|
LinuxStat::BIOS.date()
|
56
67
|
=> "04/10/2017"
|
57
68
|
|
58
|
-
# File:
|
59
|
-
# Definition:
|
69
|
+
# File: bios.rb | Line: 10
|
70
|
+
# Definition: def model
|
60
71
|
LinuxStat::BIOS.model()
|
61
72
|
=> "Inspiron 5567"
|
62
73
|
|
63
|
-
# File:
|
64
|
-
# Definition:
|
74
|
+
# File: bios.rb | Line: 27
|
75
|
+
# Definition: def vendor
|
65
76
|
LinuxStat::BIOS.vendor()
|
66
77
|
=> "Dell Inc."
|
67
78
|
|
68
|
-
# File:
|
69
|
-
# Definition:
|
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:
|
78
|
-
# Definition:
|
88
|
+
# File: battery.rb | Line: 105
|
89
|
+
# Definition: def charge
|
79
90
|
LinuxStat::Battery.charge()
|
80
91
|
=> 100.0
|
81
92
|
|
82
|
-
# File:
|
83
|
-
# 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?
|
84
105
|
LinuxStat::Battery.charging?()
|
85
106
|
=> true
|
86
107
|
|
87
|
-
# File:
|
88
|
-
# 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?
|
89
115
|
LinuxStat::Battery.discharging?()
|
90
116
|
=> false
|
91
117
|
|
92
|
-
# File:
|
93
|
-
# Definition:
|
118
|
+
# File: battery.rb | Line: 96
|
119
|
+
# Definition: def full?
|
94
120
|
LinuxStat::Battery.full?()
|
95
121
|
=> true
|
96
122
|
|
97
|
-
# File:
|
98
|
-
# Definition:
|
123
|
+
# File: battery.rb | Line: 47
|
124
|
+
# Definition: def manufacturer
|
99
125
|
LinuxStat::Battery.manufacturer()
|
100
126
|
=> "Samsung SDI"
|
101
127
|
|
102
|
-
# File:
|
103
|
-
# Definition:
|
128
|
+
# File: battery.rb | Line: 36
|
129
|
+
# Definition: def model
|
104
130
|
LinuxStat::Battery.model()
|
105
131
|
=> "DELL CYMGM77"
|
106
132
|
|
107
|
-
# File:
|
108
|
-
# Definition:
|
133
|
+
# File: battery.rb | Line: 8
|
134
|
+
# Definition: def present?
|
109
135
|
LinuxStat::Battery.present?()
|
110
136
|
=> true
|
111
137
|
|
112
|
-
# File:
|
113
|
-
# Definition:
|
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:
|
118
|
-
# Definition:
|
143
|
+
# File: battery.rb | Line: 68
|
144
|
+
# Definition: def status
|
119
145
|
LinuxStat::Battery.status()
|
120
146
|
=> "Full"
|
121
147
|
|
122
|
-
# File:
|
123
|
-
# Definition:
|
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.561
|
157
|
+
|
127
158
|
```
|
128
159
|
|
129
160
|
### LinuxStat::CPU
|
130
161
|
```
|
131
|
-
# File:
|
132
|
-
# 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
|
133
169
|
LinuxStat::CPU.count()
|
134
170
|
=> 4
|
135
171
|
|
136
|
-
# File:
|
137
|
-
# 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
|
138
179
|
LinuxStat::CPU.cur_freq()
|
139
|
-
=>
|
180
|
+
=> {"cpu0"=>2000033, "cpu1"=>2000014, "cpu2"=>2000085, "cpu3"=>2000299}
|
140
181
|
|
141
|
-
# File:
|
142
|
-
# Definition:
|
182
|
+
# File: cpu.rb | Line: 265
|
183
|
+
# Definition: def governor
|
184
|
+
LinuxStat::CPU.governor()
|
185
|
+
=> {"cpu0"=>"performance", "cpu1"=>"performance", "cpu2"=>"performance", "cpu3"=>"performance"}
|
186
|
+
|
187
|
+
# File: cpu.rb | Line: 241
|
188
|
+
# Definition: def max_freq
|
143
189
|
LinuxStat::CPU.max_freq()
|
144
|
-
=>
|
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}
|
145
196
|
|
146
|
-
# File:
|
147
|
-
# Definition:
|
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:
|
152
|
-
# 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
|
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=>
|
215
|
+
=> {0=>14.29, 1=>20.0, 2=>20.0, 3=>16.67, 4=>0.0}
|
155
216
|
|
156
|
-
# File:
|
157
|
-
# Definition:
|
158
|
-
LinuxStat::CPU.
|
159
|
-
=>
|
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:
|
162
|
-
# Definition:
|
222
|
+
# File: cpu.rb | Line: 63
|
223
|
+
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
163
224
|
LinuxStat::CPU.usage(sleep)
|
164
|
-
=>
|
225
|
+
=> 5.26
|
165
226
|
|
166
|
-
# File:
|
167
|
-
# Definition:
|
227
|
+
# File: cpu.rb | Line: 23
|
228
|
+
# Definition: def stat(sleep = ticks_to_ms_t5)
|
168
229
|
LinuxStat::CPU.usages(sleep)
|
169
|
-
=> {0=>
|
230
|
+
=> {0=>10.0, 1=>20.0, 2=>16.67, 3=>16.67, 4=>16.67}
|
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=>
|
237
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>12254480, :block_avail_unpriv=>12254480, :inodes=>58612160, :free_inodes=>56866575, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
177
238
|
|
178
239
|
```
|
179
240
|
|
180
241
|
### LinuxStat::Filesystem
|
181
242
|
```
|
182
|
-
# File:
|
183
|
-
# Definition:
|
243
|
+
# File: filesystem.rb | Line: 92
|
244
|
+
# Definition: def available(fs = ?..freeze)
|
184
245
|
LinuxStat::Filesystem.available(fs)
|
185
|
-
=>
|
246
|
+
=> 50194350080
|
186
247
|
|
187
|
-
# File:
|
188
|
-
# Definition:
|
248
|
+
# File: filesystem.rb | Line: 58
|
249
|
+
# Definition: def free(fs = ?..freeze)
|
189
250
|
LinuxStat::Filesystem.free(fs)
|
190
|
-
=>
|
251
|
+
=> 50194350080
|
191
252
|
|
192
|
-
# File:
|
193
|
-
# Definition:
|
253
|
+
# File: filesystem.rb | Line: 19
|
254
|
+
# Definition: def stat(fs = ?..freeze)
|
194
255
|
LinuxStat::Filesystem.stat(fs)
|
195
|
-
=> {:total=>119981191168, :free=>
|
256
|
+
=> {:total=>119981191168, :free=>50194350080, :used=>69786841088}
|
196
257
|
|
197
|
-
# File:
|
198
|
-
# Definition:
|
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=>
|
261
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>12254480, :block_avail_unpriv=>12254480, :inodes=>58612160, :free_inodes=>56866575, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
201
262
|
|
202
|
-
# File:
|
203
|
-
# Definition:
|
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:
|
208
|
-
# Definition:
|
268
|
+
# File: filesystem.rb | Line: 73
|
269
|
+
# Definition: def used(fs = ?..freeze)
|
209
270
|
LinuxStat::Filesystem.used(fs)
|
210
|
-
=>
|
271
|
+
=> 69786841088
|
211
272
|
|
212
273
|
```
|
213
274
|
|
214
275
|
### LinuxStat::Kernel
|
215
276
|
```
|
216
|
-
# File:
|
217
|
-
# Definition:
|
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:
|
222
|
-
# Definition:
|
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:
|
227
|
-
# Definition:
|
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:
|
232
|
-
# Definition:
|
292
|
+
# File: kernel.rb | Line: 179
|
293
|
+
# Definition: def ticks
|
233
294
|
LinuxStat::Kernel.clk_tck()
|
234
295
|
=> 100
|
235
296
|
|
236
|
-
# File:
|
237
|
-
# Definition:
|
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:
|
242
|
-
# Definition:
|
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:
|
247
|
-
# Definition:
|
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:
|
252
|
-
# Definition:
|
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:
|
257
|
-
# Definition:
|
317
|
+
# File: kernel.rb | Line: 179
|
318
|
+
# Definition: def ticks
|
258
319
|
LinuxStat::Kernel.ticks()
|
259
320
|
=> 100
|
260
321
|
|
261
|
-
# File:
|
262
|
-
# Definition:
|
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:
|
271
|
-
# Definition:
|
331
|
+
# File: memory.rb | Line: 50
|
332
|
+
# Definition: def available
|
272
333
|
LinuxStat::Memory.available()
|
273
|
-
=>
|
334
|
+
=> 1137124
|
274
335
|
|
275
|
-
# File:
|
276
|
-
# Definition:
|
336
|
+
# File: memory.rb | Line: 81
|
337
|
+
# Definition: def percent_available
|
277
338
|
LinuxStat::Memory.percent_available()
|
278
|
-
=>
|
339
|
+
=> 29.64
|
279
340
|
|
280
|
-
# File:
|
281
|
-
# Definition:
|
341
|
+
# File: memory.rb | Line: 70
|
342
|
+
# Definition: def percent_used
|
282
343
|
LinuxStat::Memory.percent_used()
|
283
|
-
=>
|
344
|
+
=> 70.36
|
284
345
|
|
285
|
-
# File:
|
286
|
-
# Definition:
|
346
|
+
# File: memory.rb | Line: 11
|
347
|
+
# Definition: def stat
|
287
348
|
LinuxStat::Memory.stat()
|
288
|
-
=> {:total=>
|
349
|
+
=> {:total=>3836228, :used=>2699104, :available=>1137124, :percent_used=>70.36, :percent_available=>29.64}
|
289
350
|
|
290
|
-
# File:
|
291
|
-
# Definition:
|
351
|
+
# File: memory.rb | Line: 40
|
352
|
+
# Definition: def total
|
292
353
|
LinuxStat::Memory.total()
|
293
|
-
=>
|
354
|
+
=> 3836228
|
294
355
|
|
295
|
-
# File:
|
296
|
-
# Definition:
|
356
|
+
# File: memory.rb | Line: 60
|
357
|
+
# Definition: def used
|
297
358
|
LinuxStat::Memory.used()
|
298
|
-
=>
|
359
|
+
=> 2699104
|
299
360
|
|
300
361
|
```
|
301
362
|
|
302
363
|
### LinuxStat::Mounts
|
303
364
|
```
|
304
|
-
# File:
|
305
|
-
# Definition:
|
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=>
|
368
|
+
=> {:mountpoint=>"/", :total=>119981191168, :free=>50194350080, :available=>50194350080, :used=>69786841088, :percent_used=>58.16, :percent_free=>41.84, :percent_available=>41.84}
|
308
369
|
|
309
|
-
# File:
|
310
|
-
# Definition:
|
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:
|
315
|
-
# Definition:
|
375
|
+
# File: mounts.rb | Line: 11
|
376
|
+
# Definition: def list
|
316
377
|
LinuxStat::Mounts.list()
|
317
|
-
=> ["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=
|
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=1892900k,nr_inodes=473225,mode=755 0 0", "run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0", "...
|
318
379
|
|
319
|
-
# File:
|
320
|
-
# Definition:
|
380
|
+
# File: mounts.rb | Line: 20
|
381
|
+
# Definition: def list_devices
|
321
382
|
LinuxStat::Mounts.list_devices()
|
322
|
-
=> ["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", "
|
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", "hug...
|
323
384
|
|
324
|
-
# File:
|
325
|
-
# Definition:
|
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/
|
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/freezer", "pstore"=>...
|
328
389
|
|
329
|
-
# File:
|
330
|
-
# Definition:
|
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:
|
335
|
-
# Definition:
|
395
|
+
# File: mounts.rb | Line: 29
|
396
|
+
# Definition: def root
|
336
397
|
LinuxStat::Mounts.root()
|
337
398
|
=> "/dev/sda2"
|
338
399
|
|
339
|
-
# File:
|
340
|
-
# Definition:
|
400
|
+
# File: mounts.rb | Line: 38
|
401
|
+
# Definition: def root_fs
|
341
402
|
LinuxStat::Mounts.root_fs()
|
342
403
|
=> "xfs"
|
343
404
|
|
344
|
-
# File:
|
345
|
-
# Definition:
|
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:
|
350
|
-
# Definition:
|
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", "/
|
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:
|
359
|
-
# Definition:
|
419
|
+
# File: net.rb | Line: 80
|
420
|
+
# Definition: def usage(interval = 0.1)
|
360
421
|
LinuxStat::Net.current_usage(interval)
|
361
|
-
=> {:received=>
|
422
|
+
=> {:received=>1020.0, :transmitted=>940.0}
|
362
423
|
|
363
|
-
# File:
|
364
|
-
# Definition:
|
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:
|
369
|
-
# Definition:
|
429
|
+
# File: net.rb | Line: 23
|
430
|
+
# Definition: def total_bytes
|
370
431
|
LinuxStat::Net.total_bytes()
|
371
|
-
=> {:received=>
|
432
|
+
=> {:received=>336164612, :transmitted=>69471921}
|
372
433
|
|
373
|
-
# File:
|
374
|
-
# Definition:
|
434
|
+
# File: net.rb | Line: 41
|
435
|
+
# Definition: def total_bytes_received
|
375
436
|
LinuxStat::Net.total_bytes_received()
|
376
|
-
=>
|
437
|
+
=> 336164612
|
377
438
|
|
378
|
-
# File:
|
379
|
-
# Definition:
|
439
|
+
# File: net.rb | Line: 54
|
440
|
+
# Definition: def total_bytes_transmitted
|
380
441
|
LinuxStat::Net.total_bytes_transmitted()
|
381
|
-
=>
|
442
|
+
=> 69471921
|
382
443
|
|
383
|
-
# File:
|
384
|
-
# Definition:
|
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:
|
393
|
-
# Definition:
|
453
|
+
# File: os.rb | Line: 97
|
454
|
+
# Definition: def bits
|
394
455
|
LinuxStat::OS.bits()
|
395
456
|
=> 64
|
396
457
|
|
397
|
-
# File:
|
398
|
-
# Definition:
|
458
|
+
# File: os.rb | Line: 42
|
459
|
+
# Definition: def distribution
|
399
460
|
LinuxStat::OS.distribution()
|
400
461
|
=> "Arch Linux"
|
401
462
|
|
402
|
-
# File:
|
403
|
-
# Definition:
|
463
|
+
# File: os.rb | Line: 81
|
464
|
+
# Definition: def hostname
|
404
465
|
LinuxStat::OS.hostname()
|
405
466
|
=> "archlinux"
|
406
467
|
|
407
|
-
# File:
|
408
|
-
# Definition:
|
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:
|
413
|
-
# Definition:
|
473
|
+
# File: os.rb | Line: 64
|
474
|
+
# Definition: def machine
|
414
475
|
LinuxStat::OS.machine()
|
415
476
|
=> "x86_64"
|
416
477
|
|
417
|
-
# File:
|
418
|
-
# Definition:
|
478
|
+
# File: os.rb | Line: 72
|
479
|
+
# Definition: def nodename
|
419
480
|
LinuxStat::OS.nodename()
|
420
481
|
=> "archlinux"
|
421
482
|
|
422
|
-
# File:
|
423
|
-
# Definition:
|
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:
|
428
|
-
# Definition:
|
488
|
+
# File: os.rb | Line: 110
|
489
|
+
# Definition: def uptime
|
429
490
|
LinuxStat::OS.uptime()
|
430
|
-
=> {:hour=>
|
491
|
+
=> {:hour=>12, :minute=>11, :second=>45.16}
|
431
492
|
|
432
493
|
```
|
433
494
|
|
434
495
|
### LinuxStat::PrettifyBytes
|
435
496
|
```
|
436
|
-
# File:
|
437
|
-
# Definition:
|
438
|
-
LinuxStat::PrettifyBytes.convert_binary( =
|
439
|
-
=> "
|
497
|
+
# File: prettify_bytes.rb | Line: 42
|
498
|
+
# Definition: def convert_binary(n)
|
499
|
+
LinuxStat::PrettifyBytes.convert_binary(n = 122600299243524)
|
500
|
+
=> "111.50 tebibytes"
|
440
501
|
|
441
|
-
# File:
|
442
|
-
# Definition:
|
443
|
-
LinuxStat::PrettifyBytes.convert_decimal( =
|
444
|
-
=> "
|
502
|
+
# File: prettify_bytes.rb | Line: 19
|
503
|
+
# Definition: def convert_decimal(n)
|
504
|
+
LinuxStat::PrettifyBytes.convert_decimal(n = 610088277227728)
|
505
|
+
=> "610.09 terabytes"
|
445
506
|
|
446
|
-
# File:
|
447
|
-
# Definition:
|
448
|
-
LinuxStat::PrettifyBytes.convert_short_binary( =
|
449
|
-
=> "
|
507
|
+
# File: prettify_bytes.rb | Line: 90
|
508
|
+
# Definition: def convert_short_binary(n)
|
509
|
+
LinuxStat::PrettifyBytes.convert_short_binary(n = 117789985929175)
|
510
|
+
=> "107.13 TiB"
|
450
511
|
|
451
|
-
# File:
|
452
|
-
# Definition:
|
453
|
-
LinuxStat::PrettifyBytes.convert_short_decimal( =
|
454
|
-
=> "
|
512
|
+
# File: prettify_bytes.rb | Line: 65
|
513
|
+
# Definition: def convert_short_decimal(n)
|
514
|
+
LinuxStat::PrettifyBytes.convert_short_decimal(n = 598923420265643)
|
515
|
+
=> "598.92 TB"
|
455
516
|
|
456
517
|
```
|
457
518
|
|
458
519
|
### LinuxStat::Process
|
459
520
|
```
|
460
|
-
# File:
|
461
|
-
# Definition:
|
521
|
+
# File: process.rb | Line: 19
|
522
|
+
# Definition: def count
|
462
523
|
LinuxStat::Process.count()
|
463
|
-
=>
|
524
|
+
=> 208
|
464
525
|
|
465
|
-
# File:
|
466
|
-
# Definition:
|
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,
|
529
|
+
=> [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 119, 120, 122, 132, 135, 141, 153, 154, 170, 172, 174, 175, 178, 183, 184, 185, 186, 187, 188, 231, 263, 270, 331, 337, 5813, 9989, 16385, 17981, 18103, 18138, 18800, 18...
|
469
530
|
|
470
|
-
# File:
|
471
|
-
# Definition:
|
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,
|
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, 119, 120, 122, 132, 135,...
|
474
535
|
|
475
|
-
# File:
|
476
|
-
# Definition:
|
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:
|
481
|
-
# Definition:
|
541
|
+
# File: process.rb | Line: 97
|
542
|
+
# Definition: def running
|
482
543
|
LinuxStat::Process.running()
|
483
|
-
=> [
|
544
|
+
=> [20187, 20447]
|
484
545
|
|
485
|
-
# File:
|
486
|
-
# Definition:
|
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,
|
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, 169, 171, 189, 218, 235, 308, 309, 310, 311, 326, 356, 357, 358, 359, 375, 378, 381, 408, 426, 428, 429,...
|
489
550
|
|
490
|
-
# File:
|
491
|
-
# Definition:
|
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:
|
496
|
-
# Definition:
|
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:
|
505
|
-
# Definition:
|
565
|
+
# File: process_info.rb | Line: 54
|
566
|
+
# Definition: def cmdline(pid = $$)
|
506
567
|
LinuxStat::ProcessInfo.cmdline(pid)
|
507
568
|
=> "ruby /usr/bin/linuxstat.rb -md"
|
508
569
|
|
509
|
-
# File:
|
510
|
-
# Definition:
|
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:
|
515
|
-
# 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)
|
516
582
|
LinuxStat::ProcessInfo.cpu_stat(pid:, sleep:)
|
517
|
-
=> {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>
|
583
|
+
=> {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>2}
|
518
584
|
|
519
|
-
# File:
|
520
|
-
# Definition:
|
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:
|
525
|
-
# Definition:
|
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:
|
530
|
-
# Definition:
|
595
|
+
# File: process_info.rb | Line: 433
|
596
|
+
# Definition: def last_executed_cpu(pid = $$)
|
531
597
|
LinuxStat::ProcessInfo.last_executed_cpu(pid)
|
532
|
-
=>
|
598
|
+
=> 2
|
533
599
|
|
534
|
-
# File:
|
535
|
-
# Definition:
|
600
|
+
# File: process_info.rb | Line: 114
|
601
|
+
# Definition: def mem_stat(pid = $$)
|
536
602
|
LinuxStat::ProcessInfo.mem_stat(pid)
|
537
|
-
=> {:memory=>
|
603
|
+
=> {:memory=>12484.608, :virtual_memory=>84090.88, :resident_memory=>18665.472}
|
538
604
|
|
539
|
-
# File:
|
540
|
-
# Definition:
|
605
|
+
# File: process_info.rb | Line: 147
|
606
|
+
# Definition: def memory(pid = $$)
|
541
607
|
LinuxStat::ProcessInfo.memory(pid)
|
542
|
-
=>
|
608
|
+
=> 12484.608
|
543
609
|
|
544
|
-
# File:
|
545
|
-
# Definition:
|
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:
|
550
|
-
# 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 = $$)
|
551
622
|
LinuxStat::ProcessInfo.owner(pid)
|
552
623
|
=> "sourav"
|
553
624
|
|
554
|
-
# File:
|
555
|
-
# Definition:
|
625
|
+
# File: process_info.rb | Line: 197
|
626
|
+
# Definition: def resident_memory(pid = $$)
|
556
627
|
LinuxStat::ProcessInfo.resident_memory(pid)
|
557
|
-
=>
|
628
|
+
=> 18665.472
|
558
629
|
|
559
|
-
# File:
|
560
|
-
# Definition:
|
630
|
+
# File: process_info.rb | Line: 563
|
631
|
+
# Definition: def running_time(pid = $$)
|
561
632
|
LinuxStat::ProcessInfo.running_time(pid)
|
562
|
-
=>
|
633
|
+
=> 0.8
|
563
634
|
|
564
|
-
# File:
|
565
|
-
# Definition:
|
635
|
+
# File: process_info.rb | Line: 544
|
636
|
+
# Definition: def start_time(pid = $$)
|
566
637
|
LinuxStat::ProcessInfo.start_time(pid)
|
567
|
-
=> 2020-12-
|
638
|
+
=> 2020-12-23 00:57:33 +0530
|
568
639
|
|
569
|
-
# File:
|
570
|
-
# Definition:
|
640
|
+
# File: process_info.rb | Line: 513
|
641
|
+
# Definition: def start_time_epoch(pid = $$)
|
571
642
|
LinuxStat::ProcessInfo.start_time_epoch(pid)
|
572
|
-
=>
|
643
|
+
=> 1608665253
|
573
644
|
|
574
|
-
# File:
|
575
|
-
# Definition:
|
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:
|
580
|
-
# Definition:
|
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:
|
585
|
-
# Definition:
|
660
|
+
# File: process_info.rb | Line: 23
|
661
|
+
# Definition: def total_io(pid = $$)
|
586
662
|
LinuxStat::ProcessInfo.total_io(pid)
|
587
|
-
=> {:read_bytes=>
|
663
|
+
=> {:read_bytes=>4096, :write_bytes=>0}
|
588
664
|
|
589
|
-
# File:
|
590
|
-
# Definition:
|
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:
|
595
|
-
# Definition:
|
670
|
+
# File: process_info.rb | Line: 172
|
671
|
+
# Definition: def virtual_memory(pid = $$)
|
596
672
|
LinuxStat::ProcessInfo.virtual_memory(pid)
|
597
|
-
=>
|
673
|
+
=> 84090.88
|
598
674
|
|
599
675
|
```
|
600
676
|
|
601
677
|
### LinuxStat::Swap
|
602
678
|
```
|
603
|
-
# File:
|
604
|
-
# Definition:
|
679
|
+
# File: swap.rb | Line: 22
|
680
|
+
# Definition: def any?
|
605
681
|
LinuxStat::Swap.any?()
|
606
682
|
=> true
|
607
683
|
|
608
|
-
# File:
|
609
|
-
# Definition:
|
684
|
+
# File: swap.rb | Line: 68
|
685
|
+
# Definition: def available
|
610
686
|
LinuxStat::Swap.available()
|
611
|
-
=>
|
687
|
+
=> 4058184
|
612
688
|
|
613
|
-
# File:
|
614
|
-
# Definition:
|
689
|
+
# File: swap.rb | Line: 8
|
690
|
+
# Definition: def list
|
615
691
|
LinuxStat::Swap.list()
|
616
|
-
=> {"/dev/zram0"=>[:partition, 4194300,
|
692
|
+
=> {"/dev/zram0"=>[:partition, 4194300, 136116, -2]}
|
617
693
|
|
618
|
-
# File:
|
619
|
-
# Definition:
|
694
|
+
# File: swap.rb | Line: 103
|
695
|
+
# Definition: def percent_available
|
620
696
|
LinuxStat::Swap.percent_available()
|
621
|
-
=>
|
697
|
+
=> 96.75
|
622
698
|
|
623
|
-
# File:
|
624
|
-
# Definition:
|
699
|
+
# File: swap.rb | Line: 89
|
700
|
+
# Definition: def percent_used
|
625
701
|
LinuxStat::Swap.percent_used()
|
626
|
-
=>
|
702
|
+
=> 3.25
|
627
703
|
|
628
|
-
# File:
|
629
|
-
# Definition:
|
704
|
+
# File: swap.rb | Line: 32
|
705
|
+
# Definition: def stat
|
630
706
|
LinuxStat::Swap.stat()
|
631
|
-
=> {:total=>4194300, :used=>
|
707
|
+
=> {:total=>4194300, :used=>136116, :available=>4058184, :percent_used=>3.25, :percent_available=>96.75}
|
632
708
|
|
633
|
-
# File:
|
634
|
-
# Definition:
|
709
|
+
# File: swap.rb | Line: 57
|
710
|
+
# Definition: def total
|
635
711
|
LinuxStat::Swap.total()
|
636
712
|
=> 4194300
|
637
713
|
|
638
|
-
# File:
|
639
|
-
# Definition:
|
714
|
+
# File: swap.rb | Line: 80
|
715
|
+
# Definition: def used
|
640
716
|
LinuxStat::Swap.used()
|
641
|
-
=>
|
717
|
+
=> 136116
|
642
718
|
|
643
719
|
```
|
644
720
|
|
645
721
|
### LinuxStat::Sysconf
|
646
722
|
```
|
647
723
|
LinuxStat::Sysconf.child_max()
|
648
|
-
=>
|
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
|
-
=>
|
754
|
+
=> 1024
|
673
755
|
|
674
756
|
LinuxStat::Sysconf.pagesize()
|
675
757
|
=> 4096
|
676
758
|
|
677
759
|
LinuxStat::Sysconf.posix_version()
|
678
|
-
=>
|
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
|
@@ -709,93 +797,93 @@ LinuxStat::Uname.version()
|
|
709
797
|
|
710
798
|
### LinuxStat::User
|
711
799
|
```
|
712
|
-
# File:
|
713
|
-
# Definition:
|
800
|
+
# File: user.rb | Line: 98
|
801
|
+
# Definition: def get_user
|
714
802
|
LinuxStat::User.get_current_user()
|
715
803
|
=> "sourav"
|
716
804
|
|
717
|
-
# File:
|
718
|
-
# Definition:
|
805
|
+
# File: user.rb | Line: 137
|
806
|
+
# Definition: def get_euid
|
719
807
|
LinuxStat::User.get_euid()
|
720
808
|
=> 1000
|
721
809
|
|
722
|
-
# File:
|
723
|
-
# Definition:
|
810
|
+
# File: user.rb | Line: 129
|
811
|
+
# Definition: def get_gid
|
724
812
|
LinuxStat::User.get_gid()
|
725
813
|
=> 1000
|
726
814
|
|
727
|
-
# File:
|
728
|
-
# Definition:
|
815
|
+
# File: user.rb | Line: 152
|
816
|
+
# Definition: def get_login
|
729
817
|
LinuxStat::User.get_login()
|
730
818
|
=> "sourav"
|
731
819
|
|
732
|
-
# File:
|
733
|
-
# Definition:
|
820
|
+
# File: user.rb | Line: 121
|
821
|
+
# Definition: def get_uid
|
734
822
|
LinuxStat::User.get_uid()
|
735
823
|
=> 1000
|
736
824
|
|
737
|
-
# File:
|
738
|
-
# Definition:
|
825
|
+
# File: user.rb | Line: 98
|
826
|
+
# Definition: def get_user
|
739
827
|
LinuxStat::User.get_user()
|
740
828
|
=> "sourav"
|
741
829
|
|
742
|
-
# File:
|
743
|
-
# Definition:
|
830
|
+
# File: user.rb | Line: 215
|
831
|
+
# Definition: def gid_by_username(username = get_user)
|
744
832
|
LinuxStat::User.gid_by_username(username)
|
745
833
|
=> 1000
|
746
834
|
|
747
|
-
# File:
|
748
|
-
# Definition:
|
835
|
+
# File: user.rb | Line: 56
|
836
|
+
# Definition: def gids
|
749
837
|
LinuxStat::User.gids()
|
750
838
|
=> {: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
839
|
|
752
|
-
# File:
|
753
|
-
# Definition:
|
840
|
+
# File: user.rb | Line: 314
|
841
|
+
# Definition: def home_by_gid(id = get_gid)
|
754
842
|
LinuxStat::User.home_by_gid(id)
|
755
843
|
=> "/home/sourav"
|
756
844
|
|
757
|
-
# File:
|
758
|
-
# Definition:
|
845
|
+
# File: user.rb | Line: 266
|
846
|
+
# Definition: def home_by_username(user = get_user)
|
759
847
|
LinuxStat::User.home_by_username(user)
|
760
848
|
=> "/home/sourav"
|
761
849
|
|
762
|
-
# File:
|
763
|
-
# Definition:
|
850
|
+
# File: user.rb | Line: 72
|
851
|
+
# Definition: def home_directories
|
764
852
|
LinuxStat::User.home_directories()
|
765
853
|
=> {: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
854
|
|
767
|
-
# File:
|
768
|
-
# Definition:
|
855
|
+
# File: user.rb | Line: 293
|
856
|
+
# Definition: def homes_by_uid(id = get_uid)
|
769
857
|
LinuxStat::User.homes_by_uid(id)
|
770
858
|
=> ["/home/sourav"]
|
771
859
|
|
772
|
-
# File:
|
773
|
-
# Definition:
|
860
|
+
# File: user.rb | Line: 23
|
861
|
+
# Definition: def ids
|
774
862
|
LinuxStat::User.ids()
|
775
863
|
=> {: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
864
|
|
777
|
-
# File:
|
778
|
-
# Definition:
|
865
|
+
# File: user.rb | Line: 11
|
866
|
+
# Definition: def list
|
779
867
|
LinuxStat::User.list()
|
780
868
|
=> ["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
869
|
|
782
|
-
# File:
|
783
|
-
# Definition:
|
870
|
+
# File: user.rb | Line: 244
|
871
|
+
# Definition: def uid_by_username(username = get_user)
|
784
872
|
LinuxStat::User.uid_by_username(username)
|
785
873
|
=> 1000
|
786
874
|
|
787
|
-
# File:
|
788
|
-
# Definition:
|
875
|
+
# File: user.rb | Line: 40
|
876
|
+
# Definition: def uids
|
789
877
|
LinuxStat::User.uids()
|
790
878
|
=> {: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
879
|
|
792
|
-
# File:
|
793
|
-
# Definition:
|
880
|
+
# File: user.rb | Line: 187
|
881
|
+
# Definition: def username_by_gid(gid = get_gid)
|
794
882
|
LinuxStat::User.username_by_gid(gid)
|
795
883
|
=> "sourav"
|
796
884
|
|
797
|
-
# File:
|
798
|
-
# Definition:
|
885
|
+
# File: user.rb | Line: 169
|
886
|
+
# Definition: def usernames_by_uid(uid = get_uid)
|
799
887
|
LinuxStat::User.usernames_by_uid(uid)
|
800
888
|
=> ["sourav"]
|
801
889
|
|
@@ -867,7 +955,120 @@ well as soon as the Linux kernel updates the data and ruby executes the loop.
|
|
867
955
|
|
868
956
|
Just run the linuxstat.rb command to test what method takes what time measured in microseconds.
|
869
957
|
|
870
|
-
## Note 2:
|
958
|
+
## Note 2: Count CPU
|
959
|
+
|
960
|
+
There are confusingly 6 different methods to count the number of CPU. But they are here for a reason!
|
961
|
+
|
962
|
+
Well this section actually demystifies the methods.
|
963
|
+
|
964
|
+
1. The good old `LinuxStat::CPU.count()`:
|
965
|
+
|
966
|
+
It gets the configured CPU for the system. It doesn't count for hotplugged CPU.
|
967
|
+
If 3 out of 4 CPU are hotplugged out, it will still show 4. It calles `sysconf(_SC_NPROCESSORS_CONF)`
|
968
|
+
|
969
|
+
2. The mysterious `LinuxStat::ProcessInfo.nproc(pid = $$)`:
|
970
|
+
|
971
|
+
[ Also aliased to `LinuxStat::ProcessInfo.count_cpu()` ]
|
972
|
+
|
973
|
+
It returns the number of processors, like the other 3 methods.
|
974
|
+
Without any arguments, it's like running `require 'etc' ; puts Etc.nprocessors`
|
975
|
+
|
976
|
+
So there the caveat of checking what the number of processors are actually allocated to the pid.
|
977
|
+
|
978
|
+
For example:
|
979
|
+
|
980
|
+
```
|
981
|
+
$ ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
|
982
|
+
4
|
983
|
+
|
984
|
+
$ taskset -c 0 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
|
985
|
+
1
|
986
|
+
|
987
|
+
$ taskset -c 0-1 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
|
988
|
+
2
|
989
|
+
|
990
|
+
$ taskset -c 0-1,3 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc"
|
991
|
+
3
|
992
|
+
|
993
|
+
$ taskset -c 0-1,3 ruby -r linux_stat -e "puts LS::ProcessInfo.nproc "
|
994
|
+
3
|
995
|
+
```
|
996
|
+
|
997
|
+
Or with argument:
|
998
|
+
|
999
|
+
```
|
1000
|
+
irb(main):001:0> require 'linux_stat'
|
1001
|
+
=> true
|
1002
|
+
|
1003
|
+
irb(main):002:0> LinuxStat::ProcessInfo.command_name 4775
|
1004
|
+
=> "electron"
|
1005
|
+
|
1006
|
+
irb(main):003:0> LinuxStat::ProcessInfo.nproc 4775
|
1007
|
+
=> 4
|
1008
|
+
```
|
1009
|
+
|
1010
|
+
3. The `LinuxStat::CPU.online()`:
|
1011
|
+
|
1012
|
+
This returns the number of online CPU as an Array. It doesn't get affected by taskset or anything.
|
1013
|
+
|
1014
|
+
For example:
|
1015
|
+
|
1016
|
+
```
|
1017
|
+
irb(main):001:0> require 'linux_stat'
|
1018
|
+
=> true
|
1019
|
+
|
1020
|
+
irb(main):002:0> LinuxStat::CPU.online
|
1021
|
+
=> [0, 1, 3]
|
1022
|
+
```
|
1023
|
+
|
1024
|
+
By using `LinuxStat::CPU.online.count` you count the actual online CPU on your system.
|
1025
|
+
|
1026
|
+
Any n number of CPU can get hotplugged in and out, and this will report that correctly.
|
1027
|
+
|
1028
|
+
It just gets the info from /proc/stat; but if it fails it will read /sys/devices/system/cpu/online
|
1029
|
+
and parse the output to get an array.
|
1030
|
+
|
1031
|
+
4. The `LinuxStat::CPU.count_online`
|
1032
|
+
It's a more robust method that counts the online CPU. It shouldn't fail in most if not all cases!
|
1033
|
+
But if it fails for some really spooky reasons, it will return nil.
|
1034
|
+
|
1035
|
+
4. The `LinuxStat::CPU.offline()`:
|
1036
|
+
|
1037
|
+
This returns the number of offline CPU as an Array. It doesn't get affected by taskset or anything.
|
1038
|
+
|
1039
|
+
For example:
|
1040
|
+
|
1041
|
+
```
|
1042
|
+
irb(main):001:0> require 'linux_stat'
|
1043
|
+
=> true
|
1044
|
+
|
1045
|
+
irb(main):002:0> LinuxStat::CPU.offline
|
1046
|
+
=> [2]
|
1047
|
+
```
|
1048
|
+
|
1049
|
+
Any n number of CPU can get hotplugged in and out, and this will report that correctly.
|
1050
|
+
|
1051
|
+
It just gets the info from /sys/devices/system/cpu/offline, and parses the output.
|
1052
|
+
|
1053
|
+
5. The `LinuxStat::Sysconf.processor_configured()`:
|
1054
|
+
|
1055
|
+
Sounds repetitive! Actually yes, this is written in C, and it is called by `LinuxStat::CPU.count`.
|
1056
|
+
|
1057
|
+
The difference is that `LinuxStat::CPU.count` caches the return value, and this method doesn't.
|
1058
|
+
|
1059
|
+
6. The `LinuxStat::Sysconf.processor_online()`:
|
1060
|
+
|
1061
|
+
This may again sound repititive to LinuxStat::CPU.online, but it's actually not!
|
1062
|
+
|
1063
|
+
If you are using while loops, it might not report the correct number of CPU everytime.
|
1064
|
+
|
1065
|
+
Worst, it can take a long time to update the total number of CPU.
|
1066
|
+
|
1067
|
+
The benefit is, it's quite fast!
|
1068
|
+
|
1069
|
+
It's mostly here just for the sake of completeness to sysconf.
|
1070
|
+
|
1071
|
+
## Note 3: Filesystem
|
871
1072
|
|
872
1073
|
Filesystem can take arguments. By default it's '/' or the root of the system...
|
873
1074
|
|
@@ -902,7 +1103,7 @@ irb(main):005:0> LinuxStat::Filesystem.total(thumbdrive).fdiv(1024 ** 3).to_s <<
|
|
902
1103
|
=> "29.305004119873047 GiB"
|
903
1104
|
```
|
904
1105
|
|
905
|
-
## Note
|
1106
|
+
## Note 4: ProcessInfo
|
906
1107
|
|
907
1108
|
All the methods LinuxStat::ProcessInfo can take an argument containing the Process ID of a process.
|
908
1109
|
By default it's $$ or the PID of the current process, ruby, itself.
|
@@ -954,7 +1155,7 @@ irb(main):002:0> LinuxStat::ProcessInfo.memory(LinuxStat::Process.names.find { |
|
|
954
1155
|
=> "467.51 MiB"
|
955
1156
|
```
|
956
1157
|
|
957
|
-
## Note
|
1158
|
+
## Note 5: FS
|
958
1159
|
|
959
1160
|
LinuxStat::FS module gives you the raw info in Hash collected from statvfs.
|
960
1161
|
|
@@ -979,7 +1180,7 @@ irb(main):003:0> t = Time.now ; puts LinuxStat::FS.stat('/') ; Time.now - t
|
|
979
1180
|
|
980
1181
|
To learn more about them, just run ri and the method name. To see all available methods.
|
981
1182
|
|
982
|
-
## Note
|
1183
|
+
## Note 6: User
|
983
1184
|
Most of the LinuxStat::User supports arguments.
|
984
1185
|
|
985
1186
|
For example, to get a user's home by the username:
|
@@ -1061,7 +1262,7 @@ irb(main):004:0> LinuxStat::User.get_login
|
|
1061
1262
|
|
1062
1263
|
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
1264
|
|
1064
|
-
## Note
|
1265
|
+
## Note 7: PrettifyBytes
|
1065
1266
|
Often times we need to work with KB, MB GB, TB, or KiB, MiB, GiB, TiB, etc.
|
1066
1267
|
And we need some work to convert bytes to those units.
|
1067
1268
|
Because LinuxStat provides a lot of data in bytes, and kilobytes, it's quite tedious to convert them all the time.
|
@@ -1201,6 +1402,16 @@ Issues regarding running LinuxStat on termux are also welcomed.
|
|
1201
1402
|
|
1202
1403
|
---
|
1203
1404
|
|
1405
|
+
## Cloning this Repo
|
1406
|
+
Users of this gem are requested to follow the above installation step to install this gem.
|
1407
|
+
|
1408
|
+
This repo is only for development purpose. It has C extensions that could do worst to your stable app.
|
1409
|
+
Cloning, compiling code from this repo for a production app may seg fault and crash the whole app directly.
|
1410
|
+
|
1411
|
+
Gems on Rubygems are released after various tests.
|
1412
|
+
|
1413
|
+
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.
|
1414
|
+
|
1204
1415
|
## Development
|
1205
1416
|
After checking out the repo, compile and install this gem onto your local machine with `bundle exec rake install`
|
1206
1417
|
|