riemann-babbler 0.9.1 → 0.9.2

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.
@@ -0,0 +1,19 @@
1
+ class Riemann::Babbler::Cpufan < Riemann::Babbler
2
+
3
+ def init
4
+ plugin.set_default(:service, 'cpufan')
5
+ plugin.set_default(:cmd, '/usr/bin/sensors | grep "CPU FAN Speed:" | awk "{print $4}"')
6
+ plugin.set_default(:interval, 60)
7
+ plugin.states.set_default(:warning, 2000)
8
+ plugin.states.set_default(:critical, 3000)
9
+ end
10
+
11
+ def run_plugin
12
+ File.exists? '/usr/bin/sensors'
13
+ end
14
+
15
+ def collect
16
+ { :service => plugin.service, :metric => shell(plugin.cmd).to_i, :description => "CPU Fan Speed" }
17
+ end
18
+
19
+ end
@@ -0,0 +1,20 @@
1
+ class Riemann::Babbler::Cputemp < Riemann::Babbler
2
+
3
+ def init
4
+ plugin.set_default(:service, 'cputemp')
5
+ plugin.set_default(:interval, 60)
6
+ plugin.set_default(:cmd, '/usr/bin/sensors | grep "CPU Temperature:" | awk "{print $3}" | cut -c2-3')
7
+ plugin.states.set_default(:warning, 60)
8
+ plugin.states.set_default(:critical, 80)
9
+ end
10
+
11
+ def run_plugin
12
+ File.exists? '/usr/bin/sensors'
13
+ end
14
+
15
+ def collect
16
+ { :service => plugin.service, :metric => shell(plugin.cmd).to_i, :description => "CPU Temperature" }
17
+ end
18
+
19
+ end
20
+
@@ -0,0 +1,19 @@
1
+ class Riemann::Babbler::Exim4 < Riemann::Babbler
2
+
3
+ def init
4
+ plugin.set_default(:service, 'exim4')
5
+ plugin.set_default(:cmd, '/usr/sbin/exim -bpc')
6
+ plugin.set_default(:interval, 60)
7
+ plugin.states.set_default(:warning, 5)
8
+ plugin.states.set_default(:critical, 20)
9
+ end
10
+
11
+ def run_plugin
12
+ File.exists? '/usr/sbin/exim'
13
+ end
14
+
15
+ def collect
16
+ { :service => plugin.service, :metric => shell(plugin.cmd).to_i, :description => "Exim4: count frozen mails" }
17
+ end
18
+
19
+ end
@@ -0,0 +1,25 @@
1
+ class Riemann::Babbler::Mdadm < Riemann::Babbler
2
+
3
+ def init
4
+ plugin.set_default(:service, 'mdadm')
5
+ plugin.set_default(:interval, 60)
6
+ plugin.states.set_default(:critical, 1)
7
+ end
8
+
9
+ def run_plugin
10
+ File.exists? '/proc/mdstat'
11
+ end
12
+
13
+ def collect
14
+ file = File.read('/proc/mdstat').split("\n")
15
+ status = Array.new
16
+ file.each_with_index do |line, index|
17
+ next unless line.include? "_"
18
+ device = file[index-1].split(":")[0].strip
19
+ status << { :service => plugin.service + " #{device}", :metric => 1, :description => "mdadm failed device #{device}" }
20
+ end
21
+ status
22
+ end
23
+
24
+ end
25
+
@@ -0,0 +1,19 @@
1
+ class Riemann::Babbler::MegaCli < Riemann::Babbler
2
+
3
+ def init
4
+ plugin.set_default(:service, 'megacli')
5
+ plugin.set_default(:cmd, 'megacli -AdpAllInfo -aAll -NoLog | awk -F": " \'/Virtual Drives/ { getline; print $2; }\'')
6
+ plugin.set_default(:interval, 60)
7
+ plugin.states.set_default(:critical, 1)
8
+ end
9
+
10
+ def run_plugin
11
+ File.exists? '/usr/bin/megacli'
12
+ end
13
+
14
+ def collect
15
+ {:service => plugin.service, :metric => shell(plugin.cmd).to_i, :description => "MegaCli status}" }
16
+ end
17
+
18
+ end
19
+
@@ -0,0 +1,42 @@
1
+ class Riemann::Babbler::Nginx < Riemann::Babbler
2
+
3
+ NGINX_STATUS_1 = [
4
+ 'accepts',
5
+ 'handled',
6
+ 'requests'
7
+ ]
8
+
9
+ NGINX_STATUS_2 = [
10
+ 'reading',
11
+ 'writing',
12
+ 'waiting'
13
+ ]
14
+
15
+ def init
16
+ plugin.set_default(:service, 'nginx')
17
+ plugin.set_default(:status_file, '/etc/nginx/sites-enabled/status')
18
+ plugin.set_default(:status_url, 'http://127.0.0.1:11311/status')
19
+ plugin.set_default(:interval, 1)
20
+ end
21
+
22
+ def run_plugin
23
+ File.exists? plugin.status_file
24
+ end
25
+
26
+ def collect
27
+ status = Array.new
28
+ lines = rest_get(plugin.status_url).split("\n")
29
+ lines[2].scan(/\d+/).each_with_index do |value, index|
30
+ status << { :service => plugin.service + " #{NGINX_STATUS_1[index]}", :metric => value.to_i, :as_diff => true }
31
+ end
32
+ # line[0]: Active connections: XXXX
33
+ status << { :service => plugin.service + " active", :metric => lines[0].split(":")[1].strip.to_i }
34
+ # lines[3]: Reading: 0 Writing: 1 Waiting: 0
35
+ lines[3].scan(/\d+/).each_with_index do |value, index|
36
+ status << { :service => plugin.service + " #{NGINX_STATUS_2[index]}", :metric => value }
37
+ end
38
+ status
39
+ end
40
+
41
+ end
42
+
@@ -0,0 +1,29 @@
1
+ class Riemann::Babbler::Runit < Riemann::Babbler
2
+
3
+ def init
4
+ plugin.set_default(:service, 'runit')
5
+ plugin.set_default(:not_monit, [])
6
+ plugin.set_default(:interval, 60)
7
+ end
8
+
9
+ def run_plugin
10
+ Dir.exists? '/etc/service'
11
+ end
12
+
13
+ def read_run_status
14
+ status = Array.new
15
+ Dir.glob('/etc/service/*').each do |srv|
16
+ next if plugin.not_monit.include? srv
17
+ human_srv = ' ' + srv.gsub(/\/etc\/service\//,"")
18
+ unless File.read( File.join(srv, 'supervise', 'stat') ).strip == 'run'
19
+ status << {:service => plugin.service + human_srv , :state => 'critical', :description => "runit service #{human_srv} not running"}
20
+ end
21
+ end
22
+ status
23
+ end
24
+
25
+ def collect
26
+ read_run_status
27
+ end
28
+
29
+ end
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '0.9.1'
3
+ VERSION = '0.9.2'
4
4
  end
5
5
  end
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: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -159,11 +159,18 @@ files:
159
159
  - lib/riemann/babbler/plugin.rb
160
160
  - lib/riemann/babbler/plugin_helpers.rb
161
161
  - lib/riemann/babbler/plugins/cpu.rb
162
+ - lib/riemann/babbler/plugins/cpufan.rb
163
+ - lib/riemann/babbler/plugins/cputemp.rb
162
164
  - lib/riemann/babbler/plugins/disk.rb
163
165
  - lib/riemann/babbler/plugins/dummy.rb
166
+ - lib/riemann/babbler/plugins/exim4.rb
164
167
  - lib/riemann/babbler/plugins/la.rb
168
+ - lib/riemann/babbler/plugins/mdadm.rb
169
+ - lib/riemann/babbler/plugins/megacli.rb
165
170
  - lib/riemann/babbler/plugins/memory.rb
166
171
  - lib/riemann/babbler/plugins/net.rb
172
+ - lib/riemann/babbler/plugins/nginx.rb
173
+ - lib/riemann/babbler/plugins/runit.rb
167
174
  - lib/riemann/version.rb
168
175
  - lib/start_helpers.rb
169
176
  - riemann-babbler.gemspec
@@ -182,7 +189,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
189
  version: '0'
183
190
  segments:
184
191
  - 0
185
- hash: 3251853057915452566
192
+ hash: 2173667543562189503
186
193
  required_rubygems_version: !ruby/object:Gem::Requirement
187
194
  none: false
188
195
  requirements: