usagewatch 0.0.5 → 0.0.6.beta1

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.
data/CHANGELOG ADDED
@@ -0,0 +1,19 @@
1
+ 0.0.6.beta1 July 19 2013
2
+ ====
3
+ * Added methods for top ten processes by CPU consumption
4
+ * Added methods for top ten processes by Memory consumption
5
+ * Validation to work only in Linux OS
6
+
7
+ 0.0.3, 0.0.4, 0.0.5 Jul 17 2013
8
+ ====
9
+ * Gem specs actualization
10
+
11
+ 0.0.2 Jul 17 2013
12
+ =====
13
+ * Percentage of disk utilization
14
+ * Load format to float
15
+
16
+ 0.0.1 Jul 17 2013
17
+ =====
18
+ * First release of the gem
19
+
data/README.md CHANGED
@@ -27,6 +27,8 @@ uw_bandrx
27
27
  uw_bandtx
28
28
  uw_diskioreads
29
29
  uw_diskiowrites
30
+ uw_cputop
31
+ uw_memtop
30
32
  ```
31
33
 
32
34
  ## Example
@@ -49,6 +51,10 @@ Example Output:
49
51
  0.2 Mbit/s Current Bandwidth Transmitted
50
52
  0/s Current Disk Reads Completed
51
53
  2/s Current Disk Writes Completed
54
+ Top Ten Processes By CPU Consumption:
55
+ [["/usr/lib64/erlang/erts-5.8.5/bin/beam.smp", "5.2"], ["ruby", "4.1"], ["ps", "2.0"], ["abrt-dump-oops", "0.8"], ["aoe_ktio", "0.7"], ["aoe_tx", "0.4"], ["ata_sff", "0.2"], ["auditd", "0.1"], ["awk", "0.1"], ["-bash", "0.1"]]
56
+ Top Ten Processes By Memory Consumption:
57
+ [["unicorn", "4.8"], ["unicorn", "4.7"], ["unicorn", "4.6"], ["unicorn", "4.6"], ["unicorn", "4.5"], ["unicorn", "4.5"], ["unicorn", "4.3"], ["unicorn", "4.3"], ["unicorn", "4.2"], ["/usr/lib64/erlang/erts-5.8.5/bin/beam.smp", "4.0"]]
52
58
  ```
53
59
 
54
60
  ## Notes
@@ -69,10 +75,14 @@ Bandwidth is current received and transmitted in Megabits
69
75
 
70
76
  Disk IO is current disk reads and writes completed per second
71
77
 
78
+ Top Ten Processes By CPU Consumption are based on percent CPU used
79
+
80
+ Top Ten Processes By Memory Consumption are base on percent Memory used
81
+
72
82
  ## Tested Using
73
83
 
74
84
  RUBY VERSIONS:
75
85
  ruby 1.9.3p429 (2013-05-15) [x86_64-linux]
76
86
 
77
87
  OS VERSIONS:
78
- CENTOS 5x 6x
88
+ CENTOS 5x 6x, Ubuntu 12.04, Fedora 18
data/examples/example.rb CHANGED
@@ -16,3 +16,5 @@ puts "#{uw_bandrx} Mbit/s Current Bandwidth Received"
16
16
  puts "#{uw_bandtx} Mbit/s Current Bandwidth Transmitted"
17
17
  puts "#{uw_diskioreads}/s Current Disk Reads Completed"
18
18
  puts "#{uw_diskiowrites}/s Current Disk Writes Completed"
