riemann-babbler 0.2.8 → 0.3.0

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
@@ -7,7 +7,7 @@ logger:
7
7
 
8
8
  plugins:
9
9
 
10
- babbler:
10
+ dummy:
11
11
  service: keep alive
12
12
  interval: 1
13
13
 
@@ -21,6 +21,7 @@ module Riemann
21
21
  @configatron = $configatron
22
22
  @storage = Hash.new
23
23
  init
24
+ self.send run
24
25
  end
25
26
 
26
27
  def log
@@ -103,7 +104,7 @@ module Riemann
103
104
 
104
105
  # Переодически вызываемое действие
105
106
  def tick
106
- posted_hash = hash_to_post
107
+ posted_hash = collect
107
108
  posted_hash.each_key do |service|
108
109
  case service
109
110
  when Hash
@@ -1,11 +1,7 @@
1
1
  class Riemann::Babbler::Cpu
2
2
  include Riemann::Babbler
3
3
 
4
- def plugin
5
- options.plugins.cpu
6
- end
7
-
8
- def cpu
4
+ def collect
9
5
  cpu = File.read('/proc/stat')
10
6
  cpu[/cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/]
11
7
  u2, n2, s2, i2 = [$1, $2, $3, $4].map { |e| e.to_i }
@@ -18,18 +14,7 @@ class Riemann::Babbler::Cpu
18
14
  end
19
15
 
20
16
  @old_cpu = [u2, n2, s2, i2]
21
- fraction
22
- end
23
-
24
- def tick
25
- current_state = cpu
26
- report({
27
- :service => plugin.service,
28
- :state => state(current_state),
29
- :metric => current_state
30
- })
17
+ {"cpu" => fraction}
31
18
  end
32
19
 
33
20
  end
34
-
35
- Riemann::Babbler::Cpu.run
@@ -0,0 +1,10 @@
1
+ class Riemann::Babbler::Dummy
2
+ include Riemann::Babbler
3
+
4
+ def collect
5
+ {
6
+ :state => 'ok'
7
+ }
8
+ end
9
+
10
+ end
@@ -1,24 +1,10 @@
1
1
  class Riemann::Babbler::La
2
2
  include Riemann::Babbler
3
3
 
4
- def plugin
5
- options.plugins.la
6
- end
7
-
8
- def la
9
- File.read('/proc/loadavg').split(/\s+/)[2].to_f
10
- end
11
-
12
- def tick
13
- current_state = la
14
- status = {
15
- :service => plugin.service,
16
- :state => state(current_state),
17
- :metric => current_state
18
- }
19
- report status
4
+ def collect
5
+ {
6
+ "la_1" => File.read('/proc/loadavg').split(/\s+/)[2].to_f
7
+ }
20
8
  end
21
9
 
22
10
  end
23
-
24
- Riemann::Babbler::La.run
@@ -1,10 +1,6 @@
1
1
  class Riemann::Babbler::Memory
2
2
  include Riemann::Babbler
3
3
 
4
- def plugin
5
- options.plugins.memory
6
- end
7
-
8
4
  def memory
9
5
  m = File.read('/proc/meminfo').split(/\n/).inject({}) { |info, line|
10
6
  x = line.split(/:?\s+/)
@@ -38,5 +34,3 @@ class Riemann::Babbler::Memory
38
34
  end
39
35
 
40
36
  end
41
-
42
- Riemann::Babbler::Memory.run
@@ -2,30 +2,22 @@ class Riemann::Babbler::Net
2
2
  include Riemann::Babbler
3
3
 
4
4
  WORDS = ['rx bytes',
5
- 'rx packets',
6
- 'rx errs',
7
- 'rx drop',
8
- 'rx fifo',
9
- 'rx frame',
10
- 'rx compressed',
11
- 'rx multicast',
12
- 'tx bytes',
13
- 'tx packets',
14
- 'tx drops',
15
- 'tx fifo',
16
- 'tx colls',
17
- 'tx carrier',
18
- 'tx compressed']
5
+ 'rx packets',
6
+ 'rx errs',
7
+ 'rx drop',
8
+ 'rx fifo',
9
+ 'rx frame',
10
+ 'rx compressed',
11
+ 'rx multicast',
12
+ 'tx bytes',
13
+ 'tx packets',
14
+ 'tx drops',
15
+ 'tx fifo',
16
+ 'tx colls',
17
+ 'tx carrier',
18
+ 'tx compressed']
19
19
 
20
- def plugin
21
- options.plugins.net
22
- end
23
-
24
- def init
25
- @old_status = Hash.new
26
- end
27
-
28
- def net
20
+ def collect
29
21
  f = File.read('/proc/net/dev')
30
22
  status = Hash.new
31
23
  f.split("\n").each do |line|
@@ -43,18 +35,5 @@ class Riemann::Babbler::Net
43
35
  status
44
36
  end
45
37
 
46
- def tick
47
- status = net
48
- status.each_key do |service|
49
- #next if status[service] == 0
50
- report({
51
- :service => service,
52
- :metric => status[service],
53
- :is_diff => true
54
- })
55
- end
56
- end
57
-
58
38
  end
59
39
 
60
- Riemann::Babbler::Net.run
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  module Babbler
3
- VERSION = '0.2.8'
3
+ VERSION = '0.3.0'
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.2.8
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -140,9 +140,9 @@ files:
140
140
  - config.yml
141
141
  - lib/deep_merge.rb
142
142
  - lib/riemann/babbler/plugin.rb
143
- - lib/riemann/babbler/plugins/babbler.rb
144
143
  - lib/riemann/babbler/plugins/cpu.rb
145
144
  - lib/riemann/babbler/plugins/disk.rb
145
+ - lib/riemann/babbler/plugins/dummy.rb
146
146
  - lib/riemann/babbler/plugins/la.rb
147
147
  - lib/riemann/babbler/plugins/memory.rb
148
148
  - lib/riemann/babbler/plugins/net.rb
@@ -1,18 +0,0 @@
1
- class Riemann::Babbler::Dummy
2
- include Riemann::Babbler
3
-
4
- def plugin
5
- options.plugins.babbler
6
- end
7
-
8
- def tick
9
- status = {
10
- :service => plugin.service,
11
- :state => 'ok'
12
- }
13
- report status
14
- end
15
-
16
- end
17
-
18
- Riemann::Babbler::Dummy.run