flapjack 0.6.33 → 0.6.34

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -132,20 +132,16 @@ flapjack-nagios-receiver
132
132
 
133
133
  There is a control script that uses [Daemons](http://daemons.rubyforge.org/) to start, stop, restart, show status etc of the flapjack-nagios-receiver process. Options after -- are passed through to flapjack-nagios-receiver. Run it like so:
134
134
 
135
- flapjack-nagios-receiver-control start -- --config /etc/flapjack/flapjack-config.yaml /path/to/nagios/perfdata.fifo
135
+ flapjack-nagios-receiver-control start -- --config /etc/flapjack/flapjack-config.yaml --fifo /path/to/nagios/perfdata.fifo
136
136
  flapjack-nagios-receiver-control status
137
- flapjack-nagios-receiver-control restart -- --config /etc/flapjack/flapjack-config.yaml /path/to/nagios/perfdata.fifo
137
+ flapjack-nagios-receiver-control restart -- --config /etc/flapjack/flapjack-config.yaml --fifo /path/to/nagios/perfdata.fifo
138
138
  flapjack-nagios-receiver-control stop
139
139
 
140
140
  * Bypassing daemons control script: *
141
141
 
142
- This process needs to be started with the nagios perfdata named pipe attached to its STDIN like so:
142
+ Specify the path to the nagios named pipe (fifo):
143
143
 
144
- flapjack-nagios-receiver < /var/cache/nagios3/event_stream.fifo
145
-
146
- Or the path to the fifo can just be given as an argument, thanks to the magical powers of ARGV:
147
-
148
- flapjack-nagios-receiver /var/cache/nagios3/event_stream.fifo
144
+ flapjack-nagios-receiver --fifo /var/cache/nagios3/event_stream.fifo
149
145
 
150
146
  Now as nagios feeds check execution results into the perfdata named pipe, flapjack-nagios-receiver will convert them to JSON encoded ruby objects and insert them into the *events* queue.
151
147
 
@@ -18,8 +18,8 @@ OptionParser.new do |opts|
18
18
  options.config = c
19
19
  end
20
20
 
21
- opts.on("-f", "--fifo [PATH]", String, "PATH to the nagios perfdata named pipe") do |f|
22
- options.fifo_path = f
21
+ opts.on("-f", "--fifo FIFO", String, "Path to the nagios perfdata named pipe") do |f|
22
+ options.fifo = f
23
23
  end
24
24
 
25
25
  end.parse!(ARGV)
@@ -42,10 +42,12 @@ if config_env.nil? || config_env.empty?
42
42
  exit(false)
43
43
  end
44
44
 
45
- # add lib to the default include path
46
- #unless $:.include?(File.dirname(__FILE__) + '/../lib/')
47
- # $: << File.dirname(__FILE__) + '/../lib'
48
- #end
45
+ if !options.fifo
46
+ puts "You must specify a path to the nagios perfdata named pipe using the --fifo option"
47
+ exit(false)
48
+ end
49
+
50
+ @fifo = File.new(options.fifo)
49
51
 
50
52
  # nagios.cfg contains the following templates for host and service data (modified from the default
51
53
  # to include hoststate / servicestate, and a fake service 'HOST' for hostperfdata, so that the
@@ -71,11 +73,10 @@ def process_input
71
73
  redis = Redis.new(:db => @redis_db, :host => @redis_host, :port => @redis_port)
72
74
  end
73
75
 
74
- puts "ARGV after option processing looks like this: [#{ARGV.inspect}]"
75
-
76
76
  begin
77
- while line = ARGF.readline.split("\t")
78
- object_type, timestamp, entity, check, state, check_time, check_latency, check_output, check_perfdata = line
77
+ while line = @fifo.gets
78
+ skip unless line
79
+ object_type, timestamp, entity, check, state, check_time, check_latency, check_output, check_perfdata = line.split("\t")
79
80
  puts "#{object_type}, #{timestamp}, #{entity}, #{check}, #{state}, #{check_output}"
80
81
  next unless line.length == 9
81
82
  next unless timestamp =~ /^\d+$/
@@ -28,9 +28,8 @@ fi
28
28
 
29
29
  # Evaluate command
30
30
 
31
- #/bin/bash -c "source /etc/profile.d/rbenv.sh && rbenv shell 1.9.3-p125 && flapjack-nagios-receiver-control $1 -- --config /etc/flapjack/flapjack-config.yaml ${NAGIOS_PERFDATA_FIFO}"
32
- rbenv shell 1.9.3-p125 && flapjack-nagios-receiver-control $1 -- --config /etc/flapjack/flapjack-config.yaml ${NAGIOS_PERFDATA_FIFO}
33
- RETVAL=$?
31
+ rbenv shell 1.9.3-p125 && flapjack-nagios-receiver-control $1 -- --config /etc/flapjack/flapjack-config.yaml --fifo ${NAGIOS_PERFDATA_FIFO}
34
32
 
33
+ RETVAL=$?
35
34
  exit $RETVAL
36
35
 
@@ -227,12 +227,8 @@ module Flapjack
227
227
  end
228
228
 
229
229
  def build_redis_connection_pool(options = {})
230
- redis_em_options = @redis_options.dup
231
- redis_db = redis_em_options.delete(:db)
232
230
  EventMachine::Synchrony::ConnectionPool.new(:size => options[:size] || 5) do
233
- redis = EM::Protocols::Redis.connect(redis_em_options)
234
- redis.select(redis_db)
235
- redis
231
+ ::Redis.new(@redis_options)
236
232
  end
237
233
  end
238
234
 
@@ -27,15 +27,9 @@ module Flapjack
27
27
  def build_redis_connection_pool(options = {})
28
28
  return unless @bootstrapped
29
29
  if defined?(EventMachine) && defined?(EventMachine::Synchrony)
30
-
31
- redis_em_options = @redis_config.dup
32
- redis_db = redis_em_options.delete(:db)
33
30
  EventMachine::Synchrony::ConnectionPool.new(:size => options[:size] || 5) do
34
- r = EM::Protocols::Redis.connect(redis_em_options)
35
- r.select(redis_db)
36
- r
31
+ ::Redis.new(@redis_config)
37
32
  end
38
-
39
33
  else
40
34
  ::Redis.new(@redis_config)
41
35
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module Flapjack
4
- VERSION = "0.6.33"
4
+ VERSION = "0.6.34"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.33
4
+ version: 0.6.34
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: