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

Commit

Permalink
fix: default event formatting (#155)
Browse files Browse the repository at this point in the history
* fix: default event formatting

* fix: build fix

* fix: build fix
  • Loading branch information
weliasz authored Oct 18, 2021
1 parent 4602304 commit ed96f44
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
5 changes: 4 additions & 1 deletion splunk_connect_for_snmp_poller/manager/poller.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
get_profiles,
)
from splunk_connect_for_snmp_poller.manager.tasks import snmp_polling
from splunk_connect_for_snmp_poller.manager.validator.inventory_validator import (
DYNAMIC_PROFILE,
)
from splunk_connect_for_snmp_poller.mongo import WalkedHostsRepository
from splunk_connect_for_snmp_poller.utilities import (
file_was_modified,
Expand Down Expand Up @@ -114,7 +117,7 @@ def __check_inventory(self):
)
continue
inventory_hosts.add(entry_key)
if ir.profile == "*":
if ir.profile == DYNAMIC_PROFILE:
self.delete_all_entries_per_host(ir.host)
self.add_device_for_profile_matching(ir)
else:
Expand Down
5 changes: 4 additions & 1 deletion splunk_connect_for_snmp_poller/manager/poller_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from splunk_connect_for_snmp_poller.manager.task_utilities import parse_port
from splunk_connect_for_snmp_poller.manager.tasks import snmp_polling
from splunk_connect_for_snmp_poller.manager.validator.inventory_validator import (
DYNAMIC_PROFILE,
is_valid_inventory_line_from_dict,
should_process_inventory_line,
)
Expand Down Expand Up @@ -75,7 +76,9 @@ def parse_inventory_file(inventory_file_path, profiles, fetch_frequency=True):
agent["version"],
agent["community"],
agent["profile"],
get_frequency(agent, profiles, 60) if fetch_frequency else None,
get_frequency(agent, profiles, 60)
if fetch_frequency and agent["profile"] != DYNAMIC_PROFILE
else None,
)


Expand Down
18 changes: 17 additions & 1 deletion splunk_connect_for_snmp_poller/manager/task_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
)
from splunk_connect_for_snmp_poller.manager.hec_sender import post_data_to_splunk_hec
from splunk_connect_for_snmp_poller.manager.mib_server_client import get_translation
from splunk_connect_for_snmp_poller.manager.realtime.interface_mib import InterfaceMib
from splunk_connect_for_snmp_poller.manager.realtime.oid_constant import OidConstant
from splunk_connect_for_snmp_poller.manager.static.interface_mib_utililities import (
extract_network_interface_data_from_additional_config,
Expand Down Expand Up @@ -130,9 +131,24 @@ async def result_without_translation(var_binds):
}
result = json.dumps(result)
else:
result = '{{"metric": \'{{"{oid}":"{value}"}}\'}}'.format(
metric_content_dict = {
name.prettyPrint(): val.prettyPrint(),
InterfaceMib.METRIC_NAME_KEY: name.prettyPrint(),
}

metric_content = json.dumps(metric_content_dict)

non_metric_content = '{oid}="{value}"'.format(
oid=name.prettyPrint(), value=val.prettyPrint()
)

result_dict = {
"metric": metric_content,
"non_metric": non_metric_content,
"metric_name": name.prettyPrint(),
}

result = json.dumps(result_dict)
logger.debug("Our result is_metric - %s and string - %s", is_metric, result)
return is_metric, result

Expand Down

0 comments on commit ed96f44

Please sign in to comment.