blink_tm 0.1.2 → 0.1.3
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/lib/blink_tm.rb +7 -2
- data/lib/blink_tm/blink_tm.rb +22 -23
- data/lib/blink_tm/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: 3a36bc60afc808cd46592945eebb5522b017af21743da1cdc71eeb381a7367dd
|
|
4
|
+
data.tar.gz: 8a5d4c012fdad495381e8fe4caafa39e9b3aafa8490f52dc83460cecc8826296
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac2ac55e696cb64a0260057029633e1132255d1956f9a484c841515fb3b9dac92d21ec6b4f7287186396c0c4bd3b54f301b69be88126616ee2ef4c9ffdd1a84c
|
|
7
|
+
data.tar.gz: 59454494c4df79ed7918e925c7e9cacf8db35b1e2b698e2192ba1c953829db023fb28d876075d736e9128f1940adc78d20892f3b3e75ec9201c961fad565f114
|
data/lib/blink_tm.rb
CHANGED
|
@@ -5,10 +5,13 @@ module BlinkTM
|
|
|
5
5
|
# Important Constants
|
|
6
6
|
BAUDRATE = BlinkTM::B57600
|
|
7
7
|
SCANID = 'BTM'
|
|
8
|
+
|
|
9
|
+
# POLLING time, how often should CPU, Net, IO usages should be updated.
|
|
10
|
+
# Should always be a float.
|
|
8
11
|
POLLING = 0.375
|
|
9
12
|
|
|
10
|
-
# Refresh
|
|
11
|
-
REFRESH = 0.5
|
|
13
|
+
# Refresh time, how often the main loop should run
|
|
14
|
+
REFRESH = 0.5
|
|
12
15
|
|
|
13
16
|
# Errors
|
|
14
17
|
NoDeviceError = Class.new(StandardError)
|
|
@@ -30,4 +33,6 @@ module BlinkTM
|
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
require 'blink_tm/version'
|
|
36
|
+
require 'fcntl'
|
|
37
|
+
require 'linux_stat'
|
|
33
38
|
require 'blink_tm/blink_tm'
|
data/lib/blink_tm/blink_tm.rb
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/ruby -w
|
|
2
2
|
# Frozen_String_Literal: true
|
|
3
3
|
|
|
4
|
-
require 'fcntl'
|
|
5
|
-
require 'linux_stat'
|
|
6
|
-
|
|
7
4
|
module BlinkTM
|
|
8
5
|
# Detect device
|
|
9
6
|
def find_device
|
|
@@ -97,8 +94,8 @@ module BlinkTM
|
|
|
97
94
|
sleep POLLING
|
|
98
95
|
io_stat2 = iostat()
|
|
99
96
|
|
|
100
|
-
io_r = io_stat2[0].-(io_stat1[0])
|
|
101
|
-
io_w = io_stat2[1].-(io_stat1[1])
|
|
97
|
+
io_r = io_stat2[0].-(io_stat1[0]).fdiv(POLLING)
|
|
98
|
+
io_w = io_stat2[1].-(io_stat1[1]).fdiv(POLLING)
|
|
102
99
|
end
|
|
103
100
|
}
|
|
104
101
|
|
|
@@ -132,6 +129,7 @@ module BlinkTM
|
|
|
132
129
|
end
|
|
133
130
|
|
|
134
131
|
puts "#{BlinkTM::BOLD}#{BlinkTM::GREEN}:: #{Time.now.strftime('%H:%M:%S.%2N')}: Device ready!#{BlinkTM::RESET}"
|
|
132
|
+
refresh = 0
|
|
135
133
|
|
|
136
134
|
while true
|
|
137
135
|
# cpu(01234) memUsed(999993) swapUsed(999992) io_active(0)
|
|
@@ -156,23 +154,15 @@ module BlinkTM
|
|
|
156
154
|
# "#{convert_bytes(net_u)} #{convert_bytes(net_d)} "\
|
|
157
155
|
# "#{convert_bytes(io_r)} #{convert_bytes(io_w)}"
|
|
158
156
|
|
|
159
|
-
|
|
157
|
+
refresh ^= 1
|
|
158
|
+
|
|
159
|
+
str = "!##{"%03d" % cpu_u}#{"%03d" % mem_u}#{"%03d" % swap_u}"\
|
|
160
160
|
"#{convert_bytes(net_u)}#{convert_bytes(net_d)}"\
|
|
161
|
-
"#{convert_bytes(io_r)}#{convert_bytes(io_w)}"
|
|
161
|
+
"#{convert_bytes(io_r)}#{convert_bytes(io_w)}#{refresh}~"
|
|
162
162
|
|
|
163
163
|
# Rescuing from suspend
|
|
164
|
-
file.syswrite('#')
|
|
165
|
-
|
|
166
|
-
file.syswrite('!')
|
|
167
|
-
file.flush
|
|
168
|
-
sleep 0.025
|
|
169
|
-
|
|
170
164
|
file.syswrite(str)
|
|
171
165
|
file.flush
|
|
172
|
-
sleep 0.025
|
|
173
|
-
|
|
174
|
-
file.syswrite('~')
|
|
175
|
-
file.flush
|
|
176
166
|
|
|
177
167
|
sleep REFRESH
|
|
178
168
|
end
|
|
@@ -208,14 +198,23 @@ module BlinkTM
|
|
|
208
198
|
|
|
209
199
|
@@sector_size ||= LS::FS.stat(?/)[:block_size]
|
|
210
200
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
201
|
+
io = []
|
|
202
|
+
|
|
203
|
+
IO.foreach('/proc/diskstats') { |x|
|
|
204
|
+
splitted = x.split
|
|
205
|
+
|
|
206
|
+
if splitted[2] == @@root_partition
|
|
207
|
+
# IO read / write
|
|
208
|
+
io.replace([
|
|
209
|
+
splitted[5].to_i * @@sector_size,
|
|
210
|
+
splitted[9].to_i * @@sector_size
|
|
211
|
+
])
|
|
214
212
|
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
break
|
|
214
|
+
end
|
|
215
|
+
}
|
|
217
216
|
|
|
218
|
-
|
|
217
|
+
io
|
|
219
218
|
end
|
|
220
219
|
|
|
221
220
|
extend(self)
|
data/lib/blink_tm/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blink_tm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
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-04-
|
|
11
|
+
date: 2021-04-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: linux_stat
|