riemann-babbler 1.3.4 → 1.3.5

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/config.yml CHANGED
@@ -67,3 +67,6 @@ plugins:
67
67
 
68
68
  runit:
69
69
  service: runit
70
+
71
+ diskstat:
72
+ service: diskstat
@@ -0,0 +1,44 @@
1
+ class Riemann::Babbler::Diskstat < Riemann::Babbler
2
+
3
+ WORDS = [
4
+ 'reads reqs',
5
+ 'reads merged',
6
+ 'reads sector',
7
+ 'reads time',
8
+ 'writes reqs',
9
+ 'writes merged',
10
+ 'writes sector',
11
+ 'writes time',
12
+ 'io reqs',
13
+ 'io time',
14
+ 'io weighted'
15
+ ]
16
+
17
+ def init
18
+ plugin.set_default(:service, 'diskstat')
19
+ plugin.set_default(:interval, 60)
20
+ plugin.set_default(:filter, ['reads reqs', 'writes reqs'])
21
+ end
22
+
23
+ def collect
24
+ status = Array.new
25
+ f = File.read('/proc/diskstats')
26
+ state = f.split("\n").reject { |d| d =~ /(ram|loop| md| dm| sr)/ }.inject({}) do |s, line|
27
+ if line =~ /^(?:\s+\d+){2}\s+([\w\d]+) (.*)$/
28
+ dev = $1
29
+
30
+ WORDS.map do |service|
31
+ next unless plugin.filter.include?(service) #TODO hardcode
32
+ "#{plugin.service} #{dev} #{service}"
33
+ end.zip(
34
+ $2.split(/\s+/).map { |str| str.to_i }
35
+ ).each do |service, value|
36
+ next if service.nil? #TODO hardcode
37
+ status << { :service => service, :metric => value, :as_diff => true}
38
+ end
39
+ end
40
+ end
41
+ status
42
+ end
43
+
44
+ end
@@ -0,0 +1,32 @@
1
+ require 'net/http'
2
+ require 'csv'
3
+
4
+ class Riemann::Babbler::Haproxy < Riemann::Babbler
5
+
6
+ def init
7
+ plugin.set_default(:service, 'haproxy')
8
+ plugin.set_default(:interval, 60)
9
+ plugin.set_default(:url, 'http://user:password@localhost/stats;csv')
10
+ end
11
+
12
+ def collect
13
+ status = Array.new
14
+ content = rest_get(plugin.url)
15
+ csv = CSV.parse(content.split("# ")[1], { :headers => true })
16
+ csv.each do |row|
17
+ row = row.to_hash
18
+ ns = "haproxy #{row['pxname']} #{row['svname']}"
19
+ row.each do |property, metric|
20
+ unless (property.nil? || property == 'pxname' || property == 'svname')
21
+ status << {
22
+ :service => "#{ns} #{property}",
23
+ :metric => metric.to_f,
24
+ :state => (['UP', 'OPEN'].include?(row['status']) ? 'ok' : 'critical')
25
+ }
26
+ end
27
+ end
28
+ end
29
+ status
30
+ end
31
+
32
+ end
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '1.3.4'
3
+ VERSION = '1.3.5'
4
4
  end
5
5
  end
@@ -62,14 +62,13 @@ module Riemann
62
62
 
63
63
  def report_with_diff(event)
64
64
  current_metric = event[:metric]
65
- if @storage.has_key?(event[:service])
66
- unless current_metric + @storage[event[:service]] > 2**64
67
- event[:metric] = current_metric - @storage[event[:service]]
68
- end unless @storage[event[:service]].nil?
65
+ old_metric = @storage[event[:service]]
66
+ if old_metric && current_metric + old_metric < 2**64
67
+ event[:metric] = current_metric - old_metric
68
+ event.delete(:as_diff)
69
+ report(event)
69
70
  end
70
- @storage[ event[:service] ] = current_metric
71
- event.delete(:as_diff)
72
- report(event)
71
+ @storage[event[:service]] = current_metric
73
72
  end
74
73
 
75
74
  def get_hostname
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-babbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-10 00:00:00.000000000 Z
12
+ date: 2013-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riemann-client
@@ -193,9 +193,11 @@ files:
193
193
  - lib/riemann/babbler/plugins/cpu_fan.rb
194
194
  - lib/riemann/babbler/plugins/cpu_temp.rb
195
195
  - lib/riemann/babbler/plugins/disk.rb
196
+ - lib/riemann/babbler/plugins/diskstat.rb
196
197
  - lib/riemann/babbler/plugins/dummy.rb
197
198
  - lib/riemann/babbler/plugins/exim4.rb
198
199
  - lib/riemann/babbler/plugins/find_files.rb
200
+ - lib/riemann/babbler/plugins/haproxy.rb
199
201
  - lib/riemann/babbler/plugins/http.rb
200
202
  - lib/riemann/babbler/plugins/la.rb
201
203
  - lib/riemann/babbler/plugins/mdadm.rb