linux_stat 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +54 -1052
- data/exe/linuxstat.rb +2 -2
- data/lib/linux_stat/battery.rb +32 -6
- data/lib/linux_stat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a2257dd9d025a05cf31fbfdf06d67933abd1d355678fe23c0ab1d5797fce9e9
|
4
|
+
data.tar.gz: 3898fa563cda7716321f689a64448afb0b46bb7ba1c9bac297c9f3ba0e9e4f38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6fede8da5d7a14322253c8c108b56069f0d3089349f23a9b7c207500c240b8a855a847dc9de649797da81466e449911609f3308473a4d8f5c32c1d0622cf46
|
7
|
+
data.tar.gz: 0f61a61920ca364cba0b3e664ff67bab7fcbf45d3d47eaea622b71b2fde7585cb761025f1b02d8f7e80ea0105b66541432cdb7ca12594938a6d5f04c0d648b05
|
data/README.md
CHANGED
@@ -8,11 +8,27 @@ For reading the eyecandy HTML version, visit [linux_stat](https://souravgoswami.
|
|
8
8
|
|
9
9
|
LinuxStat lets you read status of a Linux system. It can show you cpu stats and usages, memory stats and usages, swap stats and usages, battery usage, bios info, kernel details, local ip, os details and parse os-release + lsb-release, etc.
|
10
10
|
|
11
|
-
It only works
|
11
|
+
It only works on Linux, and detecting the OS is upto the user of this gem.
|
12
12
|
|
13
|
-
|
13
|
+
---
|
14
14
|
|
15
|
-
|
15
|
+
| Table of Contents |
|
16
|
+
|:---|
|
17
|
+
| [Runtime Dependencies](https://github.com/Souravgoswami/linux_stat#runtime-dependencies) |
|
18
|
+
| [Build Dependencies](https://github.com/Souravgoswami/linux_stat#build-dependencies) |
|
19
|
+
| [Optional Runtime Dependencies](https://github.com/Souravgoswami/linux_stat#optional-runtime-dependencies) |
|
20
|
+
| [Installation](https://github.com/Souravgoswami/linux_stat#installation) |
|
21
|
+
| [Usage](https://github.com/Souravgoswami/linux_stat#usage) |
|
22
|
+
| [Notes](https://github.com/Souravgoswami/linux_stat#notes) |
|
23
|
+
| [Return Types](https://github.com/Souravgoswami/linux_stat#return-types) |
|
24
|
+
| [Ruby On Rails](https://github.com/Souravgoswami/linux_stat#ruby-on-rails) |
|
25
|
+
| [Android](https://github.com/Souravgoswami/linux_stat#android) |
|
26
|
+
| [Cloning this Repo](https://github.com/Souravgoswami/linux_stat#cloning-this-repo) |
|
27
|
+
| [Development](https://github.com/Souravgoswami/linux_stat#development) |
|
28
|
+
| [Testing](https://github.com/Souravgoswami/linux_stat#testing) |
|
29
|
+
| [Contributing](https://github.com/Souravgoswami/linux_stat#contributing) |
|
30
|
+
| [License](https://github.com/Souravgoswami/linux_stat#license) |
|
31
|
+
| [Languages](https://github.com/Souravgoswami/linux_stat#languages) |
|
16
32
|
|
17
33
|
---
|
18
34
|
|
@@ -84,1060 +100,42 @@ $ gem install linux_stat
|
|
84
100
|
```
|
85
101
|
|
86
102
|
## Usage
|
87
|
-
Following are the LinuxStat modules and module functions.
|
88
|
-
It's generated by linuxstat.rb command, which is available after the installation.
|
89
|
-
|
90
|
-
For ease of use, LinuxStat is also assigned to the LS constant.
|
91
|
-
|
92
|
-
### LinuxStat::BIOS
|
93
|
-
```
|
94
|
-
# File: bios.rb | Line: 58
|
95
|
-
# Definition: def date
|
96
|
-
LinuxStat::BIOS.date()
|
97
|
-
=> "04/10/2017"
|
98
|
-
|
99
|
-
# File: bios.rb | Line: 12
|
100
|
-
# Definition: def model
|
101
|
-
LinuxStat::BIOS.model()
|
102
|
-
=> "Inspiron 5567"
|
103
|
-
|
104
|
-
# File: bios.rb | Line: 29
|
105
|
-
# Definition: def vendor
|
106
|
-
LinuxStat::BIOS.vendor()
|
107
|
-
=> "Dell Inc."
|
108
|
-
|
109
|
-
# File: bios.rb | Line: 44
|
110
|
-
# Definition: def version
|
111
|
-
LinuxStat::BIOS.version()
|
112
|
-
=> "1.1.2"
|
113
|
-
|
114
|
-
```
|
115
|
-
|
116
|
-
### LinuxStat::Battery
|
117
|
-
```
|
118
|
-
# File: battery.rb | Line: 107
|
119
|
-
# Definition: def charge
|
120
|
-
LinuxStat::Battery.charge()
|
121
|
-
=> 100.0
|
122
|
-
|
123
|
-
# File: battery.rb | Line: 124
|
124
|
-
# Definition: def charge_full_design_wh
|
125
|
-
LinuxStat::Battery.charge_full_design_wh()
|
126
|
-
=> 42.0
|
127
|
-
|
128
|
-
# File: battery.rb | Line: 143
|
129
|
-
# Definition: def charge_full_wh
|
130
|
-
LinuxStat::Battery.charge_full_wh()
|
131
|
-
=> 23.79
|
132
|
-
|
133
|
-
# File: battery.rb | Line: 80
|
134
|
-
# Definition: def charging?
|
135
|
-
LinuxStat::Battery.charging?()
|
136
|
-
=> true
|
137
|
-
|
138
|
-
# File: battery.rb | Line: 193
|
139
|
-
# Definition: def devices_stat
|
140
|
-
LinuxStat::Battery.devices_stat()
|
141
|
-
=> {: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....
|
142
|
-
|
143
|
-
# File: battery.rb | Line: 89
|
144
|
-
# Definition: def discharging?
|
145
|
-
LinuxStat::Battery.discharging?()
|
146
|
-
=> false
|
147
|
-
|
148
|
-
# File: battery.rb | Line: 98
|
149
|
-
# Definition: def full?
|
150
|
-
LinuxStat::Battery.full?()
|
151
|
-
=> true
|
152
|
-
|
153
|
-
# File: battery.rb | Line: 49
|
154
|
-
# Definition: def manufacturer
|
155
|
-
LinuxStat::Battery.manufacturer()
|
156
|
-
=> "Samsung SDI"
|
157
|
-
|
158
|
-
# File: battery.rb | Line: 38
|
159
|
-
# Definition: def model
|
160
|
-
LinuxStat::Battery.model()
|
161
|
-
=> "DELL CYMGM77"
|
162
|
-
|
163
|
-
# File: battery.rb | Line: 10
|
164
|
-
# Definition: def present?
|
165
|
-
LinuxStat::Battery.present?()
|
166
|
-
=> true
|
167
|
-
|
168
|
-
# File: battery.rb | Line: 18
|
169
|
-
# Definition: def stat
|
170
|
-
LinuxStat::Battery.stat()
|
171
|
-
=> {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Full", :charge=>100.0, :charging=>true, :discharging=>false, :full=>true}
|
172
|
-
|
173
|
-
# File: battery.rb | Line: 70
|
174
|
-
# Definition: def status
|
175
|
-
LinuxStat::Battery.status()
|
176
|
-
=> "Full"
|
177
|
-
|
178
|
-
# File: battery.rb | Line: 59
|
179
|
-
# Definition: def technology
|
180
|
-
LinuxStat::Battery.technology()
|
181
|
-
=> "Li-ion"
|
182
|
-
|
183
|
-
# File: battery.rb | Line: 162
|
184
|
-
# Definition: def voltage_now
|
185
|
-
LinuxStat::Battery.voltage_now()
|
186
|
-
=> 12.531
|
187
|
-
|
188
|
-
```
|
189
|
-
|
190
|
-
### LinuxStat::CPU
|
191
|
-
```
|
192
|
-
# File: cpu.rb | Line: 289
|
193
|
-
# Definition: def available_governors
|
194
|
-
LinuxStat::CPU.available_governors()
|
195
|
-
=> {"cpu0"=>["performance", "powersave"], "cpu1"=>["performance", "powersave"], "cpu2"=>["performance", "powersave"], "cpu3"=>["performance", "powersave"]}
|
196
|
-
|
197
|
-
# File: cpu.rb | Line: 88
|
198
|
-
# Definition: def count
|
199
|
-
LinuxStat::CPU.count()
|
200
|
-
=> 4
|
201
|
-
|
202
|
-
# File: cpu.rb | Line: 105
|
203
|
-
# Definition: def count_online
|
204
|
-
LinuxStat::CPU.count_online()
|
205
|
-
=> 4
|
206
|
-
|
207
|
-
# File: cpu.rb | Line: 199
|
208
|
-
# Definition: def cur_freq
|
209
|
-
LinuxStat::CPU.cur_freq()
|
210
|
-
=> {"cpu0"=>1969861, "cpu1"=>2000059, "cpu2"=>2000024, "cpu3"=>1949778}
|
211
|
-
|
212
|
-
# File: cpu.rb | Line: 267
|
213
|
-
# Definition: def governor
|
214
|
-
LinuxStat::CPU.governor()
|
215
|
-
=> {"cpu0"=>"performance", "cpu1"=>"performance", "cpu2"=>"performance", "cpu3"=>"performance"}
|
216
|
-
|
217
|
-
# File: cpu.rb | Line: 243
|
218
|
-
# Definition: def max_freq
|
219
|
-
LinuxStat::CPU.max_freq()
|
220
|
-
=> {"cpu0"=>2000000, "cpu1"=>2000000, "cpu2"=>2000000, "cpu3"=>2000000}
|
221
|
-
|
222
|
-
# File: cpu.rb | Line: 221
|
223
|
-
# Definition: def min_freq
|
224
|
-
LinuxStat::CPU.min_freq()
|
225
|
-
=> {"cpu0"=>2000000, "cpu1"=>2000000, "cpu2"=>2000000, "cpu3"=>2000000}
|
226
|
-
|
227
|
-
# File: cpu.rb | Line: 186
|
228
|
-
# Definition: def model
|
229
|
-
LinuxStat::CPU.model()
|
230
|
-
=> "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
|
231
|
-
|
232
|
-
# File: cpu.rb | Line: 165
|
233
|
-
# Definition: def offline
|
234
|
-
LinuxStat::CPU.offline()
|
235
|
-
=> []
|
236
|
-
|
237
|
-
# File: cpu.rb | Line: 134
|
238
|
-
# Definition: def online
|
239
|
-
LinuxStat::CPU.online()
|
240
|
-
=> [0, 1, 2, 3]
|
241
|
-
|
242
|
-
# File: cpu.rb | Line: 25
|
243
|
-
# Definition: def stat(sleep = ticks_to_ms_t5)
|
244
|
-
LinuxStat::CPU.stat(sleep)
|
245
|
-
=> {0=>9.52, 1=>16.67, 2=>20.0, 3=>0.0, 4=>16.67}
|
246
|
-
|
247
|
-
# File: cpu.rb | Line: 65
|
248
|
-
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
249
|
-
LinuxStat::CPU.total_usage(sleep)
|
250
|
-
=> 5.56
|
251
|
-
|
252
|
-
# File: cpu.rb | Line: 65
|
253
|
-
# Definition: def total_usage(sleep = ticks_to_ms_t5)
|
254
|
-
LinuxStat::CPU.usage(sleep)
|
255
|
-
=> 5.0
|
256
|
-
|
257
|
-
# File: cpu.rb | Line: 25
|
258
|
-
# Definition: def stat(sleep = ticks_to_ms_t5)
|
259
|
-
LinuxStat::CPU.usages(sleep)
|
260
|
-
=> {0=>10.0, 1=>0.0, 2=>0.0, 3=>0.0, 4=>0.0}
|
261
|
-
|
262
|
-
```
|
263
|
-
|
264
|
-
### LinuxStat::FS
|
265
|
-
```
|
266
|
-
LinuxStat::FS.stat(arg = "/")
|
267
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>7498564, :block_avail_unpriv=>7498564, :inodes=>58612160, :free_inodes=>56765394, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
268
|
-
|
269
|
-
```
|
270
|
-
|
271
|
-
### LinuxStat::Filesystem
|
272
|
-
```
|
273
|
-
# File: filesystem.rb | Line: 94
|
274
|
-
# Definition: def available(fs = ?..freeze)
|
275
|
-
LinuxStat::Filesystem.available(fs)
|
276
|
-
=> 30714118144
|
277
|
-
|
278
|
-
# File: filesystem.rb | Line: 60
|
279
|
-
# Definition: def free(fs = ?..freeze)
|
280
|
-
LinuxStat::Filesystem.free(fs)
|
281
|
-
=> 30714118144
|
282
|
-
|
283
|
-
# File: filesystem.rb | Line: 21
|
284
|
-
# Definition: def stat(fs = ?..freeze)
|
285
|
-
LinuxStat::Filesystem.stat(fs)
|
286
|
-
=> {:total=>119981191168, :free=>30714118144, :used=>89267073024}
|
287
|
-
|
288
|
-
# File: filesystem.rb | Line: 110
|
289
|
-
# Definition: def stat_raw(fs = ?..freeze)
|
290
|
-
LinuxStat::Filesystem.stat_raw(fs)
|
291
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>7498564, :block_avail_unpriv=>7498564, :inodes=>58612160, :free_inodes=>56765394, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
292
|
-
|
293
|
-
# File: filesystem.rb | Line: 41
|
294
|
-
# Definition: def total(fs = ?..freeze)
|
295
|
-
LinuxStat::Filesystem.total(fs)
|
296
|
-
=> 119981191168
|
297
|
-
|
298
|
-
# File: filesystem.rb | Line: 75
|
299
|
-
# Definition: def used(fs = ?..freeze)
|
300
|
-
LinuxStat::Filesystem.used(fs)
|
301
|
-
=> 89267073024
|
302
|
-
|
303
|
-
```
|
304
103
|
|
305
|
-
|
306
|
-
|
307
|
-
# File: kernel.rb | Line: 88
|
308
|
-
# Definition: def build_date
|
309
|
-
LinuxStat::Kernel.build_date()
|
310
|
-
=> 2020-11-20 07:44:55 +0000
|
311
|
-
|
312
|
-
# File: kernel.rb | Line: 142
|
313
|
-
# Definition: def build_date_string
|
314
|
-
LinuxStat::Kernel.build_date_string()
|
315
|
-
=> "20 Nov 2020 07:44:55 +0000"
|
316
|
-
|
317
|
-
# File: kernel.rb | Line: 23
|
318
|
-
# Definition: def build_user
|
319
|
-
LinuxStat::Kernel.build_user()
|
320
|
-
=> "souravgoswami@archlinux"
|
321
|
-
|
322
|
-
# File: kernel.rb | Line: 181
|
323
|
-
# Definition: def ticks
|
324
|
-
LinuxStat::Kernel.clk_tck()
|
325
|
-
=> 100
|
326
|
-
|
327
|
-
# File: kernel.rb | Line: 35
|
328
|
-
# Definition: def compiler
|
329
|
-
LinuxStat::Kernel.compiler()
|
330
|
-
=> [:gcc, "10.2.0"]
|
331
|
-
|
332
|
-
# File: kernel.rb | Line: 57
|
333
|
-
# Definition: def compiler_version
|
334
|
-
LinuxStat::Kernel.compiler_version()
|
335
|
-
=> "10.2.0"
|
336
|
-
|
337
|
-
# File: kernel.rb | Line: 12
|
338
|
-
# Definition: def version
|
339
|
-
LinuxStat::Kernel.release()
|
340
|
-
=> "5.9.9-xanmod1-1"
|
341
|
-
|
342
|
-
# File: kernel.rb | Line: 171
|
343
|
-
# Definition: def string
|
344
|
-
LinuxStat::Kernel.string()
|
345
|
-
=> "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"
|
346
|
-
|
347
|
-
# File: kernel.rb | Line: 181
|
348
|
-
# Definition: def ticks
|
349
|
-
LinuxStat::Kernel.ticks()
|
350
|
-
=> 100
|
351
|
-
|
352
|
-
# File: kernel.rb | Line: 12
|
353
|
-
# Definition: def version
|
354
|
-
LinuxStat::Kernel.version()
|
355
|
-
=> "5.9.9-xanmod1-1"
|
356
|
-
|
357
|
-
```
|
358
|
-
|
359
|
-
### LinuxStat::Memory
|
360
|
-
```
|
361
|
-
# File: memory.rb | Line: 62
|
362
|
-
# Definition: def available
|
363
|
-
LinuxStat::Memory.available()
|
364
|
-
=> 595616
|
365
|
-
|
366
|
-
# File: memory.rb | Line: 52
|
367
|
-
# Definition: def free
|
368
|
-
LinuxStat::Memory.free()
|
369
|
-
=> 256356
|
370
|
-
|
371
|
-
# File: memory.rb | Line: 93
|
372
|
-
# Definition: def percent_available
|
373
|
-
LinuxStat::Memory.percent_available()
|
374
|
-
=> 15.53
|
375
|
-
|
376
|
-
# File: memory.rb | Line: 82
|
377
|
-
# Definition: def percent_used
|
378
|
-
LinuxStat::Memory.percent_used()
|
379
|
-
=> 84.47
|
380
|
-
|
381
|
-
# File: memory.rb | Line: 13
|
382
|
-
# Definition: def stat
|
383
|
-
LinuxStat::Memory.stat()
|
384
|
-
=> {:total=>3836228, :used=>3240612, :available=>595616, :percent_used=>84.47, :percent_available=>15.53}
|
385
|
-
|
386
|
-
# File: memory.rb | Line: 42
|
387
|
-
# Definition: def total
|
388
|
-
LinuxStat::Memory.total()
|
389
|
-
=> 3836228
|
390
|
-
|
391
|
-
# File: memory.rb | Line: 72
|
392
|
-
# Definition: def used
|
393
|
-
LinuxStat::Memory.used()
|
394
|
-
=> 3240620
|
395
|
-
|
396
|
-
```
|
397
|
-
|
398
|
-
### LinuxStat::Mounts
|
399
|
-
```
|
400
|
-
# File: mounts.rb | Line: 181
|
401
|
-
# Definition: def device_stat(dev = root)
|
402
|
-
LinuxStat::Mounts.device_stat(dev)
|
403
|
-
=> {:mountpoint=>"/", :total=>119981191168, :free=>30714118144, :available=>30714118144, :used=>89267073024, :percent_used=>74.4, :percent_free=>25.6, :percent_available=>25.6}
|
404
|
-
|
405
|
-
# File: mounts.rb | Line: 139
|
406
|
-
# Definition: def devices_stat
|
407
|
-
LinuxStat::Mounts.devices_stat()
|
408
|
-
=> {"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...
|
409
|
-
|
410
|
-
# File: mounts.rb | Line: 13
|
411
|
-
# Definition: def list
|
412
|
-
LinuxStat::Mounts.list()
|
413
|
-
=> ["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=1892888k,nr_inodes=473222,mode=755 0 0", "run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0", "...
|
414
|
-
|
415
|
-
# File: mounts.rb | Line: 22
|
416
|
-
# Definition: def list_devices
|
417
|
-
LinuxStat::Mounts.list_devices()
|
418
|
-
=> ["proc", "sys", "dev", "run", "/dev/sda2", "securityfs", "tmpfs", "devpts", "tmpfs", "cgroup2", "cgroup", "pstore", "none", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "systemd-1", "deb...
|
419
|
-
|
420
|
-
# File: mounts.rb | Line: 111
|
421
|
-
# Definition: def list_devices_mount_point
|
422
|
-
LinuxStat::Mounts.list_devices_mount_point()
|
423
|
-
=> {"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/rdma", "pstore"=>"/s...
|
424
|
-
|
425
|
-
# File: mounts.rb | Line: 82
|
426
|
-
# Definition: def mount_point(dev = root)
|
427
|
-
LinuxStat::Mounts.mount_point(dev)
|
428
|
-
=> "/"
|
429
|
-
|
430
|
-
# File: mounts.rb | Line: 31
|
431
|
-
# Definition: def root
|
432
|
-
LinuxStat::Mounts.root()
|
433
|
-
=> "/dev/sda2"
|
434
|
-
|
435
|
-
# File: mounts.rb | Line: 40
|
436
|
-
# Definition: def root_fs
|
437
|
-
LinuxStat::Mounts.root_fs()
|
438
|
-
=> "xfs"
|
439
|
-
|
440
|
-
# File: mounts.rb | Line: 49
|
441
|
-
# Definition: def root_mount_options
|
442
|
-
LinuxStat::Mounts.root_mount_options()
|
443
|
-
=> "rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota"
|
444
|
-
|
445
|
-
# File: mounts.rb | Line: 58
|
446
|
-
# Definition: def tmpfs
|
447
|
-
LinuxStat::Mounts.tmpfs()
|
448
|
-
=> {"/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", "/ramdisk"=>"tmpfs /ramdisk tmpfs rw,nosuid,nodev,relatime,size=6291456k 0 0", "/tmp...
|
449
|
-
|
450
|
-
```
|
451
|
-
|
452
|
-
### LinuxStat::Net
|
453
|
-
```
|
454
|
-
# File: net.rb | Line: 86
|
455
|
-
# Definition: def usage(interval = 0.1)
|
456
|
-
LinuxStat::Net.current_usage(interval)
|
457
|
-
=> {:received=>0.0, :transmitted=>0.0}
|
458
|
-
|
459
|
-
# File: net.rb | Line: 12
|
460
|
-
# Definition: def ipv4_private
|
461
|
-
LinuxStat::Net.ipv4_private()
|
462
|
-
=> "192.168.0.103"
|
463
|
-
|
464
|
-
# File: net.rb | Line: 27
|
465
|
-
# Definition: def total_bytes
|
466
|
-
LinuxStat::Net.total_bytes()
|
467
|
-
=> {:received=>2371748196, :transmitted=>220748232}
|
468
|
-
|
469
|
-
# File: net.rb | Line: 45
|
470
|
-
# Definition: def total_bytes_received
|
471
|
-
LinuxStat::Net.total_bytes_received()
|
472
|
-
=> 2371748196
|
473
|
-
|
474
|
-
# File: net.rb | Line: 58
|
475
|
-
# Definition: def total_bytes_transmitted
|
476
|
-
LinuxStat::Net.total_bytes_transmitted()
|
477
|
-
=> 220748232
|
478
|
-
|
479
|
-
# File: net.rb | Line: 86
|
480
|
-
# Definition: def usage(interval = 0.1)
|
481
|
-
LinuxStat::Net.usage(interval)
|
482
|
-
=> {:received=>820.0, :transmitted=>0.0}
|
483
|
-
|
484
|
-
```
|
485
|
-
|
486
|
-
### LinuxStat::OS
|
487
|
-
```
|
488
|
-
# File: os.rb | Line: 133
|
489
|
-
# Definition: def bits
|
490
|
-
LinuxStat::OS.bits()
|
491
|
-
=> 64
|
492
|
-
|
493
|
-
# File: os.rb | Line: 88
|
494
|
-
# Definition: def version
|
495
|
-
LinuxStat::OS.distrib_version()
|
496
|
-
=> "rolling"
|
497
|
-
|
498
|
-
# File: os.rb | Line: 50
|
499
|
-
# Definition: def distribution
|
500
|
-
LinuxStat::OS.distribution()
|
501
|
-
=> "Arch Linux"
|
502
|
-
|
503
|
-
# File: os.rb | Line: 121
|
504
|
-
# Definition: def hostname
|
505
|
-
LinuxStat::OS.hostname()
|
506
|
-
=> "archlinux"
|
507
|
-
|
508
|
-
# File: os.rb | Line: 208
|
509
|
-
# Definition: def loadavg
|
510
|
-
LinuxStat::OS.loadavg()
|
511
|
-
=> {1=>2.873046875, 5=>1.9189453125, 15=>1.396484375}
|
512
|
-
|
513
|
-
# File: os.rb | Line: 39
|
514
|
-
# Definition: def lsb_release
|
515
|
-
LinuxStat::OS.lsb_release()
|
516
|
-
=> {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
|
517
|
-
|
518
|
-
# File: os.rb | Line: 104
|
519
|
-
# Definition: def machine
|
520
|
-
LinuxStat::OS.machine()
|
521
|
-
=> "x86_64"
|
522
|
-
|
523
|
-
# File: os.rb | Line: 112
|
524
|
-
# Definition: def nodename
|
525
|
-
LinuxStat::OS.nodename()
|
526
|
-
=> "archlinux"
|
527
|
-
|
528
|
-
# File: os.rb | Line: 23
|
529
|
-
# Definition: def os_release
|
530
|
-
LinuxStat::OS.os_release()
|
531
|
-
=> {: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/"...
|
532
|
-
|
533
|
-
# File: os.rb | Line: 150
|
534
|
-
# Definition: def uptime
|
535
|
-
LinuxStat::OS.uptime()
|
536
|
-
=> {:hour=>16, :minute=>16, :second=>1, :jiffy=>430}
|
537
|
-
|
538
|
-
# File: os.rb | Line: 180
|
539
|
-
# Definition: def uptime_f
|
540
|
-
LinuxStat::OS.uptime_f()
|
541
|
-
=> 58561.43
|
542
|
-
|
543
|
-
# File: os.rb | Line: 191
|
544
|
-
# Definition: def uptime_i
|
545
|
-
LinuxStat::OS.uptime_i()
|
546
|
-
=> 58562
|
547
|
-
|
548
|
-
# File: os.rb | Line: 88
|
549
|
-
# Definition: def version
|
550
|
-
LinuxStat::OS.version()
|
551
|
-
=> "rolling"
|
552
|
-
|
553
|
-
```
|
554
|
-
|
555
|
-
### LinuxStat::PCI
|
556
|
-
```
|
557
|
-
# File: pci.rb | Line: 216
|
558
|
-
# Definition: def count
|
559
|
-
LinuxStat::PCI.count()
|
560
|
-
=> 13
|
561
|
-
|
562
|
-
# File: pci.rb | Line: 216
|
563
|
-
# Definition: def count
|
564
|
-
LinuxStat::PCI.count_devices()
|
565
|
-
=> 13
|
566
|
-
|
567
|
-
# File: pci.rb | Line: 54
|
568
|
-
# Definition: def devices_info(hwdata: true)
|
569
|
-
LinuxStat::PCI.devices_info(hwdata:)
|
570
|
-
=> [{:id=>"8086:1904", :vendor=>"8086", :device=>"1904", :irq=>0, :kernel_driver=>"skl_uncore", :hwdata=>{:vendor=>"Intel Corporation", :product=>"Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Host Bridge/DRAM Registers"}}, {:id=>"8086:1916", :vendor...
|
571
|
-
|
572
|
-
# File: pci.rb | Line: 130
|
573
|
-
# Definition: def devices_stat(hwdata: true)
|
574
|
-
LinuxStat::PCI.devices_stat(hwdata:)
|
575
|
-
=> [{:path=>"/sys/bus/pci/devices/0000:00:00.0/", :id=>"8086:1904", :vendor=>"8086", :device=>"1904", :sub_vendor=>"1028", :sub_device=>"077d", :kernel_driver=>"skl_uncore", :revision=>"0x08", :irq=>0, :enable=>false, :hwdata=>{:vendor=>"Intel Corporatio...
|
576
|
-
|
577
|
-
# File: pci.rb | Line: 264
|
578
|
-
# Definition: def hwdata_file
|
579
|
-
LinuxStat::PCI.hwdata_file()
|
580
|
-
=> "/usr/share/hwdata/pci.ids"
|
581
|
-
|
582
|
-
# File: pci.rb | Line: 253
|
583
|
-
# Definition: def hwdata_file_set?
|
584
|
-
LinuxStat::PCI.hwdata_file_set?()
|
585
|
-
=> true
|
586
|
-
|
587
|
-
# File: pci.rb | Line: 280
|
588
|
-
# Definition: def initialize_hwdata
|
589
|
-
LinuxStat::PCI.initialize_hwdata()
|
590
|
-
=> false
|
591
|
-
|
592
|
-
```
|
593
|
-
|
594
|
-
### LinuxStat::PrettifyBytes
|
595
|
-
```
|
596
|
-
# File: prettify_bytes.rb | Line: 49
|
597
|
-
# Definition: def convert_binary(n, precision: 2)
|
598
|
-
LinuxStat::PrettifyBytes.convert_binary(n = 55206562261629, precision:)
|
599
|
-
=> "50.21 tebibytes"
|
600
|
-
|
601
|
-
# File: prettify_bytes.rb | Line: 26
|
602
|
-
# Definition: def convert_decimal(n, precision: 2)
|
603
|
-
LinuxStat::PrettifyBytes.convert_decimal(n = 341141363483637, precision:)
|
604
|
-
=> "341.14 terabytes"
|
605
|
-
|
606
|
-
# File: prettify_bytes.rb | Line: 97
|
607
|
-
# Definition: def convert_short_binary(n, precision: 2)
|
608
|
-
LinuxStat::PrettifyBytes.convert_short_binary(n = 175331196815015, precision:)
|
609
|
-
=> "159.46 TiB"
|
610
|
-
|
611
|
-
# File: prettify_bytes.rb | Line: 72
|
612
|
-
# Definition: def convert_short_decimal(n, precision: 2)
|
613
|
-
LinuxStat::PrettifyBytes.convert_short_decimal(n = 789625492086030, precision:)
|
614
|
-
=> "789.63 TB"
|
615
|
-
|
616
|
-
```
|
617
|
-
|
618
|
-
### LinuxStat::ProcFS
|
619
|
-
```
|
620
|
-
LinuxStat::ProcFS.last_pid()
|
621
|
-
=> 52438
|
622
|
-
|
623
|
-
LinuxStat::ProcFS.uptime_f()
|
624
|
-
=> 58561.65
|
625
|
-
|
626
|
-
```
|
627
|
-
|
628
|
-
### LinuxStat::Process
|
629
|
-
```
|
630
|
-
# File: process.rb | Line: 57
|
631
|
-
# Definition: def cmdlines
|
632
|
-
LinuxStat::Process.cmdlines()
|
633
|
-
=> {1=>"/usr/lib/systemd/systemd --system --deserialize 63", 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=>""...
|
634
|
-
|
635
|
-
# File: process.rb | Line: 29
|
636
|
-
# Definition: def count
|
637
|
-
LinuxStat::Process.count()
|
638
|
-
=> 212
|
639
|
-
|
640
|
-
# File: process.rb | Line: 120
|
641
|
-
# Definition: def idle
|
642
|
-
LinuxStat::Process.idle()
|
643
|
-
=> [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, 165, 168, 170, 171, 175, 180, 181, 182, 183, 184, 185, 186, 187, 189, 231, 234, 275, 447, 502, 21751, 23896, 41972, 41973, 41974, 41975, 41...
|
644
|
-
|
645
|
-
# File: process.rb | Line: 160
|
646
|
-
# Definition: def last_pid
|
647
|
-
LinuxStat::Process.last_pid()
|
648
|
-
=> 52438
|
649
|
-
|
650
|
-
# File: process.rb | Line: 11
|
651
|
-
# Definition: def list
|
652
|
-
LinuxStat::Process.list()
|
653
|
-
=> [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,...
|
654
|
-
|
655
|
-
# File: process.rb | Line: 36
|
656
|
-
# Definition: def names
|
657
|
-
LinuxStat::Process.names()
|
658
|
-
=> {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...
|
659
|
-
|
660
|
-
# File: process.rb | Line: 138
|
661
|
-
# Definition: def running
|
662
|
-
LinuxStat::Process.running()
|
663
|
-
=> [52438]
|
664
|
-
|
665
|
-
# File: process.rb | Line: 111
|
666
|
-
# Definition: def sleeping
|
667
|
-
LinuxStat::Process.sleeping()
|
668
|
-
=> [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, 164, 167, 188, 218, 233, 235, 308, 311, 362, 364, 365, 378, 379, 380, 381, 395, 398, 401, 465, 520, 522,...
|
669
|
-
|
670
|
-
# File: process.rb | Line: 147
|
671
|
-
# Definition: def stopped
|
672
|
-
LinuxStat::Process.stopped()
|
673
|
-
=> []
|
674
|
-
|
675
|
-
# File: process.rb | Line: 78
|
676
|
-
# Definition: def types
|
677
|
-
LinuxStat::Process.types()
|
678
|
-
=> {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...
|
679
|
-
|
680
|
-
# File: process.rb | Line: 129
|
681
|
-
# Definition: def zombie
|
682
|
-
LinuxStat::Process.zombie()
|
683
|
-
=> []
|
684
|
-
|
685
|
-
```
|
686
|
-
|
687
|
-
### LinuxStat::ProcessInfo
|
688
|
-
```
|
689
|
-
# File: process_info.rb | Line: 61
|
690
|
-
# Definition: def cmdline(pid = $$)
|
691
|
-
LinuxStat::ProcessInfo.cmdline(pid)
|
692
|
-
=> "/usr/bin/ruby /home/sourav/.gem/ruby/2.7.0/bin/linuxstat.rb --markdown"
|
693
|
-
|
694
|
-
# File: process_info.rb | Line: 87
|
695
|
-
# Definition: def command_name(pid = $$)
|
696
|
-
LinuxStat::ProcessInfo.command_name(pid)
|
697
|
-
=> "ruby"
|
698
|
-
|
699
|
-
# File: process_info.rb | Line: 608
|
700
|
-
# Definition: def nproc(pid = $$)
|
701
|
-
LinuxStat::ProcessInfo.count_cpu(pid)
|
702
|
-
=> 4
|
104
|
+
Following are the LinuxStat modules and module functions in a table.
|
105
|
+
Usages.md is generated by `linuxstat.rb -md` command, which is available after the installation.
|
703
106
|
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
#
|
711
|
-
LinuxStat::
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
#
|
716
|
-
LinuxStat::
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
#
|
721
|
-
LinuxStat::
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
#
|
726
|
-
LinuxStat::
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
#
|
731
|
-
LinuxStat::ProcessInfo.last_executed_cpu(pid)
|
732
|
-
=> 3
|
733
|
-
|
734
|
-
# File: process_info.rb | Line: 151
|
735
|
-
# Definition: def mem_stat(pid = $$)
|
736
|
-
LinuxStat::ProcessInfo.mem_stat(pid)
|
737
|
-
=> {:memory=>24735744, :virtual_memory=>96317440, :resident_memory=>30707712, :shared_memory=>5971968}
|
738
|
-
|
739
|
-
# File: process_info.rb | Line: 171
|
740
|
-
# Definition: def memory(pid = $$)
|
741
|
-
LinuxStat::ProcessInfo.memory(pid)
|
742
|
-
=> 24735.744
|
743
|
-
|
744
|
-
# File: process_info.rb | Line: 578
|
745
|
-
# Definition: def nice(pid = $$)
|
746
|
-
LinuxStat::ProcessInfo.nice(pid)
|
747
|
-
=> 0
|
748
|
-
|
749
|
-
# File: process_info.rb | Line: 608
|
750
|
-
# Definition: def nproc(pid = $$)
|
751
|
-
LinuxStat::ProcessInfo.nproc(pid)
|
752
|
-
=> 4
|
753
|
-
|
754
|
-
# File: process_info.rb | Line: 471
|
755
|
-
# Definition: def owner(pid = $$)
|
756
|
-
LinuxStat::ProcessInfo.owner(pid)
|
757
|
-
=> "sourav"
|
758
|
-
|
759
|
-
# File: process_info.rb | Line: 112
|
760
|
-
# Definition: def process_name(pid = $$)
|
761
|
-
LinuxStat::ProcessInfo.process_name(pid)
|
762
|
-
=> "linuxstat.rb"
|
763
|
-
|
764
|
-
# File: process_info.rb | Line: 213
|
765
|
-
# Definition: def resident_memory(pid = $$)
|
766
|
-
LinuxStat::ProcessInfo.resident_memory(pid)
|
767
|
-
=> 30707.712
|
768
|
-
|
769
|
-
# File: process_info.rb | Line: 540
|
770
|
-
# Definition: def running_time(pid = $$)
|
771
|
-
LinuxStat::ProcessInfo.running_time(pid)
|
772
|
-
=> 1.03
|
773
|
-
|
774
|
-
# File: process_info.rb | Line: 234
|
775
|
-
# Definition: def shared_memory(pid = $$)
|
776
|
-
LinuxStat::ProcessInfo.shared_memory(pid)
|
777
|
-
=> 5971.968
|
778
|
-
|
779
|
-
# File: process_info.rb | Line: 521
|
780
|
-
# Definition: def start_time(pid = $$)
|
781
|
-
LinuxStat::ProcessInfo.start_time(pid)
|
782
|
-
=> 2021-02-07 03:30:35 +0530
|
783
|
-
|
784
|
-
# File: process_info.rb | Line: 493
|
785
|
-
# Definition: def start_time_epoch(pid = $$)
|
786
|
-
LinuxStat::ProcessInfo.start_time_epoch(pid)
|
787
|
-
=> 1612648835
|
788
|
-
|
789
|
-
# File: process_info.rb | Line: 565
|
790
|
-
# Definition: def state(pid = $$)
|
791
|
-
LinuxStat::ProcessInfo.state(pid)
|
792
|
-
=> "R"
|
793
|
-
|
794
|
-
# File: process_info.rb | Line: 370
|
795
|
-
# Definition: def thread_usage(pid: $$, sleep: ticks_to_ms_t5)
|
796
|
-
LinuxStat::ProcessInfo.thread_usage(pid:, sleep:)
|
797
|
-
=> 0.0
|
798
|
-
|
799
|
-
# File: process_info.rb | Line: 395
|
800
|
-
# Definition: def threads(pid = $$)
|
801
|
-
LinuxStat::ProcessInfo.threads(pid)
|
802
|
-
=> 1
|
803
|
-
|
804
|
-
# File: process_info.rb | Line: 30
|
805
|
-
# Definition: def total_io(pid = $$)
|
806
|
-
LinuxStat::ProcessInfo.total_io(pid)
|
807
|
-
=> {:read_bytes=>1286144, :write_bytes=>0}
|
808
|
-
|
809
|
-
# File: process_info.rb | Line: 426
|
810
|
-
# Definition: def uid(pid = $$)
|
811
|
-
LinuxStat::ProcessInfo.uid(pid)
|
812
|
-
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
813
|
-
|
814
|
-
# File: process_info.rb | Line: 192
|
815
|
-
# Definition: def virtual_memory(pid = $$)
|
816
|
-
LinuxStat::ProcessInfo.virtual_memory(pid)
|
817
|
-
=> 96317.44
|
818
|
-
|
819
|
-
```
|
820
|
-
|
821
|
-
### LinuxStat::Swap
|
822
|
-
```
|
823
|
-
# File: swap.rb | Line: 24
|
824
|
-
# Definition: def any?
|
825
|
-
LinuxStat::Swap.any?()
|
826
|
-
=> true
|
827
|
-
|
828
|
-
# File: swap.rb | Line: 84
|
829
|
-
# Definition: def available
|
830
|
-
LinuxStat::Swap.available()
|
831
|
-
=> 2328956
|
832
|
-
|
833
|
-
# File: swap.rb | Line: 73
|
834
|
-
# Definition: def free
|
835
|
-
LinuxStat::Swap.free()
|
836
|
-
=> 2328956
|
837
|
-
|
838
|
-
# File: swap.rb | Line: 10
|
839
|
-
# Definition: def list
|
840
|
-
LinuxStat::Swap.list()
|
841
|
-
=> {"/dev/zram0"=>[:partition, 4194300, 1865344, -2]}
|
842
|
-
|
843
|
-
# File: swap.rb | Line: 127
|
844
|
-
# Definition: def percent_available
|
845
|
-
LinuxStat::Swap.percent_available()
|
846
|
-
=> 55.53
|
847
|
-
|
848
|
-
# File: swap.rb | Line: 107
|
849
|
-
# Definition: def percent_used
|
850
|
-
LinuxStat::Swap.percent_used()
|
851
|
-
=> 44.47
|
852
|
-
|
853
|
-
# File: swap.rb | Line: 34
|
854
|
-
# Definition: def stat
|
855
|
-
LinuxStat::Swap.stat()
|
856
|
-
=> {:total=>4194300, :used=>1865344, :available=>2328956, :percent_used=>44.47, :percent_available=>55.53}
|
857
|
-
|
858
|
-
# File: swap.rb | Line: 62
|
859
|
-
# Definition: def total
|
860
|
-
LinuxStat::Swap.total()
|
861
|
-
=> 4194300
|
862
|
-
|
863
|
-
# File: swap.rb | Line: 98
|
864
|
-
# Definition: def used
|
865
|
-
LinuxStat::Swap.used()
|
866
|
-
=> 1865344
|
867
|
-
|
868
|
-
```
|
869
|
-
|
870
|
-
### LinuxStat::Sysconf
|
871
|
-
```
|
872
|
-
LinuxStat::Sysconf.child_max()
|
873
|
-
=> 14788
|
874
|
-
|
875
|
-
LinuxStat::Sysconf.expr_nest_max()
|
876
|
-
=> 32
|
877
|
-
|
878
|
-
LinuxStat::Sysconf.get_euid()
|
879
|
-
=> 1000
|
880
|
-
|
881
|
-
LinuxStat::Sysconf.get_gid()
|
882
|
-
=> 1000
|
883
|
-
|
884
|
-
LinuxStat::Sysconf.get_login()
|
885
|
-
=> "sourav"
|
886
|
-
|
887
|
-
LinuxStat::Sysconf.get_uid()
|
888
|
-
=> 1000
|
889
|
-
|
890
|
-
LinuxStat::Sysconf.get_user()
|
891
|
-
=> "sourav"
|
892
|
-
|
893
|
-
LinuxStat::Sysconf.hostname()
|
894
|
-
=> "archlinux"
|
895
|
-
|
896
|
-
LinuxStat::Sysconf.hostname_max()
|
897
|
-
=> 64
|
898
|
-
|
899
|
-
LinuxStat::Sysconf.line_max()
|
900
|
-
=> 2048
|
901
|
-
|
902
|
-
LinuxStat::Sysconf.login_name_max()
|
903
|
-
=> 256
|
904
|
-
|
905
|
-
LinuxStat::Sysconf.open_max()
|
906
|
-
=> 1024
|
907
|
-
|
908
|
-
LinuxStat::Sysconf.pagesize()
|
909
|
-
=> 4096
|
910
|
-
|
911
|
-
LinuxStat::Sysconf.posix_version()
|
912
|
-
=> 200809
|
913
|
-
|
914
|
-
LinuxStat::Sysconf.processor_configured()
|
915
|
-
=> 4
|
916
|
-
|
917
|
-
LinuxStat::Sysconf.processor_online()
|
918
|
-
=> 4
|
919
|
-
|
920
|
-
LinuxStat::Sysconf.sc_clk_tck()
|
921
|
-
=> 100
|
922
|
-
|
923
|
-
LinuxStat::Sysconf.stream_max()
|
924
|
-
=> 16
|
925
|
-
|
926
|
-
LinuxStat::Sysconf.tty_name_max()
|
927
|
-
=> 32
|
928
|
-
|
929
|
-
```
|
930
|
-
|
931
|
-
### LinuxStat::Sysinfo
|
932
|
-
```
|
933
|
-
LinuxStat::Sysinfo.bufferram()
|
934
|
-
=> 4096
|
935
|
-
|
936
|
-
LinuxStat::Sysinfo.freehigh()
|
937
|
-
=> 0
|
938
|
-
|
939
|
-
LinuxStat::Sysinfo.freeram()
|
940
|
-
=> 258519040
|
941
|
-
|
942
|
-
LinuxStat::Sysinfo.freeswap()
|
943
|
-
=> 2384850944
|
944
|
-
|
945
|
-
LinuxStat::Sysinfo.loads()
|
946
|
-
=> [2.873046875, 1.9189453125, 1.396484375]
|
947
|
-
|
948
|
-
LinuxStat::Sysinfo.sharedram()
|
949
|
-
=> 644231168
|
950
|
-
|
951
|
-
LinuxStat::Sysinfo.stat()
|
952
|
-
=> {:totalram=>3928297472, :freeram=>258519040, :sharedram=>644231168, :bufferram=>4096, :totalswap=>4294963200, :freeswap=>2384850944, :totalhigh=>0, :freehigh=>0, :uptime=>58562, :loads=>[2.873046875, 1.9189453125, 1.396484375]}
|
953
|
-
|
954
|
-
LinuxStat::Sysinfo.totalhigh()
|
955
|
-
=> 0
|
956
|
-
|
957
|
-
LinuxStat::Sysinfo.totalram()
|
958
|
-
=> 3928297472
|
959
|
-
|
960
|
-
LinuxStat::Sysinfo.totalswap()
|
961
|
-
=> 4294963200
|
962
|
-
|
963
|
-
LinuxStat::Sysinfo.uptime()
|
964
|
-
=> 58562
|
965
|
-
|
966
|
-
```
|
967
|
-
|
968
|
-
### LinuxStat::Thermal
|
969
|
-
```
|
970
|
-
# File: thermal.rb | Line: 59
|
971
|
-
# Definition: def count_fans
|
972
|
-
LinuxStat::Thermal.count_fans()
|
973
|
-
=> 1
|
974
|
-
|
975
|
-
# File: thermal.rb | Line: 49
|
976
|
-
# Definition: def count_sensors
|
977
|
-
LinuxStat::Thermal.count_sensors()
|
978
|
-
=> 8
|
979
|
-
|
980
|
-
# File: thermal.rb | Line: 41
|
981
|
-
# Definition: def fans
|
982
|
-
LinuxStat::Thermal.fans()
|
983
|
-
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Processor Fan", :rpm=>2795}]
|
984
|
-
|
985
|
-
# File: thermal.rb | Line: 23
|
986
|
-
# Definition: def temperatures
|
987
|
-
LinuxStat::Thermal.temperatures()
|
988
|
-
=> [{:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"SODIMM", :temperature=>33.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"CPU", :temperature=>41.0}, {:path=>"/sys/class/hwmon/hwmon4", :name=>"dell_smm", :label=>"Ambi...
|
989
|
-
|
990
|
-
```
|
991
|
-
|
992
|
-
### LinuxStat::USB
|
993
|
-
```
|
994
|
-
# File: usb.rb | Line: 139
|
995
|
-
# Definition: def count
|
996
|
-
LinuxStat::USB.count()
|
997
|
-
=> 11
|
998
|
-
|
999
|
-
# File: usb.rb | Line: 139
|
1000
|
-
# Definition: def count
|
1001
|
-
LinuxStat::USB.count_devices()
|
1002
|
-
=> 11
|
1003
|
-
|
1004
|
-
# File: usb.rb | Line: 49
|
1005
|
-
# Definition: def devices_stat(hwdata: true)
|
1006
|
-
LinuxStat::USB.devices_stat(hwdata:)
|
1007
|
-
=> [{:path=>"/sys/bus/usb/devices/1-1.2/", :id=>"04d9:1203", :vendor_id=>"04d9", :product_id=>"1203", :bus_num=>1, :dev_num=>12, :hwdata=>{:vendor=>"Holtek Semiconductor, Inc.", :product=>"Keyboard"}, :authorized=>true, :b_max_power=>"100mA", :b_max_pack...
|
1008
|
-
|
1009
|
-
# File: usb.rb | Line: 179
|
1010
|
-
# Definition: def hwdata_file
|
1011
|
-
LinuxStat::USB.hwdata_file()
|
1012
|
-
=> "/usr/share/hwdata/usb.ids"
|
1013
|
-
|
1014
|
-
# File: usb.rb | Line: 168
|
1015
|
-
# Definition: def hwdata_file_set?
|
1016
|
-
LinuxStat::USB.hwdata_file_set?()
|
1017
|
-
=> true
|
1018
|
-
|
1019
|
-
# File: usb.rb | Line: 195
|
1020
|
-
# Definition: def initialize_hwdata
|
1021
|
-
LinuxStat::USB.initialize_hwdata()
|
1022
|
-
=> false
|
1023
|
-
|
1024
|
-
```
|
1025
|
-
|
1026
|
-
### LinuxStat::Uname
|
1027
|
-
```
|
1028
|
-
LinuxStat::Uname.machine()
|
1029
|
-
=> "x86_64"
|
1030
|
-
|
1031
|
-
LinuxStat::Uname.nodename()
|
1032
|
-
=> "archlinux"
|
1033
|
-
|
1034
|
-
LinuxStat::Uname.release()
|
1035
|
-
=> "5.9.9-xanmod1-1"
|
1036
|
-
|
1037
|
-
LinuxStat::Uname.sysname()
|
1038
|
-
=> "Linux"
|
1039
|
-
|
1040
|
-
LinuxStat::Uname.version()
|
1041
|
-
=> "#1 SMP PREEMPT Fri, 20 Nov 2020 07:44:55 +0000"
|
1042
|
-
|
1043
|
-
```
|
1044
|
-
|
1045
|
-
### LinuxStat::User
|
1046
|
-
```
|
1047
|
-
# File: user.rb | Line: 101
|
1048
|
-
# Definition: def get_user
|
1049
|
-
LinuxStat::User.get_current_user()
|
1050
|
-
=> "sourav"
|
1051
|
-
|
1052
|
-
# File: user.rb | Line: 140
|
1053
|
-
# Definition: def get_euid
|
1054
|
-
LinuxStat::User.get_euid()
|
1055
|
-
=> 1000
|
1056
|
-
|
1057
|
-
# File: user.rb | Line: 132
|
1058
|
-
# Definition: def get_gid
|
1059
|
-
LinuxStat::User.get_gid()
|
1060
|
-
=> 1000
|
1061
|
-
|
1062
|
-
# File: user.rb | Line: 155
|
1063
|
-
# Definition: def get_login
|
1064
|
-
LinuxStat::User.get_login()
|
1065
|
-
=> "sourav"
|
1066
|
-
|
1067
|
-
# File: user.rb | Line: 124
|
1068
|
-
# Definition: def get_uid
|
1069
|
-
LinuxStat::User.get_uid()
|
1070
|
-
=> 1000
|
1071
|
-
|
1072
|
-
# File: user.rb | Line: 101
|
1073
|
-
# Definition: def get_user
|
1074
|
-
LinuxStat::User.get_user()
|
1075
|
-
=> "sourav"
|
1076
|
-
|
1077
|
-
# File: user.rb | Line: 218
|
1078
|
-
# Definition: def gid_by_username(username = get_user)
|
1079
|
-
LinuxStat::User.gid_by_username(username)
|
1080
|
-
=> 1000
|
1081
|
-
|
1082
|
-
# File: user.rb | Line: 58
|
1083
|
-
# Definition: def gids
|
1084
|
-
LinuxStat::User.gids()
|
1085
|
-
=> {: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, :...
|
1086
|
-
|
1087
|
-
# File: user.rb | Line: 317
|
1088
|
-
# Definition: def home_by_gid(id = get_gid)
|
1089
|
-
LinuxStat::User.home_by_gid(id)
|
1090
|
-
=> "/home/sourav"
|
1091
|
-
|
1092
|
-
# File: user.rb | Line: 269
|
1093
|
-
# Definition: def home_by_username(user = get_user)
|
1094
|
-
LinuxStat::User.home_by_username(user)
|
1095
|
-
=> "/home/sourav"
|
1096
|
-
|
1097
|
-
# File: user.rb | Line: 75
|
1098
|
-
# Definition: def home_directories
|
1099
|
-
LinuxStat::User.home_directories()
|
1100
|
-
=> {: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...
|
1101
|
-
|
1102
|
-
# File: user.rb | Line: 296
|
1103
|
-
# Definition: def homes_by_uid(id = get_uid)
|
1104
|
-
LinuxStat::User.homes_by_uid(id)
|
1105
|
-
=> ["/home/sourav"]
|
1106
|
-
|
1107
|
-
# File: user.rb | Line: 25
|
1108
|
-
# Definition: def ids
|
1109
|
-
LinuxStat::User.ids()
|
1110
|
-
=> {: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...
|
1111
|
-
|
1112
|
-
# File: user.rb | Line: 13
|
1113
|
-
# Definition: def list
|
1114
|
-
LinuxStat::User.list()
|
1115
|
-
=> ["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...
|
1116
|
-
|
1117
|
-
# File: user.rb | Line: 247
|
1118
|
-
# Definition: def uid_by_username(username = get_user)
|
1119
|
-
LinuxStat::User.uid_by_username(username)
|
1120
|
-
=> 1000
|
1121
|
-
|
1122
|
-
# File: user.rb | Line: 42
|
1123
|
-
# Definition: def uids
|
1124
|
-
LinuxStat::User.uids()
|
1125
|
-
=> {: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...
|
1126
|
-
|
1127
|
-
# File: user.rb | Line: 190
|
1128
|
-
# Definition: def username_by_gid(gid = get_gid)
|
1129
|
-
LinuxStat::User.username_by_gid(gid)
|
1130
|
-
=> "sourav"
|
1131
|
-
|
1132
|
-
# File: user.rb | Line: 172
|
1133
|
-
# Definition: def usernames_by_uid(uid = get_uid)
|
1134
|
-
LinuxStat::User.usernames_by_uid(uid)
|
1135
|
-
=> ["sourav"]
|
1136
|
-
|
1137
|
-
```
|
107
|
+
For ease of use, LinuxStat is also assigned to the LS constant.
|
108
|
+
So LinuxStat::USB can be replaced with LS::USB for example.
|
109
|
+
|
110
|
+
| LinuxStat Module | Description |
|
111
|
+
|:---|:---|
|
112
|
+
| [LinuxStat::BIOS](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatbios) | System's BIOS related informaion |
|
113
|
+
| [LinuxStat::Battery](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatbattery) | System's first Battery realted information |
|
114
|
+
| [LinuxStat::CPU](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatcpu) | System's CPU usage and other related information |
|
115
|
+
| [LinuxStat::FS](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatfs) | System's file system related information. It's used by Filesystem module. |
|
116
|
+
| [LinuxStat::Filesystem](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatfilesystem) | System's file system usage and other related information |
|
117
|
+
| [LinuxStat::Kernel](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatkernel) | System's kernel related information |
|
118
|
+
| [LinuxStat::Memory](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatmemory) | System's memory (RAM) usage and other related information |
|
119
|
+
| [LinuxStat::Mounts](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatmounts) | System's mount point related information |
|
120
|
+
| [LinuxStat::Net](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatnet) | System's internet usage and other information |
|
121
|
+
| [LinuxStat::OS](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatos) | System's OS related information and parse release files |
|
122
|
+
| [LinuxStat::PCI](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatpci) | System's PCI device related information (optional parsing of hwdata) |
|
123
|
+
| [LinuxStat::PrettifyBytes](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatprettifybytes) | Convert bytes into human readable format (kB, kiB, etc.) |
|
124
|
+
| [LinuxStat::ProcFS](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatprocfs) | Read proc file system in C for faster access. Used accross |
|
125
|
+
| [LinuxStat::Process](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatprocess) | System's processes and related information |
|
126
|
+
| [LinuxStat::ProcessInfo](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatprocessinfo) | System's single process CPU, memory usages, CPU time, etc. info |
|
127
|
+
| [LinuxStat::Swap](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatswap) | System's swap related information |
|
128
|
+
| [LinuxStat::Sysconf](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatsysconf) | Used by other LinuxStat modules, provides various system details like pagesize, max children, open files, etc |
|
129
|
+
| [LinuxStat::Sysinfo](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatsysinfo) | Used by other LinuxStat modules, faster access to information like totalram, freeram, totalhigh, load average, etc. |
|
130
|
+
| [LinuxStat::Thermal](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatthermal) | System's thermal status, fan related info, sensor count, fan count, etc. |
|
131
|
+
| [LinuxStat::USB](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatusb) | System's USB device related information and other counts (optional parsing of hwdata) |
|
132
|
+
| [LinuxStat::Uname](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatuname) | Used by other LinuxStat modules, System's Uname information in C, that's also provided by the `uname` command. |
|
133
|
+
| [LinuxStat::User](https://github.com/Souravgoswami/linux_stat/blob/master/Usages.md#linuxstatuser) | Systems' various user related information, provides current user name, home directory, etc. |
|
1138
134
|
|
1139
135
|
---
|
1140
136
|
|
137
|
+
# Notes
|
138
|
+
|
1141
139
|
## Note 1: CPU usage, and Net usage
|
1142
140
|
To calculate the current usage, we need to get two usages at a given interval, and subtract the 2nd from the 1st.
|
1143
141
|
For example, if the current download (`LinuxStat::Net.total_bytes_received`) is 1000 bytes, and if 0.1 seconds ago, it was 100 bytes, that means 900 bytes was received in 0.1 seconds.
|
@@ -1770,3 +768,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Sourav
|
|
1770
768
|
## License
|
1771
769
|
|
1772
770
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
771
|
+
|
772
|
+
## Languages
|
773
|
+
|
774
|
+
<img src="https://linuxstatloc.herokuapp.com/svg" width="260px">
|
data/exe/linuxstat.rb
CHANGED
@@ -150,9 +150,9 @@ execute.sort.each do |c|
|
|
150
150
|
disp_meth = "#{meth}"
|
151
151
|
disp_meth.concat(arg ? "(#{param})" : "(#{param})")
|
152
152
|
|
153
|
-
time =
|
153
|
+
time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
154
154
|
ret = arg ? e.send(meth, arg) : e.send(meth)
|
155
|
-
time2 =
|
155
|
+
time2 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
156
156
|
time = time2.-(time).*(1_000_000).round(3)
|
157
157
|
|
158
158
|
v = ret.inspect
|
data/lib/linux_stat/battery.rb
CHANGED
@@ -105,11 +105,19 @@ module LinuxStat
|
|
105
105
|
#
|
106
106
|
# If the battery is not present or the information is not available, it will return nil.
|
107
107
|
def charge
|
108
|
-
@@charge_now_file ||= File.join(PATH, 'charge_now')
|
109
|
-
|
108
|
+
@@charge_now_file ||= if File.readable?(File.join(PATH, 'charge_now'))
|
109
|
+
File.join(PATH, 'charge_now').freeze
|
110
|
+
elsif File.readable?(File.join(PATH, 'energy_now'))
|
111
|
+
File.join(PATH, 'energy_now').freeze
|
112
|
+
end
|
113
|
+
|
114
|
+
@@charge_full_file ||= if File.readable?(File.join(PATH, 'charge_full'))
|
115
|
+
File.join(PATH, 'charge_full').freeze
|
116
|
+
elsif File.readable?(File.join(PATH, 'energy_full'))
|
117
|
+
File.join(PATH, 'energy_full').freeze
|
118
|
+
end
|
110
119
|
|
111
|
-
|
112
|
-
return nil unless @@charge_now_readable
|
120
|
+
return nil unless @@charge_now_file && @@charge_full_file
|
113
121
|
|
114
122
|
charge_now = IO.read(@@charge_now_file).to_i
|
115
123
|
charge_full = IO.read(@@charge_full_file).to_i
|
@@ -215,7 +223,16 @@ module LinuxStat
|
|
215
223
|
|
216
224
|
# charge now
|
217
225
|
cn_f = File.join(x, 'charge_now'.freeze).freeze
|
218
|
-
charge_now = File.readable?(cn_f)
|
226
|
+
charge_now = if File.readable?(cn_f)
|
227
|
+
IO.read(cn_f).to_i.fdiv(1_000_000)
|
228
|
+
else
|
229
|
+
en_f = File.join(x, 'energy_now'.freeze)
|
230
|
+
if File.readable?(en_f)
|
231
|
+
IO.read(en_f) .to_i.fdiv(1_000_000)
|
232
|
+
else
|
233
|
+
nil
|
234
|
+
end
|
235
|
+
end
|
219
236
|
|
220
237
|
# voltage min design
|
221
238
|
vmd_f = File.join(x, 'voltage_min_design'.freeze).freeze
|
@@ -227,7 +244,16 @@ module LinuxStat
|
|
227
244
|
|
228
245
|
# charge full
|
229
246
|
cf_f = File.join(x, 'charge_full'.freeze).freeze
|
230
|
-
charge_full = File.readable?(cf_f)
|
247
|
+
charge_full = if File.readable?(cf_f)
|
248
|
+
IO.read(cf_f).to_i.fdiv(1_000_000)
|
249
|
+
else
|
250
|
+
ef_f = File.join(x, 'energy_full'.freeze)
|
251
|
+
if File.readable?(ef_f)
|
252
|
+
IO.read(ef_f).to_i.fdiv(1_000_000)
|
253
|
+
else
|
254
|
+
nil
|
255
|
+
end
|
256
|
+
end
|
231
257
|
|
232
258
|
# status
|
233
259
|
s_f = File.join(x, 'status'.freeze).freeze
|
data/lib/linux_stat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linux_stat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sourav Goswami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Linux only, efficient linux system utilization reporting and system monitoring
|
14
14
|
gem
|