class NewRelic::F5Plugin::Virtuals
Constants
- MAX_RESULTS
- OID_LTM_VIRTUAL_SERVERS
- OID_LTM_VIRTUAL_SERV_ENTRY
- OID_LTM_VIRTUAL_SERV_STAT
- OID_LTM_VIRTUAL_SERV_STAT_CLIENT_BYTES_IN
- OID_LTM_VIRTUAL_SERV_STAT_CLIENT_BYTES_OUT
- OID_LTM_VIRTUAL_SERV_STAT_CLIENT_CUR_CONNS
- OID_LTM_VIRTUAL_SERV_STAT_CLIENT_PKTS_IN
- OID_LTM_VIRTUAL_SERV_STAT_CLIENT_PKTS_OUT
- OID_LTM_VIRTUAL_SERV_STAT_CLIENT_TOT_CONNS
- OID_LTM_VIRTUAL_SERV_STAT_NAME
- OID_LTM_VIRTUAL_SERV_STAT_TOT_REQUESTS
- OID_LTM_VIRTUAL_SERV_STAT_VS_USAGE_RATIO_1M
Attributes
names[RW]
snmp_manager[RW]
Public Class Methods
new(snmp = nil)
click to toggle source
Init
# File lib/newrelic_f5_plugin/virtuals.rb, line 66 def initialize(snmp = nil) @names = [ ] @f5_agent = nil if snmp @snmp_manager = snmp else @snmp_manager = nil end end
Public Instance Methods
get_conns_current(snmp = nil)
click to toggle source
Gather VS Connection count
# File lib/newrelic_f5_plugin/virtuals.rb, line 157 def get_conns_current(snmp = nil) snmp = @snmp_manager unless snmp get_names(snmp) if @names.empty? res = gather_snmp_metrics_by_name("Virtual Servers/Current Connections", @names, OID_LTM_VIRTUAL_SERV_STAT_CLIENT_CUR_CONNS, snmp) NewRelic::PlatformLogger.debug("Virtual Servers: Got #{res.size}/#{@names.size} Current Connection metrics") unless res.nil? sorted_report = res.sort_by { |k,v| v }.reverse sorted_report.each_with_index do |row, index| @f5_agent.report_metric row[0], "conns", row[1] break if index >= (MAX_RESULTS - 1) end end end
get_conns_total(snmp = nil)
click to toggle source
Gather VS Connection rate
# File lib/newrelic_f5_plugin/virtuals.rb, line 178 def get_conns_total(snmp = nil) @conn_rate ||= { } report = { } snmp = @snmp_manager unless snmp get_names(snmp) if @names.empty? res = gather_snmp_metrics_by_name("Virtual Servers/Connection Rate", @names, OID_LTM_VIRTUAL_SERV_STAT_CLIENT_TOT_CONNS, snmp) NewRelic::PlatformLogger.debug("Virtual Servers: Got #{res.size}/#{@names.size} Connection Rate metrics") unless res.nil? res.each_key do |metric| @conn_rate[metric] ||= NewRelic::Processor::EpochCounter.new report[metric] = @conn_rate[metric].process(res[metric]) end sorted_report = report.sort_by { |k,v| v }.reverse sorted_report.each_with_index do |row, index| @f5_agent.report_metric row[0], "conn/sec", row[1] break if index >= (MAX_RESULTS - 1) end end end
get_cpu_usage_1m(snmp = nil)
click to toggle source
Gather VS Connection rate
# File lib/newrelic_f5_plugin/virtuals.rb, line 318 def get_cpu_usage_1m(snmp = nil) snmp = @snmp_manager unless snmp get_names(snmp) if @names.empty? res = gather_snmp_metrics_by_name("Virtual Servers/CPU Usage/1m", @names, OID_LTM_VIRTUAL_SERV_STAT_VS_USAGE_RATIO_1M, snmp) NewRelic::PlatformLogger.debug("Virtual Servers: Got #{res.size}/#{@names.size} CPU metrics") unless res.nil? sorted_report = res.sort_by { |k,v| v }.reverse sorted_report.each_with_index do |row, index| @f5_agent.report_metric row[0], "%", row[1] break if index >= (MAX_RESULTS - 1) end end end
get_names(snmp = nil)
click to toggle source
Get the list of Virtual Server names
# File lib/newrelic_f5_plugin/virtuals.rb, line 103 def get_names(snmp = nil) snmp = @snmp_manager unless snmp if snmp @names.clear begin snmp.walk([OID_LTM_VIRTUAL_SERV_STAT_NAME]) do |row| row.each do |vb| @names.push(vb.value) end end rescue Exception => e NewRelic::PlatformLogger.error("Unable to gather Virtual Server names with error: #{e}") end NewRelic::PlatformLogger.debug("Virtual Servers: Found #{@names.size} virtual servers, reporting the top #{MAX_RESULTS} (max)") return @names end end
get_packets_in(snmp = nil)
click to toggle source
Gather VS Packets Inbound
# File lib/newrelic_f5_plugin/virtuals.rb, line 206 def get_packets_in (snmp = nil) @packet_in_rate ||= { } report = { } snmp = @snmp_manager unless snmp get_names(snmp) if @names.empty? res = gather_snmp_metrics_by_name("Virtual Servers/Packets/In", @names, OID_LTM_VIRTUAL_SERV_STAT_CLIENT_PKTS_IN, snmp) NewRelic::PlatformLogger.debug("Virtual Servers: Got #{res.size}/#{@names.size} Inbound Packet metrics") unless res.nil? res.each_key do |metric| @packet_in_rate[metric] ||= NewRelic::Processor::EpochCounter.new report[metric] = @packet_in_rate[metric].process(res[metric] * 8) end sorted_report = report.sort_by { |k,v| v }.reverse sorted_report.each_with_index do |row, index| @f5_agent.report_metric row[0], "packets/sec", row[1] break if index >= (MAX_RESULTS - 1) end end end
get_packets_out(snmp = nil)
click to toggle source
Gather VS Packets Outbound
# File lib/newrelic_f5_plugin/virtuals.rb, line 234 def get_packets_out(snmp = nil) @packet_out_rate ||= { } report = { } snmp = @snmp_manager unless snmp get_names(snmp) if @names.empty? res = gather_snmp_metrics_by_name("Virtual Servers/Packets/Out", @names, OID_LTM_VIRTUAL_SERV_STAT_CLIENT_PKTS_OUT, snmp) NewRelic::PlatformLogger.debug("Virtual Servers: Got #{res.size}/#{@names.size} Outbound Packet metrics") unless res.nil? res.each_key do |metric| @packet_out_rate[metric] ||= NewRelic::Processor::EpochCounter.new report[metric] = @packet_out_rate[metric].process(res[metric] * 8) end sorted_report = report.sort_by { |k,v| v }.reverse sorted_report.each_with_index do |row, index| @f5_agent.report_metric row[0], "packets/sec", row[1] break if index >= (MAX_RESULTS - 1) end end end
get_requests(snmp = nil)
click to toggle source
Gather VS Total Requests
# File lib/newrelic_f5_plugin/virtuals.rb, line 129 def get_requests(snmp = nil) @req_rate ||= { } report = { } snmp = @snmp_manager unless snmp get_names(snmp) if @names.empty? res = gather_snmp_metrics_by_name("Virtual Servers/Requests", @names, OID_LTM_VIRTUAL_SERV_STAT_TOT_REQUESTS, snmp) NewRelic::PlatformLogger.debug("Virtual Servers: Got #{res.size}/#{@names.size} Request metrics") unless res.nil? res.each_key do |metric| @req_rate[metric] ||= NewRelic::Processor::EpochCounter.new report[metric] = @req_rate[metric].process(res[metric]) end sorted_report = report.sort_by { |k,v| v }.reverse sorted_report.each_with_index do |row, index| @f5_agent.report_metric row[0], "req/sec", row[1] break if index >= (MAX_RESULTS - 1) end end end
get_throughput_in(snmp = nil)
click to toggle source
Gather VS Throughput Inbound (returns in bits)
# File lib/newrelic_f5_plugin/virtuals.rb, line 262 def get_throughput_in(snmp = nil) @throughput_in_rate ||= { } report = { } snmp = @snmp_manager unless snmp get_names(snmp) if @names.empty? res = gather_snmp_metrics_by_name("Virtual Servers/Throughput/In", @names, OID_LTM_VIRTUAL_SERV_STAT_CLIENT_BYTES_IN, snmp) NewRelic::PlatformLogger.debug("Virtual Servers: Got #{res.size}/#{@names.size} Inbound Throughput metrics") unless res.nil? res.each_key do |metric| @throughput_in_rate[metric] ||= NewRelic::Processor::EpochCounter.new report[metric] = @throughput_in_rate[metric].process(res[metric] * 8) end sorted_report = report.sort_by { |k,v| v }.reverse sorted_report.each_with_index do |row, index| @f5_agent.report_metric row[0], "bits/sec", row[1] break if index >= (MAX_RESULTS - 1) end end end
get_throughput_out(snmp = nil)
click to toggle source
Gather VS Throughput Outbound (returns in bits)
# File lib/newrelic_f5_plugin/virtuals.rb, line 290 def get_throughput_out(snmp = nil) @throughput_out_rate ||= { } report = { } snmp = @snmp_manager unless snmp get_names(snmp) if @names.empty? res = gather_snmp_metrics_by_name("Virtual Servers/Throughput/Out", @names, OID_LTM_VIRTUAL_SERV_STAT_CLIENT_BYTES_OUT, snmp) NewRelic::PlatformLogger.debug("Virtual Servers: Got #{res.size}/#{@names.size} Outbound Throughput metrics") unless res.nil? res.each_key do |metric| @throughput_out_rate[metric] ||= NewRelic::Processor::EpochCounter.new report[metric] = @throughput_out_rate[metric].process(res[metric] * 8) end sorted_report = report.sort_by { |k,v| v }.reverse sorted_report.each_with_index do |row, index| @f5_agent.report_metric row[0], "bits/sec", row[1] break if index >= (MAX_RESULTS - 1) end end end
poll(agent, snmp)
click to toggle source
Perform polling and reportings of metrics
# File lib/newrelic_f5_plugin/virtuals.rb, line 82 def poll(agent, snmp) @snmp_manager = snmp @f5_agent = agent unless get_names.empty? get_requests get_conns_current get_conns_total get_packets_in get_packets_out get_throughput_in get_throughput_out get_cpu_usage_1m end end