class NewRelic::F5Plugin::Platform

Constants

OID_SYS_GLOBAL_HOST

Create the OIDs if they do not exist

OID_SYS_GLOBAL_HOST_CPU_COUNT
OID_SYS_GLOBAL_HOST_CPU_IDLE_1M
OID_SYS_GLOBAL_HOST_CPU_IOWAIT_1M
OID_SYS_GLOBAL_HOST_CPU_IRQ_1M
OID_SYS_GLOBAL_HOST_CPU_NICE_1M
OID_SYS_GLOBAL_HOST_CPU_SOFTIRQ_1M
OID_SYS_GLOBAL_HOST_CPU_SYSTEM_1M
OID_SYS_GLOBAL_HOST_CPU_USER_1M
OID_SYS_HOST_MEMORY_USED
OID_SYS_PLATFORM
OID_SYS_PLATFORM_INFO
OID_SYS_PLATFORM_INFO_MARKETING_NAME
OID_SYS_PLATFORM_INFO_NAME
OID_SYS_PRODUCT
OID_SYS_PRODUCT_BUILD
OID_SYS_PRODUCT_EDITION
OID_SYS_PRODUCT_NAME
OID_SYS_PRODUCT_VERSION

Attributes

snmp_manager[RW]

Public Class Methods

new(snmp = nil) click to toggle source

Init

# File lib/newrelic_f5_plugin/platform.rb, line 38
def initialize(snmp = nil)
  @version = 'Unknown!'

  if snmp
    @snmp_manager = snmp
  else
    @snmp_manager = nil
  end
end

Public Instance Methods

get_cpu(snmp = nil) click to toggle source

Gather CPU Related metrics and report them in %

# File lib/newrelic_f5_plugin/platform.rb, line 107
def get_cpu(snmp = nil)
  metrics = { }
  snmp    = snmp_manager unless snmp

  if snmp
    res = gather_snmp_metrics_array([OID_SYS_GLOBAL_HOST_CPU_COUNT, OID_SYS_GLOBAL_HOST_CPU_USER_1M, OID_SYS_GLOBAL_HOST_CPU_NICE_1M,
                                     OID_SYS_GLOBAL_HOST_CPU_SYSTEM_1M, OID_SYS_GLOBAL_HOST_CPU_IRQ_1M, OID_SYS_GLOBAL_HOST_CPU_SOFTIRQ_1M,
                                     OID_SYS_GLOBAL_HOST_CPU_IOWAIT_1M],
                                     snmp)

    # Bail out if we didn't get anything
    return metrics if res.empty?

    # In order to show the CPU usage as a total percentage, we divide by the number of cpus for older versions
    case @version
    when /^11\.[0-4]\.0/
      cpu_count = res[0].to_i
    else
      # 11.4.1 HF3 reports average CPU not total, so don't divide by CPU count
      cpu_count = 1
    end

    vals = res[1..6].map { |i| i.to_f / cpu_count }

    metrics["CPU/Global/User"]     = vals[0]
    metrics["CPU/Global/Nice"]     = vals[1]
    metrics["CPU/Global/System"]   = vals[2]
    metrics["CPU/Global/IRQ"]      = vals[3]
    metrics["CPU/Global/Soft IRQ"] = vals[4]
    metrics["CPU/Global/IO Wait"]  = vals[5]

    # Add it all up, and send a summary metric
    metrics["CPU/Total/Global"] = vals.inject(0.0){ |a,b| a + b }

  end

  return metrics
end
get_memory(snmp = nil) click to toggle source

Gather Memory related metrics and report them in bytes

# File lib/newrelic_f5_plugin/platform.rb, line 150
def get_memory(snmp = nil)
  metrics = { }
  snmp    = snmp_manager unless snmp

  if snmp
    res = gather_snmp_metrics_array([OID_SYS_HOST_MEMORY_USED], snmp)

    # Bail out if we didn't get anything
    return metrics if res.empty?

    metrics["Memory/Host"] = res[0]
  end

  return metrics
end
get_platform_info(snmp = nil) click to toggle source
# File lib/newrelic_f5_plugin/platform.rb, line 89
def get_platform_info(snmp = nil)
  platform = "Unknown!"
  snmp     = snmp_manager unless snmp

  if snmp
    res = gather_snmp_metrics_array([OID_SYS_PLATFORM_INFO_MARKETING_NAME, OID_SYS_PLATFORM_INFO_NAME], snmp)

    platform = "#{res[0]} (#{res[1]})"
  end

  return platform
end
get_version(snmp = nil) click to toggle source

Gather Version information

# File lib/newrelic_f5_plugin/platform.rb, line 74
def get_version(snmp = nil)
  version = "Unknown!"
  snmp    = snmp_manager unless snmp

  if snmp
    res = gather_snmp_metrics_array([OID_SYS_PRODUCT_VERSION, OID_SYS_PRODUCT_BUILD], snmp)

    version = "#{res[0]}.#{res[1]}" unless res.empty?
  end

  return version
end
poll(agent, snmp) click to toggle source

Perform polling and reportings of metrics

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

  system_platform = get_platform_info
  @version        = get_version
  NewRelic::PlatformLogger.debug("Found a #{system_platform} running version #{@version}")


  system_cpu = get_cpu
  system_cpu.each_key { |m| agent.report_metric m, "%", system_cpu[m] } unless system_cpu.nil?

  system_memory = get_memory
  system_memory.each_key { |m| agent.report_metric m, "bytes", system_memory[m] } unless system_memory.nil?

end