class NewRelic::F5Plugin::Nodes

Constants

NODE_MONITOR_STATES
OID_LTM_NODE_ADDR_MONITOR_STATUS

Attributes

snmp_manager[RW]

Public Class Methods

new(snmp = nil) click to toggle source

Init

# File lib/newrelic_f5_plugin/nodes.rb, line 34
def initialize(snmp = nil)
  if snmp
    @snmp_manager = snmp
  else
    @snmp_manager = nil
  end
end

Public Instance Methods

get_status(snmp = nil) click to toggle source

Gather Node Status and report

# File lib/newrelic_f5_plugin/nodes.rb, line 66
def get_status(snmp = nil)
  snmp = snmp_manager unless snmp
  metrics = { }
  counter = 0

  if snmp
    # Init all the states with zeros so we always get them
    base_name = "Nodes/Monitor Status"
    NODE_MONITOR_STATES.each do |key,value|
      metrics["#{base_name}/#{value}"] = { :label => "nodes", :count => 0 }
    end

    # ltmNodeAddrMonitorStatus
    begin
      snmp.walk([OID_LTM_NODE_ADDR_MONITOR_STATUS]) do |row|
        row.each do |vb|
          metric_name = "#{base_name}/#{NODE_MONITOR_STATES[vb.value.to_i]}"
          metrics[metric_name][:count]  += 1
          counter += 1
        end
      end
    rescue Exception => e
      NewRelic::PlatformLogger.error("Unable to gather Node Status metrics with error: #{e}")
    end
  end

  NewRelic::PlatformLogger.debug("Nodes: Got #{counter} Status metrics")
  return metrics
end
poll(agent, snmp) click to toggle source

Perform polling and reportings of metrics

# File lib/newrelic_f5_plugin/nodes.rb, line 47
def poll(agent, snmp)
  @snmp_manager = snmp

  node_status = get_status
  node_status.each_key { |m| agent.report_metric m, node_status[m][:label], node_status[m][:count] } unless node_status.nil?
end