newrelic_f5_plugin 1.0.12 → 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ module NewRelic
8
8
  module F5Plugin
9
9
 
10
10
  class Nodes
11
- attr_accessor :vs_names, :snmp_manager
11
+ attr_accessor :snmp_manager
12
12
 
13
13
  NODE_MONITOR_STATES = {
14
14
  0 => 'unchecked',
@@ -40,6 +40,19 @@ module NewRelic
40
40
  end
41
41
 
42
42
 
43
+
44
+ #
45
+ # Perform polling and reportings of metrics
46
+ #
47
+ def poll(agent, snmp)
48
+ @snmp_manager = snmp
49
+
50
+ node_status = get_status
51
+ node_status.each_key { |m| agent.report_metric m, node_status[m][:label], node_status[m][:count] } unless node_status.nil?
52
+ end
53
+
54
+
55
+
43
56
  #
44
57
  # Node Naming in SNMP
45
58
  #
@@ -40,8 +40,9 @@ module NewRelic
40
40
  module F5Plugin
41
41
 
42
42
  class Pools
43
- attr_accessor :pool_names, :snmp_manager
43
+ attr_accessor :names, :snmp_manager
44
44
 
45
+ MAX_RESULTS = 150
45
46
  OID_LTM_POOLS = "1.3.6.1.4.1.3375.2.2.5"
46
47
  OID_LTM_POOL_STAT = "#{OID_LTM_POOLS}.2"
47
48
  OID_LTM_POOL_ENTRY = "#{OID_LTM_POOL_STAT}.3.1"
@@ -60,7 +61,8 @@ module NewRelic
60
61
  # Init
61
62
  #
62
63
  def initialize(snmp = nil)
63
- @pool_names = [ ]
64
+ @names = [ ]
65
+ @f5_agent = nil
64
66
 
65
67
  if snmp
66
68
  @snmp_manager = snmp
@@ -71,6 +73,26 @@ module NewRelic
71
73
 
72
74
 
73
75
 
76
+ #
77
+ # Perform polling and reportings of metrics
78
+ #
79
+ def poll(agent, snmp)
80
+ @snmp_manager = snmp
81
+ @f5_agent = agent
82
+
83
+ unless get_names.empty?
84
+ get_requests
85
+ get_conns_current
86
+ get_conns_total
87
+ get_packets_in
88
+ get_packets_out
89
+ get_throughput_in
90
+ get_throughput_out
91
+ end
92
+ end
93
+
94
+
95
+
74
96
  #
75
97
  # Get the list of Pool names
76
98
  #
@@ -78,20 +100,20 @@ module NewRelic
78
100
  snmp = snmp_manager unless snmp
79
101
 
80
102
  if snmp
81
- @pool_names.clear
103
+ @names.clear
82
104
 
83
105
  begin
84
106
  snmp.walk([OID_LTM_POOL_STAT_NAME]) do |row|
85
107
  row.each do |vb|
86
- @pool_names.push(vb.value)
108
+ @names.push(vb.value)
87
109
  end
88
110
  end
89
111
  rescue Exception => e
90
112
  NewRelic::PlatformLogger.error("Unable to gather Pool names with error: #{e}")
91
113
  end
92
114
 
93
- NewRelic::PlatformLogger.debug("Pools: Found #{@pool_names.size} pools")
94
- return @pool_names
115
+ NewRelic::PlatformLogger.debug("Pools: Found #{@names.size} pools, reporting the top #{MAX_RESULTS} (max)")
116
+ return @names
95
117
  end
96
118
  end
97
119
 
@@ -101,12 +123,26 @@ module NewRelic
101
123
  # Gather Total Requests
102
124
  #
103
125
  def get_requests(snmp = nil)
126
+ @req_rate ||= { }
127
+ report = { }
104
128
  snmp = snmp_manager unless snmp
105
129
 
106
- get_names(snmp) if @pool_names.empty?
107
- res = gather_snmp_metrics_by_name("Pools/Requests", @pool_names, OID_LTM_POOL_STAT_TOT_REQUESTS, snmp)
108
- NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@pool_names.size} Request metrics")
109
- return res
130
+ get_names(snmp) if @names.empty?
131
+ res = gather_snmp_metrics_by_name("Pools/Requests", @names, OID_LTM_POOL_STAT_TOT_REQUESTS, snmp)
132
+ NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@names.size} Request metrics")
133
+
134
+ unless res.nil?
135
+ res.each_key do |metric|
136
+ @req_rate[metric] ||= NewRelic::Processor::EpochCounter.new
137
+ report[metric] = @req_rate[metric].process(res[metric])
138
+ end
139
+
140
+ sorted_report = report.sort_by { |k,v| v }.reverse
141
+ sorted_report.each_with_index do |row, index|
142
+ @f5_agent.report_metric row[0], "req/sec", row[1]
143
+ break if index >= (MAX_RESULTS - 1)
144
+ end
145
+ end
110
146
  end
