riemann-babbler 0.4.0 → 0.4.1
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/README.md +59 -29
- data/bin/riemann-babbler +2 -2
- data/lib/riemann/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
###
|
1
|
+
### Install
|
2
2
|
```
|
3
3
|
gem install riemann-babbler
|
4
4
|
````
|
5
5
|
|
6
|
-
###
|
6
|
+
### Use
|
7
7
|
```
|
8
8
|
$ riemann-babbler --help
|
9
9
|
Riemann-babbler is plugin manager for riemann-tools.
|
@@ -16,55 +16,85 @@ where [options] are:
|
|
16
16
|
--help, -h: Show this message
|
17
17
|
```
|
18
18
|
|
19
|
-
###
|
20
|
-
Bubbler
|
19
|
+
### Config
|
20
|
+
Bubbler load main config and merge custom plugins
|
21
21
|
```yaml
|
22
22
|
riemann:
|
23
|
-
host: riemann.host
|
24
|
-
port: 5555
|
25
|
-
tags:
|
23
|
+
host: riemann.host
|
24
|
+
port: 5555
|
25
|
+
tags:
|
26
26
|
- prod
|
27
27
|
- web
|
28
|
-
suffix: ".testing"
|
28
|
+
suffix: ".testing"
|
29
|
+
preffix: "previx"
|
29
30
|
|
30
31
|
plugins:
|
31
32
|
dirs:
|
32
|
-
- /etc/riemann/plugins #
|
33
|
+
- /etc/riemann/plugins # load all rb files in dirs
|
33
34
|
files:
|
34
|
-
- /var/lib/riemann-plugins/test.rb #
|
35
|
+
- /var/lib/riemann-plugins/test.rb # and custom load somefile
|
35
36
|
```
|
36
|
-
#####
|
37
|
+
##### Config yml for custom plugin
|
37
38
|
```yaml
|
38
39
|
plugins:
|
39
40
|
awesome_plugin:
|
40
|
-
service: some critical service
|
41
|
-
interval: 1 #
|
41
|
+
service: some critical service
|
42
|
+
interval: 1 # (in sec)
|
42
43
|
states:
|
43
|
-
warning: 80
|
44
|
-
critical: 90
|
45
|
-
|
44
|
+
warning: 80
|
45
|
+
critical: 90
|
46
|
+
url: "http://127.0.0.1:11311/status"
|
46
47
|
```
|
47
48
|
|
48
|
-
###
|
49
|
+
### Custom Plugin
|
50
|
+
#### Example 1
|
49
51
|
```ruby
|
50
|
-
class Riemann::Babbler::Awesomeplugin
|
51
|
-
include Riemann::Babbler
|
52
|
+
class Riemann::Babbler::Awesomeplugin < Riemann::Babbler
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
def init
|
55
|
+
plugin.set_default(:service, 'awesome plugin' )
|
56
|
+
plugin.set_default(:interval, 1 )
|
57
|
+
plugin.set_default(:url, 'http://127.0.0.1:11311/status')
|
56
58
|
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
60
|
+
def collect
|
61
|
+
state = rest_get plugin.url == "OK" ? 'ok' : 'critical' # rest_get - helper
|
62
|
+
{
|
61
63
|
:service => plugin.service,
|
62
|
-
:state =>
|
64
|
+
:state => state
|
63
65
|
}
|
64
|
-
|
66
|
+
end
|
67
|
+
end
|
68
|
+
```
|
69
|
+
#### Example 2
|
70
|
+
```ruby
|
71
|
+
class Riemann::Babbler::Awesomeplugin < Riemann::Babbler
|
72
|
+
|
73
|
+
def init
|
74
|
+
plugin.set_default(:service, 'awesome plugin' )
|
75
|
+
plugin.set_default(:interval, 1 )
|
76
|
+
plugin.states.set_default(:warning, 5)
|
77
|
+
plugin.states.set_default(:critical, 20)
|
78
|
+
plugin.set_default(:cmd1, 'cat /file/status | grep somevalue')
|
79
|
+
plugin.set_default(:cmd2, 'cat /file/status | grep somevalue2')
|
80
|
+
end
|
81
|
+
|
82
|
+
def run_plugin # run plugin if
|
83
|
+
File.exists? '/file/status'
|
65
84
|
end
|
66
85
|
|
86
|
+
def collect # may return Array
|
87
|
+
status = []
|
88
|
+
status << {
|
89
|
+
:service => plugin.service + " cmd1",
|
90
|
+
:metric => shell plugin.cmd2 # shell - helper
|
91
|
+
}
|
92
|
+
status << {
|
93
|
+
:service => plugin.service + " cmd2",
|
94
|
+
:metric => shell plugin.cmd2, # shell - helper
|
95
|
+
:as_diff => true # report as diffencial: current - last
|
96
|
+
}
|
97
|
+
status
|
98
|
+
end
|
67
99
|
end
|
68
|
-
# обязательный вызов
|
69
|
-
Riemann::Babbler::Awesomeplugin.run
|
70
100
|
```
|
data/bin/riemann-babbler
CHANGED
@@ -30,7 +30,7 @@ logger = Logger.new(STDOUT)
|
|
30
30
|
config_file = if File.exist?( opts[:config] )
|
31
31
|
YAML.load_file( opts[:config] ).to_hash
|
32
32
|
else
|
33
|
-
|
33
|
+
logger.error "Can't load config file #{opts[:config]}"
|
34
34
|
Hash.new
|
35
35
|
end
|
36
36
|
|
@@ -70,7 +70,7 @@ plugin_threads = Riemann::Babbler.registered_plugins.map do |plugin|
|
|
70
70
|
}
|
71
71
|
end
|
72
72
|
|
73
|
-
Signal.trap "
|
73
|
+
Signal.trap "USR2" do # перехватываем сообщение (на будущее)
|
74
74
|
plugin_threads.each( &:kill )
|
75
75
|
end
|
76
76
|
|
data/lib/riemann/version.rb
CHANGED
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.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version: '0'
|
148
148
|
segments:
|
149
149
|
- 0
|
150
|
-
hash:
|
150
|
+
hash: -886395468252800895
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
152
|
none: false
|
153
153
|
requirements:
|