Class: NewRelic::F5Plugin::Rules

Inherits:
Object
  • Object
show all
Defined in:
lib/newrelic_f5_plugin/rules.rb

Constant Summary collapse

OID_LTM_RULES =
"1.3.6.1.4.1.3375.2.2.8"
OID_LTM_RULE_STAT =
"#{OID_LTM_RULES}.3"
OID_LTM_RULE_ENTRY =
"#{OID_LTM_RULE_STAT}.3.1"
OID_LTM_RULE_STAT_NAME =
"#{OID_LTM_RULE_ENTRY}.1"
OID_LTM_RULE_STAT_TYPE =
"#{OID_LTM_RULE_ENTRY}.2"
OID_LTM_RULE_STAT_FAILURES =
"#{OID_LTM_RULE_ENTRY}.4"
OID_LTM_RULE_STAT_ABORTS =
"#{OID_LTM_RULE_ENTRY}.5"
OID_LTM_RULE_STAT_TOT_EXEC =
"#{OID_LTM_RULE_ENTRY}.6"
OID_LTM_RULE_STAT_AVG_CYCLES =
"#{OID_LTM_RULE_ENTRY}.7"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(snmp = nil) ⇒ Rules

Init



39
40
41
42
43
44
45
46
47
# File 'lib/newrelic_f5_plugin/rules.rb', line 39

def initialize(snmp = nil)
  @names = [ ]

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

Instance Attribute Details

#namesObject

Returns the value of attribute names.



22
23
24
# File 'lib/newrelic_f5_plugin/rules.rb', line 22

def names
  @names
end

#snmp_managerObject

Returns the value of attribute snmp_manager.



22
23
24
# File 'lib/newrelic_f5_plugin/rules.rb', line 22

def snmp_manager
  @snmp_manager
end

Instance Method Details

#get_aborts(snmp = nil) ⇒ Object

Gather Total iRule Aborts



128
129
130
131
132
133
134
135
# File 'lib/newrelic_f5_plugin/rules.rb', line 128

def get_aborts(snmp = nil)
  snmp = snmp_manager unless snmp

  get_names(snmp) if @names.empty?
  res = gather_snmp_metrics_by_name("Rules/Aborts", @names, OID_LTM_RULE_STAT_ABORTS, snmp)
  NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@names.size} Abort metrics")
  return res
end

#get_average_cycles(snmp = nil) ⇒ Object

Gather Average iRule execution time (in cycles)



142
143
144
145
146
147
148
149
# File 'lib/newrelic_f5_plugin/rules.rb', line 142

def get_average_cycles(snmp = nil)
  snmp = snmp_manager unless snmp

  get_names(snmp) if @names.empty?
  res = gather_snmp_metrics_by_name("Rules/Time", @names, OID_LTM_RULE_STAT_AVG_CYCLES, snmp)
  NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@names.size} Average Cycle metrics")
  return res
end

#get_executions(snmp = nil) ⇒ Object

Gather Total iRule Executions



100
101
102
103
104
105
106
107
# File 'lib/newrelic_f5_plugin/rules.rb', line 100

def get_executions(snmp = nil)
  snmp = snmp_manager unless snmp

  get_names(snmp) if @names.empty?
  res = gather_snmp_metrics_by_name("Rules/Executions", @names, OID_LTM_RULE_STAT_TOT_EXEC, snmp)
  NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@names.size} Execution metrics")
  return res
end

#get_failures(snmp = nil) ⇒ Object

Gather Total iRule Failures



114
115
116
117
118
119
120
121
# File 'lib/newrelic_f5_plugin/rules.rb', line 114

def get_failures(snmp = nil)
  snmp = snmp_manager unless snmp

  get_names(snmp) if @names.empty?
  res = gather_snmp_metrics_by_name("Rules/Failures", @names, OID_LTM_RULE_STAT_FAILURES, snmp)
  NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@names.size} Failure metrics")
  return res
end

#get_names(snmp = nil) ⇒ Object

Get the list of iRule names



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/newrelic_f5_plugin/rules.rb', line 76

def get_names(snmp = nil)
  snmp = snmp_manager unless snmp

  if snmp
    @names.clear

    begin
      snmp.walk([OID_LTM_RULE_STAT_NAME, OID_LTM_RULE_STAT_TYPE]) do |rule, func|
        @names.push("#{rule.value}/#{func.value}")
      end
    rescue Exception => e
      NewRelic::PlatformLogger.error("Unable to gather iRule names with error: #{e}")
    end

    NewRelic::PlatformLogger.debug("Rules: Found #{@names.size} iRules")
    return @names
  end
end

#poll(agent, snmp) ⇒ Object

Perform polling and reportings of metrics



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/newrelic_f5_plugin/rules.rb', line 54

def poll(agent, snmp)
  @snmp_manager = snmp

  unless get_names.empty?
    rule_execs = get_executions
    rule_execs.each_key { |m| agent.report_counter_metric m, "execs/sec", rule_execs[m] } unless rule_execs.nil?

    rule_failures = get_failures
    rule_failures.each_key { |m| agent.report_counter_metric m, "failures/sec", rule_failures[m] } unless rule_failures.nil?

    rule_aborts = get_aborts
    rule_aborts.each_key { |m| agent.report_counter_metric m, "aborts/sec", rule_aborts[m] } unless rule_aborts.nil?

    rule_cycles = get_average_cycles
    rule_cycles.each_key { |m| agent.report_metric m, "cycles", rule_cycles[m] } unless rule_cycles.nil?
  end
end