linux_stat 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +484 -198
- data/exe/linuxstat.rb +94 -5
- data/lib/linux_stat/process_info.rb +30 -8
- 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: d2e39de1fbc809e3c2ebb150e92cd77584ce6fee22107966bdaab7a7c329e164
|
4
|
+
data.tar.gz: a66c52567c7ccb2e7ace5c7737a797d9de49a912c082d8432ec13fddfaac1e06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a73282108e1b16b1841e87188fd54099c44fdeecf2f69095335eb2a8ced7a8a5994f00a163bfe3620c17f7a9f487e6761f1895327ebeac3ac41490e4de7f33f9
|
7
|
+
data.tar.gz: 6101b6f1199bf969bcf4b7c28c1cfc1ae4c59177739650aa4962060721da9f36ed4c5d40ecebc45cdf668d715fb2e4d5e33f9b121dc37db4652128b210c36320
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# LinuxStat
|
1
|
+
# LinuxStat [](https://rubygems.org/gems/linux_stat) 
|
2
|
+
|
2
3
|

|
3
4
|
|
4
5
|
For reading the eyecandy HTML version, visit [linux_stat](https://souravgoswami.github.io/linux_stat/).
|
@@ -49,465 +50,750 @@ Or install it yourself as:
|
|
49
50
|
## Usage
|
50
51
|
### LinuxStat::BIOS
|
51
52
|
```
|
52
|
-
|
53
|
+
# File: bios.rb | Line: 56
|
54
|
+
# Definition: def date
|
55
|
+
LinuxStat::BIOS.date()
|
53
56
|
=> "04/10/2017"
|
54
57
|
|
55
|
-
|
58
|
+
# File: bios.rb | Line: 10
|
59
|
+
# Definition: def model
|
60
|
+
LinuxStat::BIOS.model()
|
56
61
|
=> "Inspiron 5567"
|
57
62
|
|
58
|
-
|
63
|
+
# File: bios.rb | Line: 27
|
64
|
+
# Definition: def vendor
|
65
|
+
LinuxStat::BIOS.vendor()
|
59
66
|
=> "Dell Inc."
|
60
67
|
|
61
|
-
|
68
|
+
# File: bios.rb | Line: 42
|
69
|
+
# Definition: def version
|
70
|
+
LinuxStat::BIOS.version()
|
62
71
|
=> "1.1.2"
|
63
72
|
|
64
73
|
```
|
65
74
|
|
66
75
|
### LinuxStat::Battery
|
67
76
|
```
|
68
|
-
|
77
|
+
# File: battery.rb | Line: 100
|
78
|
+
# Definition: def charge
|
79
|
+
LinuxStat::Battery.charge()
|
69
80
|
=> 100.0
|
70
81
|
|
71
|
-
|
82
|
+
# File: battery.rb | Line: 73
|
83
|
+
# Definition: def charging?
|
84
|
+
LinuxStat::Battery.charging?()
|
72
85
|
=> true
|
73
86
|
|
74
|
-
|
87
|
+
# File: battery.rb | Line: 82
|
88
|
+
# Definition: def discharging?
|
89
|
+
LinuxStat::Battery.discharging?()
|
75
90
|
=> false
|
76
91
|
|
77
|
-
|
92
|
+
# File: battery.rb | Line: 91
|
93
|
+
# Definition: def full?
|
94
|
+
LinuxStat::Battery.full?()
|
78
95
|
=> true
|
79
96
|
|
80
|
-
|
97
|
+
# File: battery.rb | Line: 45
|
98
|
+
# Definition: def manufacturer
|
99
|
+
LinuxStat::Battery.manufacturer()
|
81
100
|
=> "Samsung SDI"
|
82
101
|
|
83
|
-
|
102
|
+
# File: battery.rb | Line: 36
|
103
|
+
# Definition: def model
|
104
|
+
LinuxStat::Battery.model()
|
84
105
|
=> "DELL CYMGM77"
|
85
106
|
|
86
|
-
|
107
|
+
# File: battery.rb | Line: 8
|
108
|
+
# Definition: def present?
|
109
|
+
LinuxStat::Battery.present?()
|
87
110
|
=> true
|
88
111
|
|
89
|
-
|
112
|
+
# File: battery.rb | Line: 16
|
113
|
+
# Definition: def stat
|
114
|
+
LinuxStat::Battery.stat()
|
90
115
|
=> {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Full", :charge=>100.0, :charging=>true, :discharging=>false, :full=>true}
|
91
116
|
|
92
|
-
|
117
|
+
# File: battery.rb | Line: 64
|
118
|
+
# Definition: def status
|
119
|
+
LinuxStat::Battery.status()
|
93
120
|
=> "Full"
|
94
121
|
|
95
|
-
|
122
|
+
# File: battery.rb | Line: 54
|
123
|
+
# Definition: def technology
|
124
|
+
LinuxStat::Battery.technology()
|
96
125
|
=> "Li-ion"
|
97
126
|
|
98
127
|
```
|
99
128
|
|
100
129
|
### LinuxStat::CPU
|
101
130
|
```
|
102
|
-
|
131
|
+
# File: cpu.rb | Line: 82
|
132
|
+
# Definition: def count
|
133
|
+
LinuxStat::CPU.count()
|
103
134
|
=> 4
|
104
135
|
|
105
|
-
|
106
|
-
|
136
|
+
# File: cpu.rb | Line: 101
|
137
|
+
# Definition: def cur_freq
|
138
|
+
LinuxStat::CPU.cur_freq()
|
139
|
+
=> [2000018, 2000008, 2000003, 1992870]
|
107
140
|
|
108
|
-
|
141
|
+
# File: cpu.rb | Line: 116
|
142
|
+
# Definition: def max_freq
|
143
|
+
LinuxStat::CPU.max_freq()
|
109
144
|
=> [2000000, 2000000, 2000000, 2000000]
|
110
145
|
|
111
|
-
|
146
|
+
# File: cpu.rb | Line: 93
|
147
|
+
# Definition: def model
|
148
|
+
LinuxStat::CPU.model()
|
112
149
|
=> "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
|
113
150
|
|
114
|
-
|
115
|
-
|
151
|
+
# File: cpu.rb | Line: 21
|
152
|
+
# Definition: def stat(sleep = ticks_to_ms)
|
153
|
+
LinuxStat::CPU.stat(sleep)
|
154
|
+
=> {0=>25.0, 1=>50.0, 2=>0.0, 3=>0.0, 4=>50.0}
|
116
155
|
|
117
|
-
|
118
|
-
|
156
|
+
# File: linuxstat.rb | Line: 11
|
157
|
+
# Definition: define_singleton_method(:total_usage) do
|
158
|
+
LinuxStat::CPU.total_usage()
|
159
|
+
=> nil
|
119
160
|
|
120
|
-
|
121
|
-
|
161
|
+
# File: cpu.rb | Line: 63
|
162
|
+
# Definition: def total_usage(sleep = ticks_to_ms)
|
163
|
+
LinuxStat::CPU.usage(sleep)
|
164
|
+
=> 60.0
|
122
165
|
|
123
|
-
|
124
|
-
|
166
|
+
# File: cpu.rb | Line: 21
|
167
|
+
# Definition: def stat(sleep = ticks_to_ms)
|
168
|
+
LinuxStat::CPU.usages(sleep)
|
169
|
+
=> {0=>33.33, 1=>0.0, 2=>0.0, 3=>0.0, 4=>100.0}
|
125
170
|
|
126
171
|
```
|
127
172
|
|
128
|
-
### LinuxStat::
|
173
|
+
### LinuxStat::FS
|
174
|
+
```
|
129
175
|
```
|
130
|
-
LinuxStat::Filesystem.available
|
131
|
-
=> 33120964608
|
132
|
-
|
133
|
-
LinuxStat::Filesystem.free
|
134
|
-
=> 33120964608
|
135
|
-
|
136
|
-
LinuxStat::Filesystem.stat
|
137
|
-
=> {:total=>119981191168, :free=>33120964608, :used=>86860226560}
|
138
|
-
|
139
|
-
LinuxStat::Filesystem.stat_raw
|
140
|
-
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>8086173, :block_avail_unpriv=>8086173, :inodes=>58612160, :free_inodes=>56567338, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
141
176
|
|
142
|
-
LinuxStat::Filesystem
|
177
|
+
### LinuxStat::Filesystem
|
178
|
+
```
|
179
|
+
# File: filesystem.rb | Line: 92
|
180
|
+
# Definition: def available(fs = ?/.freeze)
|
181
|
+
LinuxStat::Filesystem.available(fs)
|
182
|
+
=> 52544614400
|
183
|
+
|
184
|
+
# File: filesystem.rb | Line: 58
|
185
|
+
# Definition: def free(fs = ?/.freeze)
|
186
|
+
LinuxStat::Filesystem.free(fs)
|
187
|
+
=> 52544614400
|
188
|
+
|
189
|
+
# File: filesystem.rb | Line: 19
|
190
|
+
# Definition: def stat(fs = ?/.freeze)
|
191
|
+
LinuxStat::Filesystem.stat(fs)
|
192
|
+
=> {:total=>119981191168, :free=>52544614400, :used=>67436576768}
|
193
|
+
|
194
|
+
# File: filesystem.rb | Line: 108
|
195
|
+
# Definition: def stat_raw(fs = ?/.freeze)
|
196
|
+
LinuxStat::Filesystem.stat_raw(fs)
|
197
|
+
=> {:block_size=>4096, :fragment_size=>4096, :blocks=>29292283, :block_free=>12828275, :block_avail_unpriv=>12828275, :inodes=>58612160, :free_inodes=>56968579, :filesystem_id=>2050, :mount_flags=>1024, :max_filename_length=>255}
|
198
|
+
|
199
|
+
# File: filesystem.rb | Line: 39
|
200
|
+
# Definition: def total(fs = ?/.freeze)
|
201
|
+
LinuxStat::Filesystem.total(fs)
|
143
202
|
=> 119981191168
|
144
203
|
|
145
|
-
|
146
|
-
|
204
|
+
# File: filesystem.rb | Line: 73
|
205
|
+
# Definition: def used(fs = ?/.freeze)
|
206
|
+
LinuxStat::Filesystem.used(fs)
|
207
|
+
=> 67436576768
|
147
208
|
|
148
209
|
```
|
149
210
|
|
150
211
|
### LinuxStat::Kernel
|
151
212
|
```
|
152
|
-
|
213
|
+
# File: kernel.rb | Line: 86
|
214
|
+
# Definition: def build_date
|
215
|
+
LinuxStat::Kernel.build_date()
|
153
216
|
=> 2020-11-20 07:44:55 +0000
|
154
217
|
|
155
|
-
|
218
|
+
# File: kernel.rb | Line: 140
|
219
|
+
# Definition: def build_date_string
|
220
|
+
LinuxStat::Kernel.build_date_string()
|
156
221
|
=> "20 Nov 2020 07:44:55 +0000"
|
157
222
|
|
158
|
-
|
223
|
+
# File: kernel.rb | Line: 21
|
224
|
+
# Definition: def build_user
|
225
|
+
LinuxStat::Kernel.build_user()
|
159
226
|
=> "souravgoswami@archlinux"
|
160
227
|
|
161
|
-
|
228
|
+
# File: kernel.rb | Line: 179
|
229
|
+
# Definition: def ticks
|
230
|
+
LinuxStat::Kernel.clk_tck()
|
162
231
|
=> 100
|
163
232
|
|
164
|
-
|
233
|
+
# File: kernel.rb | Line: 33
|
234
|
+
# Definition: def compiler
|
235
|
+
LinuxStat::Kernel.compiler()
|
165
236
|
=> [:gcc, "10.2.0"]
|
166
237
|
|
167
|
-
|
238
|
+
# File: kernel.rb | Line: 55
|
239
|
+
# Definition: def compiler_version
|
240
|
+
LinuxStat::Kernel.compiler_version()
|
168
241
|
=> "10.2.0"
|
169
242
|
|
170
|
-
|
243
|
+
# File: kernel.rb | Line: 10
|
244
|
+
# Definition: def version
|
245
|
+
LinuxStat::Kernel.release()
|
171
246
|
=> "5.9.9-xanmod1-1"
|
172
247
|
|
173
|
-
|
248
|
+
# File: kernel.rb | Line: 169
|
249
|
+
# Definition: def string
|
250
|
+
LinuxStat::Kernel.string()
|
174
251
|
=> "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"
|
175
252
|
|
176
|
-
|
253
|
+
# File: kernel.rb | Line: 179
|
254
|
+
# Definition: def ticks
|
255
|
+
LinuxStat::Kernel.ticks()
|
177
256
|
=> 100
|
178
257
|
|
179
|
-
|
258
|
+
# File: kernel.rb | Line: 10
|
259
|
+
# Definition: def version
|
260
|
+
LinuxStat::Kernel.version()
|
180
261
|
=> "5.9.9-xanmod1-1"
|
181
262
|
|
182
263
|
```
|
183
264
|
|
184
265
|
### LinuxStat::Memory
|
185
266
|
```
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
LinuxStat::Memory.
|
267
|
+
# File: memory.rb | Line: 50
|
268
|
+
# Definition: def available
|
269
|
+
LinuxStat::Memory.available()
|
270
|
+
=> 773460
|
271
|
+
|
272
|
+
# File: memory.rb | Line: 81
|
273
|
+
# Definition: def percent_available
|
274
|
+
LinuxStat::Memory.percent_available()
|
275
|
+
=> 20.16
|
276
|
+
|
277
|
+
# File: memory.rb | Line: 70
|
278
|
+
# Definition: def percent_used
|
279
|
+
LinuxStat::Memory.percent_used()
|
280
|
+
=> 79.84
|
281
|
+
|
282
|
+
# File: memory.rb | Line: 11
|
283
|
+
# Definition: def stat
|
284
|
+
LinuxStat::Memory.stat()
|
285
|
+
=> {:total=>3836236, :used=>3062776, :available=>773460, :percent_used=>79.84, :percent_available=>20.16}
|
286
|
+
|
287
|
+
# File: memory.rb | Line: 40
|
288
|
+
# Definition: def total
|
289
|
+
LinuxStat::Memory.total()
|
199
290
|
=> 3836236
|
200
291
|
|
201
|
-
|
202
|
-
|
292
|
+
# File: memory.rb | Line: 60
|
293
|
+
# Definition: def used
|
294
|
+
LinuxStat::Memory.used()
|
295
|
+
=> 3062776
|
203
296
|
|
204
297
|
```
|
205
298
|
|
206
299
|
### LinuxStat::Mounts
|
207
300
|
```
|
208
|
-
|
209
|
-
|
301
|
+
# File: mounts.rb | Line: 179
|
302
|
+
# Definition: def device_stat(dev = root)
|
303
|
+
LinuxStat::Mounts.device_stat(dev)
|
304
|
+
=> {:mountpoint=>"/", :total=>119981191168, :free=>52544614400, :available=>52544614400, :used=>67436576768, :percent_used=>56.21, :percent_free=>43.79, :percent_available=>43.79}
|
210
305
|
|
211
|
-
|
306
|
+
# File: mounts.rb | Line: 137
|
307
|
+
# Definition: def devices_stat
|
308
|
+
LinuxStat::Mounts.devices_stat()
|
212
309
|
=> {"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...
|
213
310
|
|
214
|
-
|
215
|
-
|
311
|
+
# File: mounts.rb | Line: 11
|
312
|
+
# Definition: def list
|
313
|
+
LinuxStat::Mounts.list()
|
314
|
+
=> ["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", "...
|
216
315
|
|
217
|
-
|
218
|
-
|
316
|
+
# File: mounts.rb | Line: 20
|
317
|
+
# Definition: def list_devices
|
318
|
+
LinuxStat::Mounts.list_devices()
|
319
|
+
=> ["proc", "sys", "dev", "run", "/dev/sda2", "securityfs", "tmpfs", "devpts", "tmpfs", "cgroup2", "cgroup", "pstore", "none", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "cgroup", "systemd-1", "tra...
|
219
320
|
|
220
|
-
|
221
|
-
|
321
|
+
# File: mounts.rb | Line: 109
|
322
|
+
# Definition: def list_devices_mount_point
|
323
|
+
LinuxStat::Mounts.list_devices_mount_point()
|
324
|
+
=> {"proc"=>"/proc", "sys"=>"/sys", "dev"=>"/dev", "run"=>"/run", "/dev/sda2"=>"/", "securityfs"=>"/sys/kernel/security", "tmpfs"=>"/run/user/1000", "devpts"=>"/dev/pts", "cgroup2"=>"/sys/fs/cgroup/unified", "cgroup"=>"/sys/fs/cgroup/blkio", "pstore"=>"/...
|
222
325
|
|
223
|
-
|
326
|
+
# File: mounts.rb | Line: 80
|
327
|
+
# Definition: def mount_point(dev = root)
|
328
|
+
LinuxStat::Mounts.mount_point(dev)
|
224
329
|
=> "/"
|
225
330
|
|
226
|
-
|
331
|
+
# File: mounts.rb | Line: 29
|
332
|
+
# Definition: def root
|
333
|
+
LinuxStat::Mounts.root()
|
227
334
|
=> "/dev/sda2"
|
228
335
|
|
229
|
-
|
336
|
+
# File: mounts.rb | Line: 38
|
337
|
+
# Definition: def root_fs
|
338
|
+
LinuxStat::Mounts.root_fs()
|
230
339
|
=> "xfs"
|
231
340
|
|
232
|
-
|
341
|
+
# File: mounts.rb | Line: 47
|
342
|
+
# Definition: def root_mount_options
|
343
|
+
LinuxStat::Mounts.root_mount_options()
|
233
344
|
=> "rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota"
|
234
345
|
|
235
|
-
|
236
|
-
|
346
|
+
# File: mounts.rb | Line: 56
|
347
|
+
# Definition: def tmpfs
|
348
|
+
LinuxStat::Mounts.tmpfs()
|
349
|
+
=> {"/dev/shm"=>"tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0", "/sys/fs/cgroup"=>"tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755 0 0", "/cache"=>"tmpfs /cache tmpfs rw,nosuid,nodev,relatime,size=2097152k 0 0", "/tmp"=>"...
|
237
350
|
|
238
351
|
```
|
239
352
|
|
240
353
|
### LinuxStat::Net
|
241
354
|
```
|
242
|
-
|
243
|
-
|
355
|
+
# File: net.rb | Line: 80
|
356
|
+
# Definition: def usage(interval = 0.1)
|
357
|
+
LinuxStat::Net.current_usage(interval)
|
358
|
+
=> {:received=>0.0, :transmitted=>0.0}
|
244
359
|
|
245
|
-
|
360
|
+
# File: net.rb | Line: 10
|
361
|
+
# Definition: def ipv4_private
|
362
|
+
LinuxStat::Net.ipv4_private()
|
246
363
|
=> "192.168.0.102"
|
247
364
|
|
248
|
-
|
249
|
-
|
365
|
+
# File: net.rb | Line: 23
|
366
|
+
# Definition: def total_bytes
|
367
|
+
LinuxStat::Net.total_bytes()
|
368
|
+
=> {:received=>463746011, :transmitted=>35058283}
|
250
369
|
|
251
|
-
|
252
|
-
|
370
|
+
# File: net.rb | Line: 41
|
371
|
+
# Definition: def total_bytes_received
|
372
|
+
LinuxStat::Net.total_bytes_received()
|
373
|
+
=> 463746011
|
253
374
|
|
254
|
-
|
255
|
-
|
375
|
+
# File: net.rb | Line: 54
|
376
|
+
# Definition: def total_bytes_transmitted
|
377
|
+
LinuxStat::Net.total_bytes_transmitted()
|
378
|
+
=> 35058283
|
256
379
|
|
257
|
-
|
258
|
-
|
380
|
+
# File: net.rb | Line: 80
|
381
|
+
# Definition: def usage(interval = 0.1)
|
382
|
+
LinuxStat::Net.usage(interval)
|
383
|
+
=> {:received=>0.0, :transmitted=>0.0}
|
259
384
|
|
260
385
|
```
|
261
386
|
|
262
387
|
### LinuxStat::OS
|
263
388
|
```
|
264
|
-
|
389
|
+
# File: os.rb | Line: 97
|
390
|
+
# Definition: def bits
|
391
|
+
LinuxStat::OS.bits()
|
265
392
|
=> 64
|
266
393
|
|
267
|
-
|
394
|
+
# File: os.rb | Line: 42
|
395
|
+
# Definition: def distribution
|
396
|
+
LinuxStat::OS.distribution()
|
268
397
|
=> "Arch Linux"
|
269
398
|
|
270
|
-
|
399
|
+
# File: os.rb | Line: 81
|
400
|
+
# Definition: def hostname
|
401
|
+
LinuxStat::OS.hostname()
|
271
402
|
=> "archlinux"
|
272
403
|
|
273
|
-
|
404
|
+
# File: os.rb | Line: 30
|
405
|
+
# Definition: def lsb_release
|
406
|
+
LinuxStat::OS.lsb_release()
|
274
407
|
=> {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
|
275
408
|
|
276
|
-
|
409
|
+
# File: os.rb | Line: 64
|
410
|
+
# Definition: def machine
|
411
|
+
LinuxStat::OS.machine()
|
277
412
|
=> "x86_64"
|
278
413
|
|
279
|
-
|
414
|
+
# File: os.rb | Line: 72
|
415
|
+
# Definition: def nodename
|
416
|
+
LinuxStat::OS.nodename()
|
280
417
|
=> "archlinux"
|
281
418
|
|
282
|
-
|
419
|
+
# File: os.rb | Line: 15
|
420
|
+
# Definition: def os_release
|
421
|
+
LinuxStat::OS.os_release()
|
283
422
|
=> {: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/"...
|
284
423
|
|
285
|
-
|
286
|
-
|
424
|
+
# File: os.rb | Line: 110
|
425
|
+
# Definition: def uptime
|
426
|
+
LinuxStat::OS.uptime()
|
427
|
+
=> {:hour=>5, :minute=>8, :second=>45.6}
|
287
428
|
|
288
429
|
```
|
289
430
|
|
290
|
-
### LinuxStat::
|
431
|
+
### LinuxStat::PrettifyBytes
|
291
432
|
```
|
292
|
-
|
293
|
-
|
433
|
+
# File: prettify_bytes.rb | Line: 42
|
434
|
+
# Definition: def convert_binary(n)
|
435
|
+
LinuxStat::PrettifyBytes.convert_binary( = 466897525899849)
|
436
|
+
=> "424.64 tebibytes"
|
294
437
|
|
295
|
-
|
296
|
-
|
438
|
+
# File: prettify_bytes.rb | Line: 19
|
439
|
+
# Definition: def convert_decimal(n)
|
440
|
+
LinuxStat::PrettifyBytes.convert_decimal( = 126301977853880)
|
441
|
+
=> "126.30 terabytes"
|
297
442
|
|
298
|
-
|
299
|
-
|
443
|
+
# File: prettify_bytes.rb | Line: 90
|
444
|
+
# Definition: def convert_short_binary(n)
|
445
|
+
LinuxStat::PrettifyBytes.convert_short_binary( = 751373892255236)
|
446
|
+
=> "683.37 TiB"
|
300
447
|
|
301
|
-
|
302
|
-
|
448
|
+
# File: prettify_bytes.rb | Line: 65
|
449
|
+
# Definition: def convert_short_decimal(n)
|
450
|
+
LinuxStat::PrettifyBytes.convert_short_decimal( = 691728311539436)
|
451
|
+
=> "691.73 TB"
|
303
452
|
|
304
|
-
|
305
|
-
=> [21158]
|
306
|
-
|
307
|
-
LinuxStat::Process.sleeping
|
308
|
-
=> [1, 2, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 38, 40, 41, 42, 46, 47, 48, 50, 51, 52, 111, 114, 115, 165, 167, 189, 217, 231, 302, 307, 308, 309, 310, 320, 321, 322, 323, 325, 326, 350, 353, 356, 374, 394,...
|
453
|
+
```
|
309
454
|
|
310
|
-
LinuxStat::Process
|
455
|
+
### LinuxStat::Process
|
456
|
+
```
|
457
|
+
# File: process.rb | Line: 19
|
458
|
+
# Definition: def count
|
459
|
+
LinuxStat::Process.count()
|
460
|
+
=> 201
|
461
|
+
|
462
|
+
# File: process.rb | Line: 71
|
463
|
+
# Definition: def idle
|
464
|
+
LinuxStat::Process.idle()
|
465
|
+
=> [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 119, 121, 131, 134, 140, 152, 153, 169, 171, 173, 174, 177, 178, 183, 184, 185, 186, 187, 188, 231, 271, 373, 383, 1001, 2553, 2554, 2555, 2556, 2557, 2558, 7770, 1...
|
466
|
+
|
467
|
+
# File: process.rb | Line: 8
|
468
|
+
# Definition: def list
|
469
|
+
LinuxStat::Process.list()
|
470
|
+
=> [1, 2, 3, 4, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 46, 47, 48, 49, 50, 51, 52, 102, 103, 104, 106, 107, 108, 109, 110, 111, 114, 115, 117, 118, 119, 121, 131, 134,...
|
471
|
+
|
472
|
+
# File: process.rb | Line: 25
|
473
|
+
# Definition: def names
|
474
|
+
LinuxStat::Process.names()
|
475
|
+
=> {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...
|
476
|
+
|
477
|
+
# File: process.rb | Line: 97
|
478
|
+
# Definition: def running
|
479
|
+
LinuxStat::Process.running()
|
480
|
+
=> [12385]
|
481
|
+
|
482
|
+
# File: process.rb | Line: 58
|
483
|
+
# Definition: def sleeping
|
484
|
+
LinuxStat::Process.sleeping()
|
485
|
+
=> [1, 2, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 38, 40, 41, 42, 46, 47, 48, 50, 51, 52, 111, 114, 115, 168, 170, 189, 218, 235, 301, 305, 309, 310, 311, 314, 315, 316, 317, 331, 334, 337, 403, 407, 409, 410,...
|
486
|
+
|
487
|
+
# File: process.rb | Line: 37
|
488
|
+
# Definition: def types
|
489
|
+
LinuxStat::Process.types()
|
311
490
|
=> {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...
|
312
491
|
|
313
|
-
|
492
|
+
# File: process.rb | Line: 84
|
493
|
+
# Definition: def zombie
|
494
|
+
LinuxStat::Process.zombie()
|
314
495
|
=> []
|
315
496
|
|
316
497
|
```
|
317
498
|
|
318
499
|
### LinuxStat::ProcessInfo
|
319
500
|
```
|
320
|
-
|
321
|
-
|
501
|
+
# File: process_info.rb | Line: 54
|
502
|
+
# Definition: def cmdline(pid = $$)
|
503
|
+
LinuxStat::ProcessInfo.cmdline(pid)
|
504
|
+
=> "ruby /usr/bin/linuxstat.rb -md"
|
322
505
|
|
323
|
-
|
506
|
+
# File: process_info.rb | Line: 78
|
507
|
+
# Definition: def command_name(pid = $$)
|
508
|
+
LinuxStat::ProcessInfo.command_name(pid)
|
324
509
|
=> "ruby"
|
325
510
|
|
326
|
-
|
327
|
-
|
511
|
+
# File: process_info.rb | Line: 247
|
512
|
+
# Definition: def cpu_stat(pid: $$, sleep: ticks_to_ms)
|
513
|
+
LinuxStat::ProcessInfo.cpu_stat(pid:, sleep:)
|
514
|
+
=> {:cpu_usage=>0.0, :threads=>1, :last_executed_cpu=>0}
|
328
515
|
|
329
|
-
|
516
|
+
# File: process_info.rb | Line: 301
|
517
|
+
# Definition: def cpu_usage(pid: $$, sleep: ticks_to_ms)
|
518
|
+
LinuxStat::ProcessInfo.cpu_usage(pid:, sleep:)
|
330
519
|
=> 0.0
|
331
520
|
|
332
|
-
|
521
|
+
# File: process_info.rb | Line: 406
|
522
|
+
# Definition: def gid(pid = $$)
|
523
|
+
LinuxStat::ProcessInfo.gid(pid)
|
333
524
|
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
334
525
|
|
335
|
-
|
336
|
-
|
526
|
+
# File: process_info.rb | Line: 369
|
527
|
+
# Definition: def last_executed_cpu(pid = $$)
|
528
|
+
LinuxStat::ProcessInfo.last_executed_cpu(pid)
|
529
|
+
=> 0
|
337
530
|
|
338
|
-
|
339
|
-
|
531
|
+
# File: process_info.rb | Line: 114
|
532
|
+
# Definition: def mem_stat(pid = $$)
|
533
|
+
LinuxStat::ProcessInfo.mem_stat(pid)
|
534
|
+
=> {:memory=>12251.136, :virtual_memory=>83943.424, :resident_memory=>18247.68}
|
340
535
|
|
341
|
-
|
342
|
-
|
536
|
+
# File: process_info.rb | Line: 147
|
537
|
+
# Definition: def memory(pid = $$)
|
538
|
+
LinuxStat::ProcessInfo.memory(pid)
|
539
|
+
=> 12251.136
|
343
540
|
|
344
|
-
|
345
|
-
|
541
|
+
# File: process_info.rb | Line: 540
|
542
|
+
# Definition: def nice(pid = $$)
|
543
|
+
LinuxStat::ProcessInfo.nice(pid)
|
544
|
+
=> 0
|
346
545
|
|
347
|
-
|
348
|
-
|
546
|
+
# File: process_info.rb | Line: 427
|
547
|
+
# Definition: def owner(pid = $$)
|
548
|
+
LinuxStat::ProcessInfo.owner(pid)
|
549
|
+
=> "sourav"
|
349
550
|
|
350
|
-
|
551
|
+
# File: process_info.rb | Line: 197
|
552
|
+
# Definition: def resident_memory(pid = $$)
|
553
|
+
LinuxStat::ProcessInfo.resident_memory(pid)
|
554
|
+
=> 18247.68
|
555
|
+
|
556
|
+
# File: process_info.rb | Line: 497
|
557
|
+
# Definition: def running_time(pid = $$)
|
558
|
+
LinuxStat::ProcessInfo.running_time(pid)
|
559
|
+
=> 0.680000000000291
|
560
|
+
|
561
|
+
# File: process_info.rb | Line: 480
|
562
|
+
# Definition: def start_time(pid = $$)
|
563
|
+
LinuxStat::ProcessInfo.start_time(pid)
|
564
|
+
=> 2020-12-17 16:16:17 +0530
|
565
|
+
|
566
|
+
# File: process_info.rb | Line: 449
|
567
|
+
# Definition: def start_time_epoch(pid = $$)
|
568
|
+
LinuxStat::ProcessInfo.start_time_epoch(pid)
|
569
|
+
=> 1608201977
|
570
|
+
|
571
|
+
# File: process_info.rb | Line: 525
|
572
|
+
# Definition: def state(pid = $$)
|
573
|
+
LinuxStat::ProcessInfo.state(pid)
|
574
|
+
=> "R"
|
575
|
+
|
576
|
+
# File: process_info.rb | Line: 344
|
577
|
+
# Definition: def threads(pid = $$)
|
578
|
+
LinuxStat::ProcessInfo.threads(pid)
|
351
579
|
=> 1
|
352
580
|
|
353
|
-
|
581
|
+
# File: process_info.rb | Line: 23
|
582
|
+
# Definition: def total_io(pid = $$)
|
583
|
+
LinuxStat::ProcessInfo.total_io(pid)
|
354
584
|
=> {:read_bytes=>0, :write_bytes=>0}
|
355
585
|
|
356
|
-
|
586
|
+
# File: process_info.rb | Line: 382
|
587
|
+
# Definition: def uid(pid = $$)
|
588
|
+
LinuxStat::ProcessInfo.uid(pid)
|
357
589
|
=> {:real=>1000, :effective=>1000, :saved_set=>1000, :filesystem_uid=>1000}
|
358
590
|
|
359
|
-
|
360
|
-
|
591
|
+
# File: process_info.rb | Line: 172
|
592
|
+
# Definition: def virtual_memory(pid = $$)
|
593
|
+
LinuxStat::ProcessInfo.virtual_memory(pid)
|
594
|
+
=> 83943.424
|
361
595
|
|
362
596
|
```
|
363
597
|
|
364
598
|
### LinuxStat::Swap
|
365
599
|
```
|
366
|
-
|
600
|
+
# File: swap.rb | Line: 22
|
601
|
+
# Definition: def any?
|
602
|
+
LinuxStat::Swap.any?()
|
367
603
|
=> true
|
368
604
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
LinuxStat::Swap.
|
382
|
-
=>
|
383
|
-
|
384
|
-
|
605
|
+
# File: swap.rb | Line: 68
|
606
|
+
# Definition: def available
|
607
|
+
LinuxStat::Swap.available()
|
608
|
+
=> 2868220
|
609
|
+
|
610
|
+
# File: swap.rb | Line: 8
|
611
|
+
# Definition: def list
|
612
|
+
LinuxStat::Swap.list()
|
613
|
+
=> {"/dev/zram0"=>[:partition, 4194300, 1326080, -2]}
|
614
|
+
|
615
|
+
# File: swap.rb | Line: 103
|
616
|
+
# Definition: def percent_available
|
617
|
+
LinuxStat::Swap.percent_available()
|
618
|
+
=> 68.38
|
619
|
+
|
620
|
+
# File: swap.rb | Line: 89
|
621
|
+
# Definition: def percent_used
|
622
|
+
LinuxStat::Swap.percent_used()
|
623
|
+
=> 31.62
|
624
|
+
|
625
|
+
# File: swap.rb | Line: 32
|
626
|
+
# Definition: def stat
|
627
|
+
LinuxStat::Swap.stat()
|
628
|
+
=> {:total=>4194300, :used=>1326080, :available=>2868220, :percent_used=>31.62, :percent_available=>68.38}
|
629
|
+
|
630
|
+
# File: swap.rb | Line: 57
|
631
|
+
# Definition: def total
|
632
|
+
LinuxStat::Swap.total()
|
385
633
|
=> 4194300
|
386
634
|
|
387
|
-
|
388
|
-
|
635
|
+
# File: swap.rb | Line: 80
|
636
|
+
# Definition: def used
|
637
|
+
LinuxStat::Swap.used()
|
638
|
+
=> 1326080
|
389
639
|
|
390
640
|
```
|
391
641
|
|
392
642
|
### LinuxStat::Sysconf
|
393
643
|
```
|
394
|
-
LinuxStat::Sysconf.child_max
|
644
|
+
# # LinuxStat::Sysconf.child_max()
|
395
645
|
=> 2000000
|
396
646
|
|
397
|
-
LinuxStat::Sysconf.get_euid
|
647
|
+
# # LinuxStat::Sysconf.get_euid()
|
398
648
|
=> 1000
|
399
649
|
|
400
|
-
LinuxStat::Sysconf.get_gid
|
650
|
+
# # LinuxStat::Sysconf.get_gid()
|
401
651
|
=> 1000
|
402
652
|
|
403
|
-
LinuxStat::Sysconf.get_login
|
653
|
+
# # LinuxStat::Sysconf.get_login()
|
404
654
|
=> "sourav"
|
405
655
|
|
406
|
-
LinuxStat::Sysconf.get_uid
|
656
|
+
# # LinuxStat::Sysconf.get_uid()
|
407
657
|
=> 1000
|
408
658
|
|
409
|
-
LinuxStat::Sysconf.get_user
|
659
|
+
# # LinuxStat::Sysconf.get_user()
|
410
660
|
=> "sourav"
|
411
661
|
|
412
|
-
LinuxStat::Sysconf.hostname_max
|
662
|
+
# # LinuxStat::Sysconf.hostname_max()
|
413
663
|
=> 64
|
414
664
|
|
415
|
-
LinuxStat::Sysconf.login_name_max
|
665
|
+
# # LinuxStat::Sysconf.login_name_max()
|
416
666
|
=> 256
|
417
667
|
|
418
|
-
LinuxStat::Sysconf.open_max
|
419
|
-
=>
|
668
|
+
# # LinuxStat::Sysconf.open_max()
|
669
|
+
=> 8192
|
420
670
|
|
421
|
-
LinuxStat::Sysconf.pagesize
|
671
|
+
# # LinuxStat::Sysconf.pagesize()
|
422
672
|
=> 4096
|
423
673
|
|
424
|
-
LinuxStat::Sysconf.posix_version
|
674
|
+
# # LinuxStat::Sysconf.posix_version()
|
425
675
|
=> 200809
|
426
676
|
|
427
|
-
LinuxStat::Sysconf.sc_clk_tck
|
677
|
+
# # LinuxStat::Sysconf.sc_clk_tck()
|
428
678
|
=> 100
|
429
679
|
|
430
|
-
LinuxStat::Sysconf.stream_max
|
680
|
+
# # LinuxStat::Sysconf.stream_max()
|
431
681
|
=> 16
|
432
682
|
|
433
|
-
LinuxStat::Sysconf.tty_name_max
|
683
|
+
# # LinuxStat::Sysconf.tty_name_max()
|
434
684
|
=> 32
|
435
685
|
|
436
686
|
```
|
437
687
|
|
438
688
|
### LinuxStat::Uname
|
439
689
|
```
|
440
|
-
LinuxStat::Uname.machine
|
690
|
+
# # LinuxStat::Uname.machine()
|
441
691
|
=> "x86_64"
|
442
692
|
|
443
|
-
LinuxStat::Uname.nodename
|
693
|
+
# # LinuxStat::Uname.nodename()
|
444
694
|
=> "archlinux"
|
445
695
|
|
446
|
-
LinuxStat::Uname.release
|
696
|
+
# # LinuxStat::Uname.release()
|
447
697
|
=> "5.9.9-xanmod1-1"
|
448
698
|
|
449
|
-
LinuxStat::Uname.sysname
|
699
|
+
# # LinuxStat::Uname.sysname()
|
450
700
|
=> "Linux"
|
451
701
|
|
452
|
-
LinuxStat::Uname.version
|
702
|
+
# # LinuxStat::Uname.version()
|
453
703
|
=> "#1 SMP PREEMPT Fri, 20 Nov 2020 07:44:55 +0000"
|
454
704
|
|
455
705
|
```
|
456
706
|
|
457
707
|
### LinuxStat::User
|
458
708
|
```
|
459
|
-
|
709
|
+
# File: user.rb | Line: 98
|
710
|
+
# Definition: def get_user
|
711
|
+
LinuxStat::User.get_current_user()
|
460
712
|
=> "sourav"
|
461
713
|
|
462
|
-
|
714
|
+
# File: user.rb | Line: 137
|
715
|
+
# Definition: def get_euid
|
716
|
+
LinuxStat::User.get_euid()
|
463
717
|
=> 1000
|
464
718
|
|
465
|
-
|
719
|
+
# File: user.rb | Line: 129
|
720
|
+
# Definition: def get_gid
|
721
|
+
LinuxStat::User.get_gid()
|
466
722
|
=> 1000
|
467
723
|
|
468
|
-
|
724
|
+
# File: user.rb | Line: 152
|
725
|
+
# Definition: def get_login
|
726
|
+
LinuxStat::User.get_login()
|
469
727
|
=> "sourav"
|
470
728
|
|
471
|
-
|
729
|
+
# File: user.rb | Line: 121
|
730
|
+
# Definition: def get_uid
|
731
|
+
LinuxStat::User.get_uid()
|
472
732
|
=> 1000
|
473
733
|
|
474
|
-
|
734
|
+
# File: user.rb | Line: 98
|
735
|
+
# Definition: def get_user
|
736
|
+
LinuxStat::User.get_user()
|
475
737
|
=> "sourav"
|
476
738
|
|
477
|
-
|
739
|
+
# File: user.rb | Line: 215
|
740
|
+
# Definition: def gid_by_username(username = get_user)
|
741
|
+
LinuxStat::User.gid_by_username(username)
|
478
742
|
=> 1000
|
479
743
|
|
480
|
-
|
744
|
+
# File: user.rb | Line: 56
|
745
|
+
# Definition: def gids
|
746
|
+
LinuxStat::User.gids()
|
481
747
|
=> {: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, :...
|
482
748
|
|
483
|
-
|
749
|
+
# File: user.rb | Line: 314
|
750
|
+
# Definition: def home_by_gid(id = get_gid)
|
751
|
+
LinuxStat::User.home_by_gid(id)
|
484
752
|
=> "/home/sourav"
|
485
753
|
|
486
|
-
|
754
|
+
# File: user.rb | Line: 266
|
755
|
+
# Definition: def home_by_username(user = get_user)
|
756
|
+
LinuxStat::User.home_by_username(user)
|
487
757
|
=> "/home/sourav"
|
488
758
|
|
489
|
-
|
759
|
+
# File: user.rb | Line: 72
|
760
|
+
# Definition: def home_directories
|
761
|
+
LinuxStat::User.home_directories()
|
490
762
|
=> {: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...
|
491
763
|
|
492
|
-
|
764
|
+
# File: user.rb | Line: 293
|
765
|
+
# Definition: def homes_by_uid(id = get_uid)
|
766
|
+
LinuxStat::User.homes_by_uid(id)
|
493
767
|
=> ["/home/sourav"]
|
494
768
|
|
495
|
-
|
769
|
+
# File: user.rb | Line: 23
|
770
|
+
# Definition: def ids
|
771
|
+
LinuxStat::User.ids()
|
496
772
|
=> {: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...
|
497
773
|
|
498
|
-
|
774
|
+
# File: user.rb | Line: 11
|
775
|
+
# Definition: def list
|
776
|
+
LinuxStat::User.list()
|
499
777
|
=> ["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...
|
500
778
|
|
501
|
-
|
779
|
+
# File: user.rb | Line: 244
|
780
|
+
# Definition: def uid_by_username(username = get_user)
|
781
|
+
LinuxStat::User.uid_by_username(username)
|
502
782
|
=> 1000
|
503
783
|
|
504
|
-
|
784
|
+
# File: user.rb | Line: 40
|
785
|
+
# Definition: def uids
|
786
|
+
LinuxStat::User.uids()
|
505
787
|
=> {: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...
|
506
788
|
|
507
|
-
|
789
|
+
# File: user.rb | Line: 187
|
790
|
+
# Definition: def username_by_gid(gid = get_gid)
|
791
|
+
LinuxStat::User.username_by_gid(gid)
|
508
792
|
=> "sourav"
|
509
793
|
|
510
|
-
|
794
|
+
# File: user.rb | Line: 169
|
795
|
+
# Definition: def usernames_by_uid(uid = get_uid)
|
796
|
+
LinuxStat::User.usernames_by_uid(uid)
|
511
797
|
=> ["sourav"]
|
512
798
|
|
513
799
|
```
|
data/exe/linuxstat.rb
CHANGED
@@ -7,6 +7,51 @@ rescue LoadError
|
|
7
7
|
abort "The Gem needs to be installed before this test can be run!"
|
8
8
|
end
|
9
9
|
|
10
|
+
module LinuxStat::CPU
|
11
|
+
define_singleton_method(:total_usage) do
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Gradient colour to strings
|
16
|
+
class String
|
17
|
+
def colourize(colour = 1, flip: false)
|
18
|
+
colours, line_length = [], -1
|
19
|
+
temp = ''
|
20
|
+
|
21
|
+
each_line do |c|
|
22
|
+
n, i = c.length, -1
|
23
|
+
|
24
|
+
if line_length != n
|
25
|
+
step, line_length = 255.0./(n), n
|
26
|
+
colours.clear
|
27
|
+
|
28
|
+
while (i += 1) < n
|
29
|
+
l = i.*(step)
|
30
|
+
colours.<<(
|
31
|
+
case colour
|
32
|
+
when 0 then [ l.*(2).to_i.clamp(0, 255), l.to_i.clamp(0, 255), 255.-(l).to_i.clamp(0, 255) ]
|
33
|
+
when 1 then [ 255, 255.-(l).to_i.clamp(0, 255), l.to_i.clamp(0, 255) ]
|
34
|
+
when 2 then [ l.to_i.clamp(0, 255), 255.-(l).to_i.clamp(0, 255), l.to_i.clamp(0, 255) ]
|
35
|
+
when 3 then [ l.*(2).to_i.clamp(0, 255), 255.-(l).to_i.clamp(0, 255), 100.+(l / 2).to_i.clamp(0, 255) ]
|
36
|
+
when 4 then [ 30, 255.-(l / 2).to_i.clamp(0, 255), 110.+(l / 2).to_i.clamp(0, 255) ]
|
37
|
+
when 5 then [ 255.-(l * 2).to_i.clamp(0, 255), l.to_i.clamp(0, 255), 200 ]
|
38
|
+
when 6 then [ 50.+(255 - l).to_i.clamp(0, 255), 255.-(l / 2).to_i.clamp(0, 255), (l * 2).to_i.clamp(0, 255) ]
|
39
|
+
else [ l.*(2).to_i.clamp(0, 255), 255.-(l).to_i.clamp(0, 255), 100.+(l / 2).to_i.clamp(0, 255) ]
|
40
|
+
end
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
colours.reverse! if flip
|
45
|
+
end
|
46
|
+
|
47
|
+
i = -1
|
48
|
+
temp.concat "\e[38;2;#{colours[i][0]};#{colours[i][1]};#{colours[i][2]}m#{c[i]}" while (i += 1) < n
|
49
|
+
end
|
50
|
+
|
51
|
+
temp << "\e[0m".freeze
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
10
55
|
# Check which conflicting argument (e.g., `-md -html` together) is passed last
|
11
56
|
# Always use the last argument
|
12
57
|
conflicting, hash = [
|
@@ -54,7 +99,6 @@ execute.sort.each do |c|
|
|
54
99
|
next if e.class != Module && e.class != Class
|
55
100
|
|
56
101
|
meths = e.methods(false).sort
|
57
|
-
next if meths.any? { |a| e.method(a).arity > 0 }
|
58
102
|
|
59
103
|
if meths.length > 0
|
60
104
|
if MARKDOWN
|
@@ -66,21 +110,66 @@ execute.sort.each do |c|
|
|
66
110
|
end
|
67
111
|
end
|
68
112
|
|
113
|
+
|
69
114
|
meths.each do |meth|
|
115
|
+
arg = nil
|
116
|
+
params = e.method(meth).parameters
|
117
|
+
|
118
|
+
param = ''
|
119
|
+
|
120
|
+
params.each do |p|
|
121
|
+
case p[0]
|
122
|
+
when :opt
|
123
|
+
param << "#{p[1]}, "
|
124
|
+
when :key
|
125
|
+
param << "#{p[1]}:, "
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
param.delete_suffix!(", ")
|
130
|
+
|
131
|
+
if e.method(meth).arity > 0
|
132
|
+
if c == :PrettifyBytes
|
133
|
+
arg = rand(10 ** 15)
|
134
|
+
else
|
135
|
+
next
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
disp_meth = "#{meth}"
|
140
|
+
disp_meth.concat(arg ? "(#{param} = #{arg})" : "(#{param})")
|
141
|
+
|
70
142
|
time = Time.now
|
71
|
-
v = e.send(meth)
|
143
|
+
v = arg ? e.send(meth, arg) : e.send(meth)
|
72
144
|
time2 = Time.now
|
73
145
|
time = time2.-(time).*(1_000_000).round(3)
|
74
146
|
|
75
147
|
v = v.inspect
|
76
148
|
dis = v.length > 253 ? v[0..250].strip + '...'.freeze : v
|
77
149
|
|
150
|
+
source = e.singleton_method(meth).source_location.to_a
|
151
|
+
src, src_meth = '', ''
|
152
|
+
|
153
|
+
unless source.empty?
|
154
|
+
src << " File: #{File.split(source[0])[-1]} | Line: #{source[1]}\n"
|
155
|
+
src_meth << " Definition: #{IO.foreach(source[0]).first(source[1])[-1].strip}\n"
|
156
|
+
|
157
|
+
if MARKDOWN || HTML
|
158
|
+
src.prepend('#'.freeze)
|
159
|
+
src_meth.prepend('#'.freeze)
|
160
|
+
else
|
161
|
+
src.prepend(?\u2B23.freeze)
|
162
|
+
src_meth.prepend(?\u2B23.freeze)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
|
78
167
|
if MARKDOWN
|
79
|
-
puts "#{e}.#{
|
168
|
+
puts "#{src}#{src_meth}#{e}.#{disp_meth}\n=> #{dis}"
|
80
169
|
elsif HTML
|
81
|
-
puts "#{e}.#{
|
170
|
+
puts "#{src}#{src_meth}#{e}.#{disp_meth}\n=> #{dis}"
|
82
171
|
else
|
83
|
-
puts "\e[1;38;2;80;80;255m#{e}.#{
|
172
|
+
puts "\e[1m#{src.colourize}\e[1m#{src_meth.colourize(4)}\e[0m\e[1;38;2;80;80;255m#{e}.#{disp_meth}\e[0m\n=> #{dis}"
|
84
173
|
end
|
85
174
|
|
86
175
|
puts( "(" +
|
@@ -435,6 +435,32 @@ module LinuxStat
|
|
435
435
|
LinuxStat::User.username_by_gid(gid)
|
436
436
|
end
|
437
437
|
|
438
|
+
##
|
439
|
+
# = start_time_epoch(pid = $$)
|
440
|
+
#
|
441
|
+
# Returns the epoch time (as Integer) the process was started.
|
442
|
+
#
|
443
|
+
# For example:
|
444
|
+
# LinuxStat::ProcessInfo.start_time_epoch 526
|
445
|
+
#
|
446
|
+
# => 1608097744
|
447
|
+
#
|
448
|
+
# If the info isn't available or the argument passed doesn't exist as a process ID, it will return nil.
|
449
|
+
def start_time_epoch(pid = $$)
|
450
|
+
stat_file = "/proc/#{pid}/stat".freeze
|
451
|
+
uptime = "/proc/uptime".freeze
|
452
|
+
|
453
|
+
@@u_readable ||= File.readable?(uptime)
|
454
|
+
return nil unless @@u_readable && File.readable?(stat_file)
|
455
|
+
|
456
|
+
u = IO.foreach(uptime, ' '.freeze).next.to_f
|
457
|
+
st = (IO.foreach(stat_file, ' '.freeze).first(22)[-1].to_f / get_ticks)
|
458
|
+
|
459
|
+
# Getting two Time objects and dealing with floating point numbers
|
460
|
+
# Just to make sure the time goes monotonically
|
461
|
+
Time.now.-(u - st).to_i
|
462
|
+
end
|
463
|
+
|
438
464
|
##
|
439
465
|
# = start_time(pid = $$)
|
440
466
|
#
|
@@ -443,7 +469,7 @@ module LinuxStat
|
|
443
469
|
# For example:
|
444
470
|
# LinuxStat::ProcessInfo.start_time 14183
|
445
471
|
#
|
446
|
-
# => 2020-12-16 13:31:43
|
472
|
+
# => 2020-12-16 13:31:43 +0000
|
447
473
|
#
|
448
474
|
# If the info isn't available or the argument passed doesn't exist as a process ID, it will return nil.
|
449
475
|
#
|
@@ -452,13 +478,9 @@ module LinuxStat
|
|
452
478
|
#
|
453
479
|
# Don't trust the timezone returned by the time.
|
454
480
|
def start_time(pid = $$)
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
@@u_readable ||= File.readable?(uptime)
|
459
|
-
return nil unless @@u_readable && File.readable?(stat_file)
|
460
|
-
|
461
|
-
Time.now.-(IO.foreach(uptime, ' '.freeze).next.to_i - (IO.read(stat_file).split[21].to_i / get_ticks))
|
481
|
+
# Getting two Time objects and dealing with floating point numbers
|
482
|
+
# Just to make sure the time goes monotonically
|
483
|
+
Time.at(start_time_epoch(pid))
|
462
484
|
end
|
463
485
|
|
464
486
|
##
|
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: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sourav Goswami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Linux only, efficient linux system utilization reporting and system monitoring
|
14
14
|
gem
|