111
147
 
112
148
 
@@ -117,10 +153,17 @@ module NewRelic
117
153
  def get_conns_current(snmp = nil)
118
154
  snmp = snmp_manager unless snmp
119
155
 
120
- get_names(snmp) if @pool_names.empty?
121
- res = gather_snmp_metrics_by_name("Pools/Current Connections", @pool_names, OID_LTM_POOL_STAT_SERVER_CUR_CONNS, snmp)
122
- NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@pool_names.size} Current Connection metrics")
123
- return res
156
+ get_names(snmp) if @names.empty?
157
+ res = gather_snmp_metrics_by_name("Pools/Current Connections", @names, OID_LTM_POOL_STAT_SERVER_CUR_CONNS, snmp)
158
+ NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@names.size} Current Connection metrics")
159
+
160
+ unless res.nil?
161
+ sorted_report = res.sort_by { |k,v| v }.reverse
162
+ sorted_report.each_with_index do |row, index|
163
+ @f5_agent.report_metric row[0], "conns", row[1]
164
+ break if index >= (MAX_RESULTS - 1)
165
+ end
166
+ end
124
167
  end
125
168
 
126
169
 
@@ -129,12 +172,26 @@ module NewRelic
129
172
  # Gather Connection rate
130
173
  #
131
174
  def get_conns_total(snmp = nil)
175
+ @conn_rate ||= { }
176
+ report = { }
132
177
  snmp = snmp_manager unless snmp
133
178
 
134
- get_names(snmp) if @pool_names.empty?
135
- res = gather_snmp_metrics_by_name("Pools/Connection Rate", @pool_names, OID_LTM_POOL_STAT_SERVER_TOT_CONNS, snmp)
136
- NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@pool_names.size} Connection Rate metrics")
137
- return res
179
+ get_names(snmp) if @names.empty?
180
+ res = gather_snmp_metrics_by_name("Pools/Connection Rate", @names, OID_LTM_POOL_STAT_SERVER_TOT_CONNS, snmp)
181
+ NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@names.size} Connection Rate metrics")
182
+
183
+ unless res.nil?
184
+ res.each_key do |metric|
185
+ @conn_rate[metric] ||= NewRelic::Processor::EpochCounter.new
186
+ report[metric] = @conn_rate[metric].process(res[metric])
187
+ end
188
+
189
+ sorted_report = report.sort_by { |k,v| v }.reverse
190
+ sorted_report.each_with_index do |row, index|
191
+ @f5_agent.report_metric row[0], "conn/sec", row[1]
192
+ break if index >= (MAX_RESULTS - 1)
193
+ end
194
+ end
138
195
  end
139
196
 
140
197
 
@@ -143,13 +200,26 @@ module NewRelic
143
200
  # Gather Packets Inbound
144
201
  #
145
202
  def get_packets_in(snmp = nil)
203
+ @packet_in_rate ||= { }
204
+ report = { }
146
205
  snmp = snmp_manager unless snmp
147
206
 
148
- get_names(snmp) if @pool_names.empty?
149
- res = gather_snmp_metrics_by_name("Pools/Packets/In", @pool_names, OID_LTM_POOL_STAT_SERVER_PKTS_IN, snmp)
150
- res = res.each_key { |n| res[n] *= 8 }
151
- NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@pool_names.size} Inbound Packet metrics")
152
- return res
207
+ get_names(snmp) if @names.empty?
208
+ res = gather_snmp_metrics_by_name("Pools/Packets/In", @names, OID_LTM_POOL_STAT_SERVER_PKTS_IN, snmp)
209
+ NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@names.size} Inbound Packet metrics")
210
+
211
+ unless res.nil?
212
+ res.each_key do |metric|
213
+ @packet_in_rate[metric] ||= NewRelic::Processor::EpochCounter.new
214
+ report[metric] = @packet_in_rate[metric].process(res[metric] * 8)
215
+ end
216
+
217
+ sorted_report = report.sort_by { |k,v| v }.reverse
218
+ sorted_report.each_with_index do |row, index|
219
+ @f5_agent.report_metric row[0], "packets/sec", row[1]
220
+ break if index >= (MAX_RESULTS - 1)
221
+ end
222
+ end
153
223
  end