19
+ puts "Top Ten Processes By CPU Consumption: #{uw_cputop}"
20
+ puts "Top Ten Processes By Memory Consumption: #{uw_memtop}"
@@ -0,0 +1,339 @@
1
+ module Usagewatch
2
+ def uw_diskused
3
+ @df = `df`
4
+ @parts = @df.split(" ").map { |s| s.to_i }
5
+ @sum = 0
6
+ for i in (9..@parts.size - 1).step(6) do
7
+ @sum += @parts[i]
8
+ end
9
+ @round = @sum.round(2)
10
+ @totaldiskused = ((@round/1024)/1024).round(2)
11
+ end
12
+
13
+ # Show the percentage of disk used.
14
+ def uw_diskused_perc
15
+ df = `df --total`
16
+ df.split(" ").last.to_f.round(2)
17
+ end
18
+
19
+ def uw_cpuused
20
+ @proc0 = File.readlines('/proc/stat').grep(/^cpu /).first.split(" ")
21
+ sleep 1
22
+ @proc1 = File.readlines('/proc/stat').grep(/^cpu /).first.split(" ")
23
+
24
+ @proc0usagesum = @proc0[1].to_i + @proc0[2].to_i + @proc0[3].to_i
25
+ @proc1usagesum = @proc1[1].to_i + @proc1[2].to_i + @proc1[3].to_i
26
+ @procusage = @proc1usagesum - @proc0usagesum
27
+
28
+ @proc0total = 0
29
+ for i in (1..4) do
30
+ @proc0total += @proc0[i].to_i
31
+ end
32
+ @proc1total = 0
33
+ for i in (1..4) do
34
+ @proc1total += @proc1[i].to_i
35
+ end
36
+ @proctotal = (@proc1total - @proc0total)
37
+
38
+ @cpuusage = (@procusage.to_f / @proctotal.to_f)
39
+ @cpuusagepercentage = (100 * @cpuusage).to_f.round(2)
40
+ end
41
+
42
+ # return hash of top ten proccesses by cpu consumption
43
+ # example [["apache2", 12.0], ["passenger", 13.2]]
44
+ def uw_cputop
45
+ ps = `ps aux | awk '{print $11, $3}' | sort -k2nr | head -n 10`
46
+ array = []
47
+ ps.each_line do |line|
48
+ line = line.chomp.split(" ")
49
+ array << [line.first.gsub(/[\[\]]/, ""), line.last]
50
+ end
51
+ array
52
+ end
53
+
54
+
55
+ def uw_tcpused
56
+ if File.exists?("/proc/net/sockstat")
57
+ File.open("/proc/net/sockstat", "r") do |ipv4|
58
+ @sockstat = ipv4.read
59
+ end
60
+
61
+ @tcp4data = @sockstat.split
62
+ @tcp4count = @tcp4data[5]
63
+ end
64
+
65
+ if File.exists?("/proc/net/sockstat6")
66
+ File.open("/proc/net/sockstat6", "r") do |ipv6|
67
+ @sockstat6 = ipv6.read
68
+
69
+ end
70
+
71
+ @tcp6data = @sockstat6.split
72
+ @tcp6count = @tcp6data[2]
73
+ end
74
+
75
+ @totaltcpused = @tcp4count.to_i + @tcp6count.to_i
76
+ end
77
+
78
+ def uw_udpused
79
+ if File.exists?("/proc/net/sockstat")
80
+ File.open("/proc/net/sockstat", "r") do |ipv4|
81
+ @sockstat = ipv4.read
82
+ end
83
+
84
+ @udp4data = @sockstat.split
85
+ @udp4count = @udp4data[16]
86
+ end
87
+
88
+ if File.exists?("/proc/net/sockstat6")
89
+ File.open("/proc/net/sockstat6", "r") do |ipv6|
90
+ @sockstat6 = ipv6.read
91
+ end
92
+
93
+ @udp6data = @sockstat6.split
94
+ @udp6count = @udp6data[5]
95
+ end
96
+
97
+ @totaludpused = @udp4count.to_i + @udp6count.to_i
98
+ end
99
+
100
+ def uw_memused
101
+ if File.exists?("/proc/meminfo")
102
+ File.open("/proc/meminfo", "r") do |file|
103
+ @result = file.read
104
+ end
105
+ end
106
+
107
+ @memstat = @result.split("\n").collect{|x| x.strip}
108
+ @memtotal = @memstat[0].gsub(/[^0-9]/, "")
109
+ @memactive = @memstat[5].gsub(/[^0-9]/, "")
110
+ @memactivecalc = (@memactive.to_f * 100) / @memtotal.to_f
111
+ @memusagepercentage = @memactivecalc.round
112
+ end
113
+
114
+ # return hash of top ten proccesses by mem consumption
115
+ # example [["apache2", 12.0], ["passenger", 13.2]]
116
+ def uw_memtop
117
+ ps = `ps aux | awk '{print $11, $4}' | sort -k2nr | head -n 10`
118
+ array = []
119
+ ps.each_line do |line|
120
+ line = line.chomp.split(" ")
121
+ array << [line.first.gsub(/[\[\]]/, ""), line.last]
122
+ end
123
+ array
124
+ end
125
+
126
+ def uw_load
127
+ if File.exists?("/proc/loadavg")
128
+ File.open("/proc/loadavg", "r") do |file|
129
+ @loaddata = file.read
130
+ end
131
+
132
+ @load = @loaddata.split(/ /).first.to_f
133
+ end
134
+ end
135
+
136
+ def uw_bandrx
137
+
138
+ def bandrx
139
+
140
+ if File.exists?("/proc/net/dev")
141
+ File.open("/proc/net/dev", "r") do |file|
142
+ @result = file.read
143
+ end
144
+ end
145
+
146
+ @arrRows = @result.split("\n")
147
+
148
+ @arrEthLoRows = @arrRows.grep(/eth|lo/)
149
+
150
+ rowcount = (@arrEthLoRows.count - 1)
151
+
152
+ for i in (0..rowcount)
153
+ @arrEthLoRows[i] = @arrEthLoRows[i].gsub(/\s+/m, ' ').strip.split(" ")
154
+ end
155
+
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
163
+
164
+ columncount = (@arrColumns[0].count - 1)
165
+
166
+ @arrTotal = Array.new
167
+ for p in (0..columncount)
168
+ @arrTotal[p] = 0
169
+ end
170
+
171
+ for j in (0..columncount)
172
+ for k in (0..rowcount)
173
+ @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
174
+ end
175
+ end
176
+
177
+ @bandrxtx= @arrTotal
178
+ end
179
+
180
+ @new0 = bandrx
181
+ sleep 1
182
+ @new1 = bandrx
183
+
184
+ @bytesreceived = @new1[0].to_i - @new0[0].to_i
185
+ @bitsreceived = (@bytesreceived * 8)
186
+ @megabitsreceived = (@bitsreceived.to_f / 1024 / 1024).round(3)
187
+ end
188
+
189
+ def uw_bandtx
190
+
191
+ def bandtx
192
+
193
+ if File.exists?("/proc/net/dev")
194
+ File.open("/proc/net/dev", "r") do |file|
195
+ @result = file.read
196
+ end
197
+ end
198
+
199
+ @arrRows = @result.split("\n")
200
+
201
+ @arrEthLoRows = @arrRows.grep(/eth|lo/)
202
+
203
+ rowcount = (@arrEthLoRows.count - 1)
204
+
205
+ for i in (0..rowcount)
206
+ @arrEthLoRows[i] = @arrEthLoRows[i].gsub(/\s+/m, ' ').strip.split(" ")
207
+ end
208
+
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
216
+
217
+ columncount = (@arrColumns[0].count - 1)
218
+
219
+ @arrTotal = Array.new
220
+ for p in (0..columncount)
221
+ @arrTotal[p] = 0
222
+ end
223
+
224
+ for j in (0..columncount)
225
+ for k in (0..rowcount)
226
+ @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
227
+ end
228
+ end
229
+
230
+ @bandrxtx = @arrTotal
231
+ end
232
+
233
+ @new0 = bandtx
234
+ sleep 1
235
+ @new1 = bandtx
236
+
237
+ @bytestransmitted = @new1[1].to_i - @new0[1].to_i
238
+ @bitstransmitted = (@bytestransmitted * 8)
239
+ @megabitstransmitted = (@bitstransmitted.to_f / 1024 / 1024).round(3)
240
+ end
241
+
242
+ def uw_diskioreads
243
+
244
+ def diskio
245
+
246
+ if File.exists?("/proc/diskstats")
247
+ File.open("/proc/diskstats", "r") do |file|
248
+ @result = file.read
249
+ end
250
+ end
251
+
252
+ @arrRows = @result.split("\n")
253
+
254
+ rowcount = (@arrRows.count - 1)
255
+
256
+ for i in (0..rowcount)
257
+ @arrRows[i] = @arrRows[i].gsub(/\s+/m, ' ').strip.split(" ")
258
+ end
259
+
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
267
+
268
+ columncount = (@arrColumns[0].count - 1)
269
+
270
+ @arrTotal = Array.new
271
+ for p in (0..columncount)
272
+ @arrTotal[p] = 0
273
+ end
274
+
275
+ for j in (0..columncount)
276
+ for k in (0..rowcount)
277
+ @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
278
+ end
279
+ end
280
+
281
+ @diskiorw= @arrTotal
282
+ end
283
+
284
+ @new0 = diskio
285
+ sleep 1
286
+ @new1 = diskio
287
+
288
+ @diskreads = @new1[0].to_i - @new0[0].to_i
289
+ end
290
+
291
+ def uw_diskiowrites
292
+
293
+ def diskio
294
+
295
+ if File.exists?("/proc/diskstats")
296
+ File.open("/proc/diskstats", "r") do |file|
297
+ @result = file.read
298
+ end
299
+ end
300
+
301
+ @arrRows = @result.split("\n")
302
+
303
+ rowcount = (@arrRows.count - 1)
304
+
305
+ for i in (0..rowcount)
306
+ @arrRows[i] = @arrRows[i].gsub(/\s+/m, ' ').strip.split(" ")
307
+ end
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
316
+
317
+ columncount = (@arrColumns[0].count - 1)
318
+
319
+ @arrTotal = Array.new
320
+ for p in (0..columncount)
321
+ @arrTotal[p] = 0
322
+ end
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
328
+ end
329
+
330
+ @diskiorw= @arrTotal
331
+ end
332
+
333
+ @new0 = diskio
334
+ sleep 1
335
+ @new1 = diskio
336
+
337
+ @diskwrites = @new1[1].to_i - @new0[1].to_i
338
+ end
339
+ end
@@ -1,3 +1,3 @@
1
1
  module Usagewatch
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6.beta1"
3
3
  end
