def do_run(self, input_config): """ Executes the modular input :param input_config: :return: """ if not modular_input_should_run(self.session_key, logger=self.logger): self.logger.debug("Modular input will not run on this node.") return auth_type = get_splunk_auth_type(authtoken=self.session_key) if auth_type.decode('utf-8') != constants.SAML: self.logger.debug( "Deleting tokens modular input should not run on a non-SAML environment" ) return self.logger.info( "Running Delete tokens modular input on search captain node") delete_tokens_sync = DeleteTokensSync(self.session_key) try: delete_tokens_sync.run() except: self.logger.exception( "Failure encountered while running Delete Tokens sync")
def do_run(self, input_config): """ Executes the modular input :param input_config: :return: """ if not modular_input_should_run(self.session_key, logger=self.logger): self.logger.debug("Modular input will not run on this node.") return if get_splunk_auth_type(authtoken=self.session_key) == constants.SAML: self.logger.debug( "Registered Users List modular input should not run on SAML environment" ) return self.logger.info( "Running Registered Users List modular input on search captain node" ) registered_users_sync = RegisteredUsersSync(self.session_key) try: registered_users_sync.run() except: self.logger.exception( "Failure encountered while running Registered Users List sync")
def do_run(self, inputs): """ The entry point for the modular input. :param inputs: The command line arguments used when running this modular input. See the parent method definition for more details. """ # noinspection PyBroadException try: if not modular_input_should_run(self.session_key, LOGGER): LOGGER.debug('The AR modular input will not run on this host.') return uri = rest.makeSplunkdUri() _wait_for_kvstore_to_start(uri=uri, session_key=self.session_key, timeout_seconds=30) task.react(self._run_initialization, [AsyncClientFactory(uri)]) except SystemExit as e: if e.code != 0: LOGGER.exception( 'Exited AR modular input with non-zero exit_code=%d message=%s', e.code, e.message) else: LOGGER.debug( 'Successfully ran the AR initialization modular input.') except Exception: LOGGER.exception( 'Unhandled exception while running AR modular input.')
def do_run(self, input_config): """ Executes the modular input using the input config which specifies TTL for alerts """ if not modular_input_should_run(self.session_key, logger=self.logger): self.logger.debug("Modular input will not run on this node.") return self.logger.info("Running Alerts TTL modular input with input=%s" % str(input_config)) alerts_ttl_utility = AlertsTtlUtility( self.session_key, float(input_config[self.input_config_key][self.ttl_days])) alerts_ttl_utility.run()
def do_run(self, input_config): """ Main entry path for input """ self.logger.info("Running cloud gateway metrics modular input") if not modular_input_should_run(self.session_key, logger=self.logger): self.logger.debug("Modular input will not run on this node.") return try: time.sleep(30) collector = SpacebridgeaAppMetricsCollector( self.logger, self.session_key) collector.run() except: self.logger.exception("Exception calculating cloudgateway metrics")
def do_run(self, input_config): """ Executes the modular input :param input_config: :return: """ if not modular_input_should_run(self.session_key, logger=self.logger): self.logger.debug("Modular input will not run on this node.") return self.logger.debug("Running Subscription Clean Up modular input on search captain node") cleanup_time_seconds = input_config[self.input_config_key][self.config_key_cleanup_threshold_seconds] subscription_clean_up = SubscriptionCleanUp(self.session_key, int(cleanup_time_seconds)) try: subscription_clean_up.run() except: self.logger.exception("Failure encountered while running Subscription Clean Up")
def do_run(self, input_config): """ Executes the modular input :param input_config: :return: """ if not modular_input_should_run(self.session_key, logger=self.logger): self.logger.debug("Modular input will not run on this node.") return try: app_info = get_app_list_request(self.session_key, CLOUDGATEWAY_APP_NAME) if not app_info or app_info['entry'][0]['content']['disabled']: self.logger.debug( "Migration modular input will not run because no previous installation of Splunk Cloud Gateway") else: migration = Migration(self.session_key) migration.run() self.logger.debug("Finished running migration from Splunk Cloud Gateway to Splunk Secure Gateway") except Exception as e: self.logger.exception("Failure encountered while running Migration modular input")
def do_run(self, input_config): """ This will update the Device Role Mapping table in KV Store with the new mapping of a device to role :param input_config: :return: """ if not modular_input_should_run(self.session_key, logger=self.logger): self.logger.debug("Modular input will not run on this node.") return # Use default URI for Device Role Mapping try: uri = rest.makeSplunkdUri() except Exception as e: self.logger.exception( "Failed to generate default URI. {}".format(e)) if not uri: return try: async_client_factory = AsyncClientFactory(uri) kvstore_client = async_client_factory.kvstore_client() splunk_client = async_client_factory.splunk_client() asyncio.run(update(self.session_key, kvstore_client, splunk_client)) except SystemExit as e: if e.code == 0: self.logger.debug( "device to role mapping updated successfully with code={}". format(str(e.code))) else: self.logger.error( "device to role mapping update failed with error={}". format(str(e))) except: self.logger.exception( "Unexpected exception in device to role mapping")