154
224
 
155
225
 
@@ -158,13 +228,26 @@ module NewRelic
158
228
  # Gather Packets Outbound
159
229
  #
160
230
  def get_packets_out(snmp = nil)
231
+ @packet_out_rate ||= { }
232
+ report = { }
161
233
  snmp = snmp_manager unless snmp
162
234
 
163
- get_names(snmp) if @pool_names.empty?
164
- res = gather_snmp_metrics_by_name("Pools/Packets/Out", @pool_names, OID_LTM_POOL_STAT_SERVER_PKTS_OUT, snmp)
165
- res = res.each_key { |n| res[n] *= 8 }
166
- NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@pool_names.size} Outbound Packet metrics")
167
- return res
235
+ get_names(snmp) if @names.empty?
236
+ res = gather_snmp_metrics_by_name("Pools/Packets/Out", @names, OID_LTM_POOL_STAT_SERVER_PKTS_OUT, snmp)
237
+ NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@names.size} Outbound Packet metrics")
238
+
239
+ unless res.nil?
240
+ res.each_key do |metric|
241
+ @packet_out_rate[metric] ||= NewRelic::Processor::EpochCounter.new
242
+ report[metric] = @packet_out_rate[metric].process(res[metric] * 8)
243
+ end
244
+
245
+ sorted_report = report.sort_by { |k,v| v }.reverse
246
+ sorted_report.each_with_index do |row, index|
247
+ @f5_agent.report_metric row[0], "packets/sec", row[1]
248
+ break if index >= (MAX_RESULTS - 1)
249
+ end
250
+ end
168
251
  end
169
252
 
170
253
 
@@ -173,13 +256,26 @@ module NewRelic
173
256
  # Gather Throughput Inbound (returns in bits)
174
257
  #
175
258
  def get_throughput_in(snmp = nil)
259
+ @throughput_in_rate ||= { }
260
+ report = { }
176
261
  snmp = snmp_manager unless snmp
177
262
 
178
- get_names(snmp) if @pool_names.empty?
179
- res = gather_snmp_metrics_by_name("Pools/Throughput/In", @pool_names, OID_LTM_POOL_STAT_SERVER_BYTES_IN, snmp)
180
- res = res.each_key { |n| res[n] *= 8 }
181
- NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@pool_names.size} Inbound Throughput metrics")
182
- return res
263
+ get_names(snmp) if @names.empty?
264
+ res = gather_snmp_metrics_by_name("Pools/Throughput/In", @names, OID_LTM_POOL_STAT_SERVER_BYTES_IN, snmp)
265
+ NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@names.size} Inbound Throughput metrics")
266
+
267
+ unless res.nil?
268
+ res.each_key do |metric|
269
+ @throughput_in_rate[metric] ||= NewRelic::Processor::EpochCounter.new
270
+ report[metric] = @throughput_in_rate[metric].process(res[metric] * 8)
271
+ end
272
+
273
+ sorted_report = report.sort_by { |k,v| v }.reverse
274
+ sorted_report.each_with_index do |row, index|
275
+ @f5_agent.report_metric row[0], "bits/sec", row[1]
276
+ break if index >= (MAX_RESULTS - 1)
277
+ end
278
+ end
183
279
  end
184
280
 
185
281
 
@@ -188,13 +284,26 @@ module NewRelic
188
284
  # Gather Throughput Outbound (returns in bits)
189
285
  #
190
286
  def get_throughput_out(snmp = nil)
287
+ @throughput_out_rate ||= { }
288
+ report = { }
191
289
  snmp = snmp_manager unless snmp
192
290
 
