From 9166792255a9d4b421f265a244cf2391a00dee4a Mon Sep 17 00:00:00 2001
From: weliasz <77732905+weliasz@users.noreply.github.com>
Date: Tue, 9 Nov 2021 13:37:52 +0100
Subject: [PATCH] feat: send all walk to events (#194)
* feat: send all walk to events
* fix: build fix
---
.run/scheduler.run.xml | 2 ++
.../manager/static/mib_enricher.py | 11 ++++++-----
.../manager/task_utilities.py | 11 ++++++++---
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/.run/scheduler.run.xml b/.run/scheduler.run.xml
index febe978..b9cf48f 100644
--- a/.run/scheduler.run.xml
+++ b/.run/scheduler.run.xml
@@ -24,6 +24,8 @@
+
+
diff --git a/splunk_connect_for_snmp_poller/manager/static/mib_enricher.py b/splunk_connect_for_snmp_poller/manager/static/mib_enricher.py
index af97033..8375a1b 100644
--- a/splunk_connect_for_snmp_poller/manager/static/mib_enricher.py
+++ b/splunk_connect_for_snmp_poller/manager/static/mib_enricher.py
@@ -76,11 +76,12 @@ def __enrich_if_mib_additional(self, metric_name, parsed_index):
for oid_family in self._mib_static_data_collection.keys():
if oid_family in metric_name:
try:
- index = extract_current_index_from_metric(parsed_index) + 1
- index_field = self.get_by_oid_and_type(
- oid_family, enricher_additional_varbinds
- )["indexNum"]
- return [{index_field: index}]
+ index = extract_current_index_from_metric(parsed_index)
+ if index is not None:
+ index_field = self.get_by_oid_and_type(
+ oid_family, enricher_additional_varbinds
+ )["indexNum"]
+ return [{index_field: index + 1}]
except KeyError:
logger.debug("Enricher additionalVarBinds badly formatted")
except TypeError:
diff --git a/splunk_connect_for_snmp_poller/manager/task_utilities.py b/splunk_connect_for_snmp_poller/manager/task_utilities.py
index 947187d..e76a3e5 100644
--- a/splunk_connect_for_snmp_poller/manager/task_utilities.py
+++ b/splunk_connect_for_snmp_poller/manager/task_utilities.py
@@ -79,7 +79,9 @@ def is_metric_data(value):
return False
-def get_translated_string(mib_server_url, var_binds, return_multimetric=False):
+def get_translated_string(
+ mib_server_url, var_binds, return_multimetric=False, force_event=False
+):
"""
Get the translated/formatted var_binds string depending on whether the var_binds is an event or metric
Note: if it failed to get translation, return the the original var_binds
@@ -88,6 +90,7 @@ def get_translated_string(mib_server_url, var_binds, return_multimetric=False):
"""
logger.debug(f"Getting translation for the following var_binds: {var_binds}")
is_metric, result = result_without_translation(var_binds, return_multimetric)
+ is_metric = False if force_event else is_metric
original_varbinds = is_metric, result
# Override the var_binds string with translated var_binds string
try:
@@ -490,12 +493,14 @@ def walk_handler(
error_in_one_time_walk = True
break
else:
- result, is_metric = get_translated_string(mib_server_url, var_binds)
+ result, is_metric = get_translated_string(
+ mib_server_url, var_binds, force_event=True
+ )
post_data_to_splunk_hec(
hec_sender,
host,
result,
- is_metric,
+ False,
index,
ir,
additional_metric_fields,