Class: AppOpsClient::CLI::MTalk

Inherits:
Thor
  • Object
show all
Defined in:
lib/appops-client/cli/mtalk.rb

Instance Method Summary collapse

Instance Method Details

#check_amqObject



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
# File 'lib/appops-client/cli/mtalk.rb', line 11

def check_amq()
  ## Hostnames
  ## TODO: reach out to opsconsole for this data.
  port = 8161
  hosts = [ "pprdsmsas406.ie.intuit.net" ]

  hosts.each do |hostname|
    http = Net::HTTP.new( hostname, port )
    res = http.get( "/admin/xml/queues.jsp" ) 
    if(res.code.to_i == 200)
      AppOpsClientLogger.info( "Queue check successful" ){ hostname }
      xml = LibXML::XML::Parser.string( res.body ).parse
      xml.find( "//queue" ).each do |q|
        q_name = q.attributes.get_attribute( "name" )
        q.children.each do |child|
          next if(child.name != "stats")
          q_size = child.attributes.get_attribute( "size" ).value.to_i
          q_consumer_count = child.attributes.get_attribute( "consumerCount" ).value.to_i
          q_enqueue_count = child.attributes.get_attribute( "enqueueCount" ).value.to_i
          q_dequeue_count = child.attributes.get_attribute( "dequeueCount" ).value.to_i
          AppOpsClientLogger.debug( "Metrics for %s" % q_name ){ [q_size, q_consumer_count, q_enqueue_count, q_dequeue_count] }
        end
      end
    else
      AppOpsClientLogger.error( "Queue check unsuccessful" ){ res.code }
    end
  end
end