riemann-babbler 0.4.1 → 0.4.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.
- data/lib/riemann/babbler/plugin.rb +45 -45
- data/lib/riemann/babbler/plugins/disk.rb +3 -3
- data/lib/riemann/version.rb +1 -1
- metadata +3 -3
@@ -28,11 +28,25 @@ module Riemann
|
|
28
28
|
run
|
29
29
|
end
|
30
30
|
|
31
|
+
# Доступ к конфигу определенного плагина
|
32
|
+
def plugin
|
33
|
+
plugin_name = self.class.name.split( "::" ).last.gsub( /(\p{Lower})(\p{Upper})/, "\\1_\\2" ).downcase
|
34
|
+
options.plugins.send plugin_name
|
35
|
+
end
|
36
|
+
|
31
37
|
def options
|
32
38
|
@configatron
|
33
39
|
end
|
34
40
|
alias :opts :options
|
35
41
|
|
42
|
+
def riemann
|
43
|
+
@riemann ||= Riemann::Client.new(
|
44
|
+
:host => options.riemann.host,
|
45
|
+
:port => options.riemann.port
|
46
|
+
)
|
47
|
+
end
|
48
|
+
alias :r :riemann
|
49
|
+
|
36
50
|
def report(event)
|
37
51
|
report_with_diff(event) and return if event[:as_diff]
|
38
52
|
event[:state] = state(event[:metric]) unless plugin.states.critical.nil?
|
@@ -66,26 +80,16 @@ module Riemann
|
|
66
80
|
true
|
67
81
|
end
|
68
82
|
|
69
|
-
#
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
report({
|
75
|
-
:service => plugin.service,
|
76
|
-
:state => 'critical',
|
77
|
-
:description => "Response from #{url}"
|
78
|
-
})
|
79
|
-
end
|
83
|
+
# Переодически вызываемое действие
|
84
|
+
def tick
|
85
|
+
posted_array = collect
|
86
|
+
posted_array = posted_array.class == Array ? posted_array : [ posted_array ]
|
87
|
+
posted_array.each { |event| report event }
|
80
88
|
end
|
81
89
|
|
82
|
-
|
83
|
-
|
84
|
-
:host => options.riemann.host,
|
85
|
-
:port => options.riemann.port
|
86
|
-
)
|
90
|
+
# Plugin init
|
91
|
+
def init
|
87
92
|
end
|
88
|
-
alias :r :riemann
|
89
93
|
|
90
94
|
def run
|
91
95
|
# выйти если run_plugin не равен true
|
@@ -102,21 +106,20 @@ module Riemann
|
|
102
106
|
end
|
103
107
|
end
|
104
108
|
|
105
|
-
#
|
106
|
-
def
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
def init
|
109
|
+
# хелпер, описание статуса
|
110
|
+
def state(my_state)
|
111
|
+
unless plugin.states.warning.nil?
|
112
|
+
case
|
113
|
+
when my_state.between?(plugin.states.warning, plugin.states.critical)
|
114
|
+
'warning'
|
115
|
+
when my_state > plugin.states.warning
|
116
|
+
'critical'
|
117
|
+
else
|
118
|
+
'ok'
|
119
|
+
end
|
120
|
+
else
|
121
|
+
my_state >= plugin.states.critical ? 'critical' : 'ok'
|
122
|
+
end
|
120
123
|
end
|
121
124
|
|
122
125
|
# хэлпер для парса stdout+stderr и exit status
|
@@ -142,19 +145,16 @@ module Riemann
|
|
142
145
|
end
|
143
146
|
end
|
144
147
|
|
145
|
-
#
|
146
|
-
def
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
'critical'
|
153
|
-
|
154
|
-
|
155
|
-
end
|
156
|
-
else
|
157
|
-
my_state >= plugin.states.critical ? 'critical' : 'ok'
|
148
|
+
# http rest
|
149
|
+
def rest_get(url)
|
150
|
+
begin
|
151
|
+
RestClient.get url
|
152
|
+
rescue
|
153
|
+
report({
|
154
|
+
:service => plugin.service,
|
155
|
+
:state => 'critical',
|
156
|
+
:description => "Response from #{url}"
|
157
|
+
})
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
@@ -24,10 +24,10 @@ class Riemann::Babbler::Disk < Riemann::Babbler
|
|
24
24
|
disk = Array.new
|
25
25
|
monit_points.each do |point|
|
26
26
|
point_stat = Filesystem.stat point
|
27
|
-
human_point = point == "/" ? "/root" : point
|
27
|
+
human_point = point == "/" ? " /root" : " " + point
|
28
28
|
human_point.gsub!(/^\//, "").gsub!(/\//, "_")
|
29
|
-
disk << { :service => human_point + " block", :metric => 1 - point_stat.blocks_available.to_f/point_stat.blocks }
|
30
|
-
disk << { :service => human_point + " inode", :metric => 1 - point_stat.files_available.to_f/point_stat.files }
|
29
|
+
disk << { :service => plugin.service + human_point + " block", :metric => 1 - point_stat.blocks_available.to_f/point_stat.blocks }
|
30
|
+
disk << { :service => plugin.service + human_point + " inode", :metric => 1 - point_stat.files_available.to_f/point_stat.files }
|
31
31
|
end
|
32
32
|
disk
|
33
33
|
end
|
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.2
|
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-04-
|
12
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: riemann-client
|
@@ -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: 2894994163189052610
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
152
|
none: false
|
153
153
|
requirements:
|