# Copyright (C) 2005-2024 Splunk Inc. All Rights Reserved. import sys from splunk.clilib.bundle_paths import make_splunkhome_path sys.path.append(make_splunkhome_path(['etc', 'apps', 'SA-ITOA', 'lib'])) sys.path.append(make_splunkhome_path(['etc', 'apps', 'SA-ITOA', 'lib', 'SA_ITOA_app_common'])) from itsi_py3 import _ from ITOA.itoa_common import modular_input_should_run, is_feature_enabled from ITOA.setup_logging import getLogger4ModInput from SA_ITOA_app_common.solnlib.modular_input import ModularInput from itsi.itsi_utils import ITOAInterfaceUtils from ITOA.mod_input_utils import skip_run_during_migration from ITOA.event_management.notable_event_aggregation_policy import NotableEventAggregationPolicy from itsi.upgrade.constants import NEW_VERSION class ItsiHighScaleEA(ModularInput): """ Modular Input that performs operations which are required for High Scale Event Analytics to work" """ title = _('IT Service Intelligence High Scale Event Analytics Modular Input') description = _('Modular Input to populate NEAPs & disable classic rules engine java process.') handlers = None app = 'SA-ITOA' name = 'itsi_high_scale_ea' use_single_instance = False use_kvstore_checkpointer = False use_hec_event_writer = False owner = 'nobody' def extra_arguments(self): return [{ 'name': "log_level", 'title': _("Logging Level"), 'description': _("This is the level at which the modular input will log data.")}] @skip_run_during_migration def do_run(self, input_config): """ - This is the method called by splunkd when mod input is enabled. @param input_config: config passed down by splunkd """ logger = getLogger4ModInput(input_config) logger.info('Populating NEAPs on first time and disabling classic rules engine java process if itsi-high-scale-ea is enabled') is_high_scale_ea_enabled = is_feature_enabled('itsi-high-scale-ea', self.session_key) if modular_input_should_run(self.session_key, logger): ITOAInterfaceUtils.enable_disable_high_scale(self.session_key, logger, is_high_scale_ea_enabled) self.send_neaps_to_ingest_service() else: logger.info("ItsiHighScaleEA modular input will not run on this node.") def send_neaps_to_ingest_service(self): notable_event_aggrigation_policy = NotableEventAggregationPolicy(self.session_key) notable_event_aggrigation_policy.send_neaps_to_ingest_service() if __name__ == "__main__": worker = ItsiHighScaleEA() worker.execute() sys.exit(0)