File: check_queue_size_munin

package info (click to toggle)
chef-expander 10.12.0-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 208 kB
  • sloc: ruby: 1,533; sh: 146; makefile: 2
file content (51 lines) | stat: -rwxr-xr-x 1,190 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env ruby

require 'rubygems'
require 'munin_plugin'
Dir.chdir(File.join(File.expand_path(File.dirname(__FILE__)), "..")) do
  require 'bunny'

  $:.unshift(File.expand_path('../../lib', __FILE__))
  require 'chef/expander'
  require 'chef/expander/version'
  require 'chef/expander/configuration'

  include Chef

munin_plugin do
  graph_title "Expander Queue Size"
  graph_vlabel "Events"
  graph_category "Opscode"
  graph_info "Events in the Expander Queue waiting to be consumed by Solr."
  queuesize.label "events"
  queuesize.draw "LINE"
  queuesize.warning "100"
  queuesize.critical "200"

  collect do

      Expander.init_config([])

      message_counts = []

      begin
        amqp_client = Bunny.new(Expander.config.amqp_config)
        amqp_client.start

        0.upto(Expander::VNODES - 1) do |vnode|
          q = amqp_client.queue("vnode-#{vnode}", :durable => true)
          message_counts << q.status[:message_count]
        end
        total_messages = message_counts.inject(:+)

      ensure
        amqp_client.stop if defined?(amqp_client) && amqp_client && amqp_client.connected?
      end

      queuesize.value total_messages
  
    end


  end
end