usagewatch 0.0.6.beta2 → 0.0.6.beta3

Sign up to get free protection for your applications and to get access to all the features.
@@ -133,50 +133,51 @@ module Usagewatch
133
133
  end
134
134
  end
135
135
 
136
- def self.uw_bandrx
137
-
138
- def bandrx
136
+ def self.bandrx
139
137
 
140
- if File.exists?("/proc/net/dev")
141
- File.open("/proc/net/dev", "r") do |file|
142
- @result = file.read
143
- end
138
+ if File.exists?("/proc/net/dev")
139
+ File.open("/proc/net/dev", "r") do |file|
140
+ @result = file.read
144
141
  end
142
+ end
145
143
 
146
- @arrRows = @result.split("\n")
144
+ @arrRows = @result.split("\n")
147
145
 
148
- @arrEthLoRows = @arrRows.grep(/eth|lo/)
146
+ @arrEthLoRows = @arrRows.grep(/eth|lo/)
149
147
 
150
- rowcount = (@arrEthLoRows.count - 1)
148
+ rowcount = (@arrEthLoRows.count - 1)
151
149
 
152
- for i in (0..rowcount)
153
- @arrEthLoRows[i] = @arrEthLoRows[i].gsub(/\s+/m, ' ').strip.split(" ")
154
- end
150
+ for i in (0..rowcount)
151
+ @arrEthLoRows[i] = @arrEthLoRows[i].gsub(/\s+/m, ' ').strip.split(" ")
152
+ end
155
153
 
156
- @arrColumns = Array.new
157
- for l in (0..rowcount)
158
- @temp = Array.new
159
- @temp[0] = @arrEthLoRows[l][1]
160
- @temp[1] = @arrEthLoRows[l][9]
161
- @arrColumns << @temp
162
- end
154
+ @arrColumns = Array.new
155
+ for l in (0..rowcount)
156
+ @temp = Array.new
157
+ @temp[0] = @arrEthLoRows[l][1]
158
+ @temp[1] = @arrEthLoRows[l][9]
159
+ @arrColumns << @temp
160
+ end
163
161
 
164
- columncount = (@arrColumns[0].count - 1)
162
+ columncount = (@arrColumns[0].count - 1)
165
163
 
166
- @arrTotal = Array.new
167
- for p in (0..columncount)
168
- @arrTotal[p] = 0
169
- end
164
+ @arrTotal = Array.new
165
+ for p in (0..columncount)
166
+ @arrTotal[p] = 0
167
+ end
170
168
 
171
- for j in (0..columncount)
172
- for k in (0..rowcount)
173
- @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
174
- end
169
+ for j in (0..columncount)
170
+ for k in (0..rowcount)
171
+ @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
175
172
  end
176
-
177
- @bandrxtx= @arrTotal
178
173
  end
179
174
 
175
+ @bandrxtx = @arrTotal
176
+ end
177
+
178
+
179
+ def self.uw_bandrx
180
+
180
181
  @new0 = bandrx
181
182
  sleep 1
182
183
  @new1 = bandrx
@@ -186,153 +187,155 @@ module Usagewatch
186
187
  @megabitsreceived = (@bitsreceived.to_f / 1024 / 1024).round(3)
187
188
  end
188
189
 
189
- def self.uw_bandtx
190
-
191
- def bandtx
190
+ def self.bandtx
192
191
 
193
- if File.exists?("/proc/net/dev")
194
- File.open("/proc/net/dev", "r") do |file|
195
- @result = file.read
196
- end
192
+ if File.exists?("/proc/net/dev")
193
+ File.open("/proc/net/dev", "r") do |file|
194
+ @result = file.read
197
195
  end
196
+ end
198
197
 
199
- @arrRows = @result.split("\n")
198
+ @arrRows = @result.split("\n")
200
199
 
201
- @arrEthLoRows = @arrRows.grep(/eth|lo/)
200
+ @arrEthLoRows = @arrRows.grep(/eth|lo/)
202
201
 
203
- rowcount = (@arrEthLoRows.count - 1)
202
+ rowcount = (@arrEthLoRows.count - 1)
204
203
 
205
- for i in (0..rowcount)
206
- @arrEthLoRows[i] = @arrEthLoRows[i].gsub(/\s+/m, ' ').strip.split(" ")
207
- end
204
+ for i in (0..rowcount)
205
+ @arrEthLoRows[i] = @arrEthLoRows[i].gsub(/\s+/m, ' ').strip.split(" ")
206
+ end
208
207
 
209
- @arrColumns = Array.new
210
- for l in (0..rowcount)
211
- @temp = Array.new
212
- @temp[0] = @arrEthLoRows[l][1]
213
- @temp[1] = @arrEthLoRows[l][9]
214
- @arrColumns << @temp
215
- end
208
+ @arrColumns = Array.new
209
+ for l in (0..rowcount)
210
+ @temp = Array.new
211
+ @temp[0] = @arrEthLoRows[l][1]
212
+ @temp[1] = @arrEthLoRows[l][9]
213
+ @arrColumns << @temp
214
+ end
216
215
 
217
- columncount = (@arrColumns[0].count - 1)
216
+ columncount = (@arrColumns[0].count - 1)
218
217
 
219
- @arrTotal = Array.new
220
- for p in (0..columncount)
221
- @arrTotal[p] = 0
222
- end
218
+ @arrTotal = Array.new
219
+ for p in (0..columncount)
220
+ @arrTotal[p] = 0
221
+ end
223
222
 
224
- for j in (0..columncount)
225
- for k in (0..rowcount)
226
- @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
227
- end
223
+ for j in (0..columncount)
224
+ for k in (0..rowcount)
225
+ @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
228
226
  end
229
-
230
- @bandrxtx = @arrTotal
231
227
  end
232
228
 
233
- @new0 = bandtx
229
+ @bandrxtx = @arrTotal
230
+ end
231
+
232
+ def self.uw_bandtx
233
+
234
+ @new0 = Usagewatch.bandtx
234
235
  sleep 1
235
- @new1 = bandtx
236
+ @new1 = Usagewatch.bandtx
236
237
 
237
238
  @bytestransmitted = @new1[1].to_i - @new0[1].to_i
238
239
  @bitstransmitted = (@bytestransmitted * 8)
239
240
  @megabitstransmitted = (@bitstransmitted.to_f / 1024 / 1024).round(3)
240
241
  end
241
242
 
242
- def self.uw_diskioreads
243
+ def self.diskio
243
244
 
244
- def diskio
245
-
246
- if File.exists?("/proc/diskstats")
247
- File.open("/proc/diskstats", "r") do |file|
248
- @result = file.read
249
- end
245
+ if File.exists?("/proc/diskstats")
246
+ File.open("/proc/diskstats", "r") do |file|
247
+ @result = file.read
250
248
  end
249
+ end
251
250
 
252
- @arrRows = @result.split("\n")
251
+ @arrRows = @result.split("\n")
253
252
 
254
- rowcount = (@arrRows.count - 1)
253
+ rowcount = (@arrRows.count - 1)
255
254
 
256
- for i in (0..rowcount)
257
- @arrRows[i] = @arrRows[i].gsub(/\s+/m, ' ').strip.split(" ")
258
- end
255
+ for i in (0..rowcount)
256
+ @arrRows[i] = @arrRows[i].gsub(/\s+/m, ' ').strip.split(" ")
257
+ end
259
258
 
260
- @arrColumns = Array.new
261
- for l in (0..rowcount)
262
- @temp = Array.new
263
- @temp[0] = @arrRows[l][3]
264
- @temp[1] = @arrRows[l][7]
265
- @arrColumns << @temp
266
- end
259
+ @arrColumns = Array.new
260
+ for l in (0..rowcount)
261
+ @temp = Array.new
262
+ @temp[0] = @arrRows[l][3]
263
+ @temp[1] = @arrRows[l][7]
264
+ @arrColumns << @temp
265
+ end
267
266
 
268
- columncount = (@arrColumns[0].count - 1)
267
+ columncount = (@arrColumns[0].count - 1)
269
268
 