193
- get_names(snmp) if @pool_names.empty?
194
- res = gather_snmp_metrics_by_name("Pools/Throughput/Out", @pool_names, OID_LTM_POOL_STAT_SERVER_BYTES_OUT, snmp)
195
- res = res.each_key { |n| res[n] *= 8 }
196
- NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@pool_names.size} Outbound Throughput metrics")
197
- return res
291
+ get_names(snmp) if @names.empty?
292
+ res = gather_snmp_metrics_by_name("Pools/Throughput/Out", @names, OID_LTM_POOL_STAT_SERVER_BYTES_OUT, snmp)
293
+ NewRelic::PlatformLogger.debug("Pools: Got #{res.size}/#{@names.size} Outbound Throughput metrics")
294
+
295
+ unless res.nil?
296
+ res.each_key do |metric|
297
+ @throughput_out_rate[metric] ||= NewRelic::Processor::EpochCounter.new
298
+ report[metric] = @throughput_out_rate[metric].process(res[metric] * 8)
299
+ end
300
+
301
+ sorted_report = report.sort_by { |k,v| v }.reverse
302
+ sorted_report.each_with_index do |row, index|
303
+ @f5_agent.report_metric row[0], "bits/sec", row[1]
304
+ break if index >= (MAX_RESULTS - 1)
305
+ end
306
+ end
198
307
  end
199
308
 
200
309
  end
@@ -19,7 +19,7 @@ module NewRelic
19
19
  module F5Plugin
20
20
 
21
21
  class Rules
22
- attr_accessor :rule_names, :snmp_manager
22
+ attr_accessor :names, :snmp_manager
23
23
 
24
24
  OID_LTM_RULES = "1.3.6.1.4.1.3375.2.2.8"
25
25
  OID_LTM_RULE_STAT = "#{OID_LTM_RULES}.3"
@@ -37,7 +37,7 @@ module NewRelic
37
37
  # Init
38
38
  #
39
39
  def initialize(snmp = nil)
40
- @rule_names = [ ]
40
+ @names = [ ]
41
41
 
42
42
  if snmp
43
43
  @snmp_manager = snmp
@@ -48,6 +48,28 @@ module NewRelic
48
48
 
49
49
 
50
50
 
51
+ #
52
+ # Perform polling and reportings of metrics
53
+ #
54
+ def poll(agent, snmp)
55
+ @snmp_manager = snmp
56
+
57
+ unless get_names.empty?
58
+ rule_execs = get_executions
59
+ rule_execs.each_key { |m| agent.report_counter_metric m, "execs/sec", rule_execs[m] } unless rule_execs.nil?
60
+
61
+ rule_failures = get_failures
62
+ rule_failures.each_key { |m| agent.report_counter_metric m, "failures/sec", rule_failures[m] } unless rule_failures.nil?
63
+
64
+ rule_aborts = get_aborts
65
+ rule_aborts.each_key { |m| agent.report_counter_metric m, "aborts/sec", rule_aborts[m] } unless rule_aborts.nil?
66
+
67
+ rule_cycles = get_average_cycles
68
+ rule_cycles.each_key { |m| agent.report_metric m, "cycles", rule_cycles[m] } unless rule_cycles.nil?
69
+ end
70
+ end
71
+
72
+
51
73
  #
52
74
  # Get the list of iRule names
53
75
  #
@@ -55,18 +77,18 @@ module NewRelic
55
77
  snmp = snmp_manager unless snmp
56
78
 
57
79
  if snmp
58
- @rule_names.clear
80
+ @names.clear
59
81
 
60
82
  begin
61
83
  snmp.walk([OID_LTM_RULE_STAT_NAME, OID_LTM_RULE_STAT_TYPE]) do |rule, func|
62
- @rule_names.push("#{rule.value}/#{func.value}")
84
+ @names.push("#{rule.value}/#{func.value}")
63
85
  end
64
86
  rescue Exception => e
65
87
  NewRelic::PlatformLogger.error("Unable to gather iRule names with error: #{e}")
66
88
  end
67
89
 
68
- NewRelic::PlatformLogger.debug("Rules: Found #{@rule_names.size} iRules")
69
- return @rule_names
90
+ NewRelic::PlatformLogger.debug("Rules: Found #{@names.size} iRules")
91
+ return @names
70
92
  end
71
93
  end
72
94
 
@@ -78,9 +100,9 @@ module NewRelic
78
100
  def get_executions(snmp = nil)
79
101
  snmp = snmp_manager unless snmp
80
102
 
81
- get_names(snmp) if @rule_names.empty?
82
- res = gather_snmp_metrics_by_name("Rules/Executions", @rule_names, OID_LTM_RULE_STAT_TOT_EXEC, snmp)
83
- NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@rule_names.size} Execution metrics")
103
+ get_names(snmp) if @names.empty?
104
+ res = gather_snmp_metrics_by_name("Rules/Executions", @names, OID_LTM_RULE_STAT_TOT_EXEC, snmp)
105
+ NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@names.size} Execution metrics")
84
106
  return res
