Skip to content

Commit 80b3cca

Browse files
author
Anze
committed
Send SNMP results to Grafolean only once per entity (instead of once per sensor)
1 parent ba6df9a commit 80b3cca

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

snmpbot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def do_snmp(*args, **job_info):
276276
# filter out only those sensors that are supposed to run at this interval:
277277
affecting_intervals, = args
278278
activated_sensors = [s for s in job_info["sensors"] if s["interval"] in affecting_intervals]
279+
values = []
279280
for sensor in activated_sensors:
280281
results = []
281282
oids = [o["oid"] for o in sensor["sensor_details"]["oids"]]
@@ -301,8 +302,10 @@ def do_snmp(*args, **job_info):
301302
# GET was used, we get one.
302303
expression = sensor["sensor_details"]["expression"]
303304
output_path = f'entity.{job_info["entity_id"]}.snmp.{sensor["sensor_details"]["output_path"]}'
304-
values = _apply_expression_to_results(results_no_counters, methods, expression, output_path)
305-
send_results_to_grafolean(job_info['backend_url'], job_info['bot_token'], job_info['account_id'], values)
305+
new_values = _apply_expression_to_results(results_no_counters, methods, expression, output_path)
306+
values.extend(new_values)
307+
308+
send_results_to_grafolean(job_info['backend_url'], job_info['bot_token'], job_info['account_id'], values)
306309

307310

308311
def jobs(self):

0 commit comments

Comments
 (0)