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