270
- @arrTotal = Array.new
271
- for p in (0..columncount)
272
- @arrTotal[p] = 0
273
- end
269
+ @arrTotal = Array.new
270
+ for p in (0..columncount)
271
+ @arrTotal[p] = 0
272
+ end
274
273
 
275
- for j in (0..columncount)
276
- for k in (0..rowcount)
277
- @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
278
- end
274
+ for j in (0..columncount)
275
+ for k in (0..rowcount)
276
+ @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
279
277
  end
280
-
281
- @diskiorw= @arrTotal
282
278
  end
283
279
 
284
- @new0 = diskio
280
+ @diskiorw= @arrTotal
281
+ end
282
+
283
+
284
+ def self.uw_diskioreads
285
+
286
+ @new0 = Usagewatch.diskio
285
287
  sleep 1
286
- @new1 = diskio
288
+ @new1 = Usagewatch.diskio
287
289
 
288
290
  @diskreads = @new1[0].to_i - @new0[0].to_i
289
291
  end
290
292
 
291
- def self.uw_diskiowrites
293
+ def self.diskio
292
294
 
293
- def diskio
294
-
295
- if File.exists?("/proc/diskstats")
296
- File.open("/proc/diskstats", "r") do |file|
297
- @result = file.read
298
- end
295
+ if File.exists?("/proc/diskstats")
296
+ File.open("/proc/diskstats", "r") do |file|
297
+ @result = file.read
299
298
  end
299
+ end
300
300
 
301
- @arrRows = @result.split("\n")
301
+ @arrRows = @result.split("\n")
302
302
 
303
- rowcount = (@arrRows.count - 1)
303
+ rowcount = (@arrRows.count - 1)
304
304
 
305
- for i in (0..rowcount)
306
- @arrRows[i] = @arrRows[i].gsub(/\s+/m, ' ').strip.split(" ")
307
- end
305
+ for i in (0..rowcount)
306
+ @arrRows[i] = @arrRows[i].gsub(/\s+/m, ' ').strip.split(" ")
307
+ end
308
308
 
309
- @arrColumns = Array.new
310
- for l in (0..rowcount)
311
- @temp = Array.new
312
- @temp[0] = @arrRows[l][3]
313
- @temp[1] = @arrRows[l][7]
314
- @arrColumns << @temp
315
- end
309
+ @arrColumns = Array.new
310
+ for l in (0..rowcount)
311
+ @temp = Array.new
312
+ @temp[0] = @arrRows[l][3]
313
+ @temp[1] = @arrRows[l][7]
314
+ @arrColumns << @temp
315
+ end
316
316
 
317
- columncount = (@arrColumns[0].count - 1)
317
+ columncount = (@arrColumns[0].count - 1)
318
318
 
319
- @arrTotal = Array.new
320
- for p in (0..columncount)
321
- @arrTotal[p] = 0
322
- end
319
+ @arrTotal = Array.new
320
+ for p in (0..columncount)
321
+ @arrTotal[p] = 0
322
+ end
323
323
 
324
- for j in (0..columncount)
325
- for k in (0..rowcount)
326
- @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
327
- end
324
+ for j in (0..columncount)
325
+ for k in (0..rowcount)
326
+ @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
328
327
  end
329
-
330
- @diskiorw= @arrTotal
331
328
  end
332
329
 
333
- @new0 = diskio
330
+ @diskiorw= @arrTotal
331
+ end
332
+
333
+
334
+ def self.uw_diskiowrites
335
+
336
+ @new0 = Usagewatch.diskio
334
337
  sleep 1
335
- @new1 = diskio
338
+ @new1 = Usagewatch.diskio
336
339
 
337
340
  @diskwrites = @new1[1].to_i - @new0[1].to_i
338
341
  end
@@ -1,3 +1,3 @@
1
1
  module Usagewatch
2
- VERSION = "0.0.6.beta2"
2
+ VERSION = "0.0.6.beta3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usagewatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6.beta2
4
+ version: 0.0.6.beta3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: