Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
feat: send all walk to events (#194)
Browse files Browse the repository at this point in the history
* feat: send all walk to events

* fix: build fix
  • Loading branch information
weliasz authored Nov 9, 2021
1 parent b0c84a0 commit 9166792
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .run/scheduler.run.xml
Original file line number Diff line number Diff line change
@@ -24,6 +24,8 @@
<env name="CELERY_BROKER_URL" value="localhost" />
<env name="MONGO_URI" value="mongodb://localhost:27017" />
<env name="MIBS_SERVER_URL" value="http://localhost:5000" />
<env name="OTEL_SERVER_METRICS_URL" value="http://localhost:8882" />
<env name="OTEL_SERVER_LOGS_URL" value="http://localhost:8881" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/splunk_connect_for_snmp_poller" />
11 changes: 6 additions & 5 deletions splunk_connect_for_snmp_poller/manager/static/mib_enricher.py
Original file line number Diff line number Diff line change
@@ -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:
11 changes: 8 additions & 3 deletions splunk_connect_for_snmp_poller/manager/task_utilities.py
Original file line number Diff line number Diff line change
@@ -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,

0 comments on commit 9166792

Please sign in to comment.