85
107
  end
86
108
 
@@ -92,9 +114,9 @@ module NewRelic
92
114
  def get_failures(snmp = nil)
93
115
  snmp = snmp_manager unless snmp
94
116
 
95
- get_names(snmp) if @rule_names.empty?
96
- res = gather_snmp_metrics_by_name("Rules/Failures", @rule_names, OID_LTM_RULE_STAT_FAILURES, snmp)
97
- NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@rule_names.size} Failure metrics")
117
+ get_names(snmp) if @names.empty?
118
+ res = gather_snmp_metrics_by_name("Rules/Failures", @names, OID_LTM_RULE_STAT_FAILURES, snmp)
119
+ NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@names.size} Failure metrics")
98
120
  return res
99
121
  end
100
122
 
@@ -106,9 +128,9 @@ module NewRelic
106
128
  def get_aborts(snmp = nil)
107
129
  snmp = snmp_manager unless snmp
108
130
 
109
- get_names(snmp) if @rule_names.empty?
110
- res = gather_snmp_metrics_by_name("Rules/Aborts", @rule_names, OID_LTM_RULE_STAT_ABORTS, snmp)
111
- NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@rule_names.size} Abort metrics")
131
+ get_names(snmp) if @names.empty?
132
+ res = gather_snmp_metrics_by_name("Rules/Aborts", @names, OID_LTM_RULE_STAT_ABORTS, snmp)
133
+ NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@names.size} Abort metrics")
112
134
  return res
113
135
  end
114
136
 
@@ -120,9 +142,9 @@ module NewRelic
120
142
  def get_average_cycles(snmp = nil)
121
143
  snmp = snmp_manager unless snmp
122
144
 
123
- get_names(snmp) if @rule_names.empty?
124
- res = gather_snmp_metrics_by_name("Rules/Time", @rule_names, OID_LTM_RULE_STAT_AVG_CYCLES, snmp)
125
- NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@rule_names.size} Average Cycle metrics")
145
+ get_names(snmp) if @names.empty?
146
+ res = gather_snmp_metrics_by_name("Rules/Time", @names, OID_LTM_RULE_STAT_AVG_CYCLES, snmp)
147
+ NewRelic::PlatformLogger.debug("Rules: Got #{res.size}/#{@names.size} Average Cycle metrics")
126
148
  return res
127
149
  end
128
150
 
@@ -52,6 +52,38 @@ module NewRelic
52
52
 
53
53
 
54
54
 
55
+ #
56
+ # Perform polling and reportings of metrics
57
+ #
58
+ def poll(agent, snmp)
59
+ @snmp_manager = snmp
60
+
61
+ unless get_names.empty?
62
+ snatpool_conns_max = get_conns_max
63
+ snatpool_conns_max.each_key { |m| agent.report_metric m, "conns", snatpool_conns_max[m] } unless snatpool_conns_max.nil?
64
+
65
+ snatpool_conns_current = get_conns_current
66
+ snatpool_conns_current.each_key { |m| agent.report_metric m, "conns", snatpool_conns_current[m] } unless snatpool_conns_current.nil?
67
+
68
+ snatpool_conns_total = get_conns_total
69
+ snatpool_conns_total.each_key { |m| agent.report_counter_metric m, "conn/sec", snatpool_conns_total[m] } unless snatpool_conns_total.nil?
70
+
71
+ snatpool_throughput_in = get_throughput_in
72
+ snatpool_throughput_in.each_key { |m| agent.report_counter_metric m, "bits/sec", snatpool_throughput_in[m] } unless snatpool_throughput_in.nil?
73
+
74
+ snatpool_throughput_out = get_throughput_out
75
+ snatpool_throughput_out.each_key { |m| agent.report_counter_metric m, "bits/sec", snatpool_throughput_out[m] } unless snatpool_throughput_out.nil?
76
+
77
+ snatpool_packets_in = get_packets_in
78
+ snatpool_packets_in.each_key { |m| agent.report_counter_metric m, "pkts/sec", snatpool_packets_in[m] } unless snatpool_packets_in.nil?
79
+
80
+ snatpool_packets_out = get_packets_out
81
+ snatpool_packets_out.each_key { |m| agent.report_counter_metric m, "pkts/sec", snatpool_packets_out[m] } unless snatpool_packets_out.nil?
82
+ end
83
+ end
84
+
85
+
86
+
55
87
  #
56
88
  # Get the list of Pool names
57
89
  #