Chapter 09/circuit-oneops-1-master/components/cookbooks/diagnostic_cache/files/default/couchbase_monitor.rb
# Collects ping metrics across all nodes in the cluster
Collects ping metrics across all nodes in the cluster
Collects ping metrics across all nodes in the cluster
def ping_stats(url, time)
    logger.info "ping_stats:start: url = #{url}, time = #{time.to_i}"
    jsonResponse = rest_call(url)
    response_hash = JSON.parse(jsonResponse)
    nodes = response_hash['nodes']
    this_node = nodes.select { |node| node.has_key?('thisNode') && node['thisNode'] == true }.first
    if this_node != nil
      nodes.each do |node|
        if node['otpNode'] != this_node['otpNode']
          hostname = URI.parse("http://#{node['hostname']}").host.downcase
          ping_time = time_socket_open_close(hostname, '22')
          write_to_graphite( construct_metric_name("#{this_node['otpNode'].gsub('.','-')}.ping.#{hostname.gsub('.','-')}", CONST_NODE_LEVEL), ping_time, time)
        end
      end
    else
      logger.info 'No nodes found with thisNode == true'
    end
    logger.info 'ping_stats:end: Completed'
  end
def ping_stats ( url , time ) logger . info "ping_stats:start: url = #{url}, time = #{time.to_i}" jsonResponse = rest_call ( url ) response_hash = JSON . parse ( jsonResponse ) nodes = response_hash [ 'nodes' ] this_node = nodes . select { | node | node . has_key? ( 'thisNode' ) && node [ 'thisNode' ] == true } . first if this_node != nil nodes . each do | node | if node [ 'otpNode' ] != this_node [ 'otpNode' ] hostname = URI . parse ( "http://#{node['hostname']}" ) . host . downcase ping_time = time_socket_open_close ( hostname , '22' ) write_to_graphite ( construct_metric_name ( "#{this_node['otpNode'].gsub('.','-')}.ping.#{hostname.gsub('.','-')}" , CONST_NODE_LEVEL ) , ping_time , time ) end end else logger . info 'No nodes found with thisNode == true' end logger . info 'ping_stats:end: Completed' end
Collects ping metrics across all nodes in the cluster
Collects ping metrics across all nodes in the cluster
url
<not_specific>
time
<not_specific>