From 54a4a70b350536d15d7e8cd9b7282821f75d030e Mon Sep 17 00:00:00 2001 From: Yuan Ling <32370701+lingy1028@users.noreply.github.com> Date: Wed, 19 May 2021 04:43:06 -0400 Subject: [PATCH] fix: moved indexes from config yaml to args (#73) * fix: fixed bug in passing aargs to format_value_for_mib_server() * fix: move index from cconfig yaml to args --- splunk_connect_for_snmp_traps/manager/hec_sender.py | 3 ++- splunk_connect_for_snmp_traps/manager/mib_server_client.py | 2 +- splunk_connect_for_snmp_traps/snmp_trap_server.py | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/splunk_connect_for_snmp_traps/manager/hec_sender.py b/splunk_connect_for_snmp_traps/manager/hec_sender.py index ca50b0d..76660b5 100644 --- a/splunk_connect_for_snmp_traps/manager/hec_sender.py +++ b/splunk_connect_for_snmp_traps/manager/hec_sender.py @@ -25,6 +25,7 @@ def configure_thread_pool(self): user_suggested_working_threads = self._args.hec_threads max_workers = max_allowed_working_threads(user_suggested_working_threads) logger.debug(f"Configured a thread-pool with {max_workers} concurrent threads") + logger.debug(f"Configured Splunk index for SNMP traps: {self._args.index}") return concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) def get_session(self): @@ -37,7 +38,7 @@ def post_data_to_thread_pool(self, host, variables_binds): "time": time.time(), "sourcetype": "sc4snmp:traps", "host": host, - "index": self._server_config["splunk"]["index"], + "index": self._args.index, "event": variables_binds, } diff --git a/splunk_connect_for_snmp_traps/manager/mib_server_client.py b/splunk_connect_for_snmp_traps/manager/mib_server_client.py index 0b33225..3d01455 100644 --- a/splunk_connect_for_snmp_traps/manager/mib_server_client.py +++ b/splunk_connect_for_snmp_traps/manager/mib_server_client.py @@ -25,7 +25,7 @@ def get_translation(var_binds, mib_server_url): var_bind = { "oid": str(name), "oid_type": name.__class__.__name__, - "val": format_value_for_mib_server(val), + "val": format_value_for_mib_server(val, val.__class__.__name__), "val_type": val.__class__.__name__, } var_binds_list.append(var_bind) diff --git a/splunk_connect_for_snmp_traps/snmp_trap_server.py b/splunk_connect_for_snmp_traps/snmp_trap_server.py index 2b68ad4..12ca27f 100644 --- a/splunk_connect_for_snmp_traps/snmp_trap_server.py +++ b/splunk_connect_for_snmp_traps/snmp_trap_server.py @@ -32,6 +32,10 @@ def main(): ) parser.add_argument("-c", "--config", default="config.yaml", help="Config File") + parser.add_argument( + "-i", "--index", default="##EVENTS_INDEX##", help="Index for traps" + ) + args = parser.parse_args() log_level = args.loglevel.upper()