data/lib/usagewatch.rb CHANGED
@@ -2,317 +2,18 @@
2
2
 
3
3
  require "usagewatch/version"
4
4
 
5
- module Usagewatch
6
- def uw_diskused
7
- @df = `df`
8
- @parts = @df.split(" ").map { |s| s.to_i }
9
- @sum = 0
10
- for i in (9..@parts.size - 1).step(6) do
11
- @sum += @parts[i]
12
- end
13
- @round = @sum.round(2)
14
- @totaldiskused = ((@round/1024)/1024).round(2)
15
- end
16
-
17
- # Show the percentage of disk used.
18
- def uw_diskused_perc
19
- df = `df --total`
20
- df.split(" ").last.to_f.round(2)
21
- end
22
-
23
- def uw_cpuused
24
- @proc0 = File.readlines('/proc/stat').grep(/^cpu /).first.split(" ")
25
- sleep 1
26
- @proc1 = File.readlines('/proc/stat').grep(/^cpu /).first.split(" ")
27
-
28
- @proc0usagesum = @proc0[1].to_i + @proc0[2].to_i + @proc0[3].to_i
29
- @proc1usagesum = @proc1[1].to_i + @proc1[2].to_i + @proc1[3].to_i
30
- @procusage = @proc1usagesum - @proc0usagesum
31
-
32
- @proc0total = 0
33
- for i in (1..4) do
34
- @proc0total += @proc0[i].to_i
35
- end
36
- @proc1total = 0
37
- for i in (1..4) do
38
- @proc1total += @proc1[i].to_i
39
- end
40
- @proctotal = (@proc1total - @proc0total)
41
-
42
- @cpuusage = (@procusage.to_f / @proctotal.to_f)
43
- @cpuusagepercentage = (100 * @cpuusage).to_f.round(2)
44
- end
45
-
46
- def uw_tcpused
47
- if File.exists?("/proc/net/sockstat")
48
- File.open("/proc/net/sockstat", "r") do |ipv4|
49
- @sockstat = ipv4.read
50
- end
51
-
52
- @tcp4data = @sockstat.split
53
- @tcp4count = @tcp4data[5]
54
- end
55
-
56
- if File.exists?("/proc/net/sockstat6")
57
- File.open("/proc/net/sockstat6", "r") do |ipv6|
58
- @sockstat6 = ipv6.read
59
-
60
- end
61
-
62
- @tcp6data = @sockstat6.split
63
- @tcp6count = @tcp6data[2]
64
- end
65
-
66
- @totaltcpused = @tcp4count.to_i + @tcp6count.to_i
67
- end
68
-
69
- def uw_udpused
70
- if File.exists?("/proc/net/sockstat")
71
- File.open("/proc/net/sockstat", "r") do |ipv4|
72
- @sockstat = ipv4.read
73
- end
74
-
75
- @udp4data = @sockstat.split
76
- @udp4count = @udp4data[16]
77
- end
78
-
79
- if File.exists?("/proc/net/sockstat6")
80
- File.open("/proc/net/sockstat6", "r") do |ipv6|
81
- @sockstat6 = ipv6.read
82
- end
83
-
84
- @udp6data = @sockstat6.split
85
- @udp6count = @udp6data[5]
86
- end
87
-
88
- @totaludpused = @udp4count.to_i + @udp6count.to_i
89
- end
90
-
91
- def uw_memused
92
- if File.exists?("/proc/meminfo")
93
- File.open("/proc/meminfo", "r") do |file|
94
- @result = file.read
95
- end
96
- end
97
-
98
- @memstat = @result.split("\n").collect{|x| x.strip}
99
- @memtotal = @memstat[0].gsub(/[^0-9]/, "")
100
- @memactive = @memstat[5].gsub(/[^0-9]/, "")
101
- @memactivecalc = (@memactive.to_f * 100) / @memtotal.to_f
102
- @memusagepercentage = @memactivecalc.round
103
- end
104
-
105
- def uw_load
106
- if File.exists?("/proc/loadavg")
107
- File.open("/proc/loadavg", "r") do |file|
108
- @loaddata = file.read
109
- end
110
-
111
- @load = @loaddata.split(/ /).first.to_f
112
- end
113
- end
114
-
115
- def uw_bandrx
116
-
117
- def bandrx
118
-
119
- if File.exists?("/proc/net/dev")
120
- File.open("/proc/net/dev", "r") do |file|
121
- @result = file.read
122
- end
123
- end
124
-
125
- @arrRows = @result.split("\n")
126
-
127
- @arrEthLoRows = @arrRows.grep(/eth|lo/)
128
-
129
- rowcount = (@arrEthLoRows.count - 1)
130
-
131
- for i in (0..rowcount)
132
- @arrEthLoRows[i] = @arrEthLoRows[i].gsub(/\s+/m, ' ').strip.split(" ")
133
- end
134
-
135
- @arrColumns = Array.new
136
- for l in (0..rowcount)
137
- @temp = Array.new
138
- @temp[0] = @arrEthLoRows[l][1]
139
- @temp[1] = @arrEthLoRows[l][9]
140
- @arrColumns << @temp
141
- end
142
-
143
- columncount = (@arrColumns[0].count - 1)
144
-
145
- @arrTotal = Array.new
146
- for p in (0..columncount)
147
- @arrTotal[p] = 0
148
- end
149
-
150
- for j in (0..columncount)
151
- for k in (0..rowcount)
152
- @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
153
- end
154
- end
155
-
156
- @bandrxtx= @arrTotal
157
- end
158
-
159
- @new0 = bandrx
160
- sleep 1
161
- @new1 = bandrx
162
-
163
- @bytesreceived = @new1[0].to_i - @new0[0].to_i
164
- @bitsreceived = (@bytesreceived * 8)
165
- @megabitsreceived = (@bitsreceived.to_f / 1024 / 1024).round(3)
166
- end
167
-
168
- def uw_bandtx
169
-
170
- def bandtx
171
-
172
- if File.exists?("/proc/net/dev")
173
- File.open("/proc/net/dev", "r") do |file|
174
- @result = file.read
175
- end
176
- end
177
-
178
- @arrRows = @result.split("\n")
179
-
180
- @arrEthLoRows = @arrRows.grep(/eth|lo/)
181
-
182
- rowcount = (@arrEthLoRows.count - 1)
183
-
184
- for i in (0..rowcount)
185
- @arrEthLoRows[i] = @arrEthLoRows[i].gsub(/\s+/m, ' ').strip.split(" ")
186
- end
187
-
188
- @arrColumns = Array.new
189
- for l in (0..rowcount)
190
- @temp = Array.new
191
- @temp[0] = @arrEthLoRows[l][1]
192
- @temp[1] = @arrEthLoRows[l][9]
193
- @arrColumns << @temp
194
- end
195
-
196
- columncount = (@arrColumns[0].count - 1)
197
-
198
- @arrTotal = Array.new
199
- for p in (0..columncount)
200
- @arrTotal[p] = 0
201
- end
202
-
203
- for j in (0..columncount)
204
- for k in (0..rowcount)
205
- @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
206
- end
207
- end
208
-
209
- @bandrxtx = @arrTotal
210
- end
211
-
212
- @new0 = bandtx
213
- sleep 1
214
- @new1 = bandtx
215
-
216
- @bytestransmitted = @new1[1].to_i - @new0[1].to_i
217
- @bitstransmitted = (@bytestransmitted * 8)
218
- @megabitstransmitted = (@bitstransmitted.to_f / 1024 / 1024).round(3)
219
- end
220
-
221
- def uw_diskioreads
222
-
223
- def diskio
224
-
225
- if File.exists?("/proc/diskstats")
226
- File.open("/proc/diskstats", "r") do |file|
227
- @result = file.read
228
- end
229
- end
230
-
231
- @arrRows = @result.split("\n")
232
-
233
- rowcount = (@arrRows.count - 1)
234
-
235
- for i in (0..rowcount)
236
- @arrRows[i] = @arrRows[i].gsub(/\s+/m, ' ').strip.split(" ")
237
- end
238
-
239
- @arrColumns = Array.new
240
- for l in (0..rowcount)
241
- @temp = Array.new
242
- @temp[0] = @arrRows[l][3]
243
- @temp[1] = @arrRows[l][7]
244
- @arrColumns << @temp
245
- end
246
-
247
- columncount = (@arrColumns[0].count - 1)
248
-
249
- @arrTotal = Array.new
250
- for p in (0..columncount)
251
- @arrTotal[p] = 0
252
- end
253
-
254
- for j in (0..columncount)
255
- for k in (0..rowcount)
256
- @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
257
- end
258
- end
259
-
260
- @diskiorw= @arrTotal
261
- end
262
-
263
- @new0 = diskio
264
- sleep 1
265
- @new1 = diskio
266
-
267
- @diskreads = @new1[0].to_i - @new0[0].to_i
268
- end
269
-
270
- def uw_diskiowrites
271
-
272
- def diskio
273
-
274
- if File.exists?("/proc/diskstats")
275
- File.open("/proc/diskstats", "r") do |file|
276
- @result = file.read
277
- end
278
- end
279
-
280
- @arrRows = @result.split("\n")
281
-
282
- rowcount = (@arrRows.count - 1)
283
-
284
- for i in (0..rowcount)
285
- @arrRows[i] = @arrRows[i].gsub(/\s+/m, ' ').strip.split(" ")
286
- end
287
-
288
- @arrColumns = Array.new
289
- for l in (0..rowcount)
290
- @temp = Array.new
291
- @temp[0] = @arrRows[l][3]
292
- @temp[1] = @arrRows[l][7]
293
- @arrColumns << @temp
294
- end
295
-
296
- columncount = (@arrColumns[0].count - 1)
297
-
298
- @arrTotal = Array.new
299
- for p in (0..columncount)
300
- @arrTotal[p] = 0
301
- end
302
-
303
- for j in (0..columncount)
304
- for k in (0..rowcount)
305
- @arrTotal[j] = @arrColumns[k][j].to_i + @arrTotal[j]
306
- end
307
- end
5
+ os = RUBY_PLATFORM
6
+ text = "OS is not supported in this version."
7
+
8
+ if os.include? "darwin"
9
+ puts "Mac" + text
10
+ elsif os.include? "linux"
11
+ require "usagewatch/linux"
12
+ elsif os =~ /cygwin|mswin|mingw|bccwin|wince|emx/
13
+ puts "Windows" + text
14
+ else
15
+ puts "This" + text
16
+ end
308
17
 
