flapjack 0.6.34 → 0.6.35
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/flapjack-nagios-receiver +18 -7
- data/lib/flapjack/version.rb +1 -1
- metadata +1 -1
@@ -76,11 +76,24 @@ def process_input
|
|
76
76
|
begin
|
77
77
|
while line = @fifo.gets
|
78
78
|
skip unless line
|
79
|
-
|
79
|
+
split_line = line.split("\t")
|
80
|
+
|
81
|
+
object_type, timestamp, entity, check, state, check_time, check_latency, check_output, check_perfdata = split_line
|
82
|
+
|
83
|
+
case
|
84
|
+
when split_line.length != 9
|
85
|
+
puts "ERROR - rejecting this line as it doesn't split into 9 tab separated strings: [#{line}]"
|
86
|
+
next
|
87
|
+
when (timestamp !~ /^\d+$/)
|
88
|
+
puts "ERROR - rejecting this line as second string doesn't look like a timestamp: [#{line}]"
|
89
|
+
next
|
90
|
+
when (not ((object_type == '[HOSTPERFDATA]') or (object_type == '[SERVICEPERFDATA]')))
|
91
|
+
puts "ERROR - rejecting this line as first string is neither '[HOSTPERFDATA]' nor '[SERVICEPERFDATA]': [#{line}]"
|
92
|
+
next
|
93
|
+
end
|
94
|
+
|
80
95
|
puts "#{object_type}, #{timestamp}, #{entity}, #{check}, #{state}, #{check_output}"
|
81
|
-
|
82
|
-
next unless timestamp =~ /^\d+$/
|
83
|
-
next unless (object_type == '[HOSTPERFDATA]') or (object_type == '[SERVICEPERFDATA]')
|
96
|
+
|
84
97
|
state = 'ok' if state.downcase == 'up'
|
85
98
|
state = 'critical' if state.downcase == 'down'
|
86
99
|
event = {
|
@@ -95,15 +108,13 @@ def process_input
|
|
95
108
|
end
|
96
109
|
rescue Redis::CannotConnectError
|
97
110
|
puts "Error, unable to to connect to the redis server (#{$!})"
|
98
|
-
rescue EOFError
|
99
|
-
puts "Error - end of file reached when reading from the named pipe. Nagios down?"
|
100
|
-
sleep 10
|
101
111
|
end
|
102
112
|
end
|
103
113
|
|
104
114
|
def main
|
105
115
|
while true
|
106
116
|
process_input
|
117
|
+
puts "Whoops, restarting main loop in 10 seconds"
|
107
118
|
sleep 10
|
108
119
|
end
|
109
120
|
end
|
data/lib/flapjack/version.rb
CHANGED