heartbeat-client 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/heartbeat-client.rb +22 -19
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -109,11 +109,11 @@ class Heartbeat
109
109
 
110
110
  if File.exists?('/tmp/mongodb.out')
111
111
  File.open("/tmp/mongodb.out", "r") do |infile|
112
- counter = 0
112
+ counter = 0; lines = []
113
113
  while (line = infile.gets)
114
- mongodb_status(mongodb, line) if counter == 2
115
- counter += 1
114
+ lines << line
116
115
  end
116
+ mongodb_status(mongodb, lines)
117
117
  end
118
118
  end
119
119
 
@@ -221,22 +221,25 @@ class Heartbeat
221
221
  end
222
222
  end
223
223
 
224
- def self.mongodb_status(mongodb, str)
225
- if (mo = str.split(' '))
226
- mo.each_with_index do |moa, index|
227
- mongodb['insert'] = moa.strip.to_i if index == 0
228
- mongodb['query'] = moa.strip.to_i if index == 1
229
- mongodb['update'] = moa.strip.to_i if index == 2
230
- mongodb['delete'] = moa.strip.to_i if index == 3
231
- mongodb['getmore'] = moa.strip.to_i if index == 4
232
- mongodb['command'] = moa.strip.to_i if index == 5
233
- mongodb['flushes'] = moa.strip.to_i if index == 6
234
- mongodb['mapped'] = moa.strip if index == 7
235
- mongodb['vsize'] = moa.strip if index == 8
236
- mongodb['res'] = moa.strip if index == 9
237
- mongodb['netIn'] = moa.strip if index == 14
238
- mongodb['netOut'] = moa.strip if index == 15
239
- mongodb['conn'] = moa.strip if index == 16
224
+ def self.mongodb_status(mongodb, lines)
225
+ if lines and lines.size == 3
226
+ header = lines[1].gsub('%', '').gsub('miss', '').split(' '); mo = lines[2].split(' ')
227
+ if header and mo and header.size == mo.size
228
+ header.each_with_index do |h, index|
229
+ mongodb['insert'] = mo[index].strip.to_i if h == 'insert'
230
+ mongodb['query'] = mo[index].to_i if h == 'query'
231
+ mongodb['update'] = mo[index].strip.to_i if h == 'update'
232
+ mongodb['delete'] = mo[index].strip.to_i if h == 'delete'
233
+ mongodb['getmore'] = mo[index].strip.to_i if h == 'getmore'
234
+ mongodb['command'] = mo[index].strip.to_i if h == 'command'
235
+ mongodb['flushes'] = mo[index].strip.to_i if h == 'flushes'
236
+ mongodb['mapped'] = mo[index].strip if h == 'mapped'
237
+ mongodb['vsize'] = mo[index].strip if h == 'vsize'
238
+ mongodb['res'] = mo[index].strip if h == 'res'
239
+ mongodb['netIn'] = mo[index].strip if h == 'netIn'
240
+ mongodb['netOut'] = mo[index].strip if h == 'netOut'
241
+ mongodb['conn'] = mo[index].strip if h == 'conn'
242
+ end
240
243
  end
241
244
  end
242
245
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heartbeat-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Oliver Kiessler