309
- @diskiorw= @arrTotal
310
- end
311
18
 
312
- @new0 = diskio
313
- sleep 1
314
- @new1 = diskio
315
19
 
316
- @diskwrites = @new1[1].to_i - @new0[1].to_i
317
- end
318
- end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usagewatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.6.beta1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Phil Chen, Ruben Espinosa
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-18 00:00:00.000000000 Z
12
+ date: 2013-07-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -52,12 +52,14 @@ extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
54
  - .gitignore
55
+ - CHANGELOG
55
56
  - Gemfile
56
57
  - LICENSE.txt
57
58
  - README.md
58
59
  - Rakefile
59
60
  - examples/example.rb
60
61
  - lib/usagewatch.rb
62
+ - lib/usagewatch/linux.rb
61
63
  - lib/usagewatch/version.rb
62
64
  - usagewatch.gemspec
63
65
  homepage: https://github.com/nethacker/usagewatch
@@ -76,9 +78,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
78
  required_rubygems_version: !ruby/object:Gem::Requirement
77
79
  none: false
78
80
  requirements:
79
- - - ! '>='
81
+ - - ! '>'
80
82
  - !ruby/object:Gem::Version
81
- version: '0'
83
+ version: 1.3.1
82
84
  requirements: []
83
85
  rubyforge_project:
84
86
  rubygems_version: 1.8.23