from .fields import (BooleanField, Field, FieldValidationException, IntervalField) try: from splunk.clilib.bundle_paths import make_splunkhome_path except ImportError: from splunk.appserver.mrsparkle.lib.util import make_splunkhome_path if 'slave' in splunk.clilib.cli_common.getMergedConf('server').get('clustering', {}).get('mode', {}): sys.path.append(os.path.join(get_slaveapps_base_path(), "@appname@", "lib")) else: sys.path.append(make_splunkhome_path(["etc", "apps", "@appname@", "lib"])) # Define logger using the name of the script here, versus in the modular_input class. # logger = log.setup_logger(name='python_modular_input', level=logging.INFO) logger = setupLogger(logger=None, log_format='%(asctime)s %(levelname)s [ModularInput] %(message)s', level=logging.INFO, log_name="python_modular_input.log", logger_name="modinput") class ModularInputConfig(object): def __init__(self, server_host, server_uri, session_key, checkpoint_dir, configuration): self.server_host = server_host self.server_uri = server_uri self.session_key = session_key self.checkpoint_dir = checkpoint_dir self.configuration = configuration def __str__(self): attrs = ['server_host', 'server_uri', 'session_key', 'checkpoint_dir', 'configuration'] return str({attr: str(getattr(self, attr)) for attr in attrs}) @staticmethod
sys.path.insert(0, make_splunkhome_path(['etc', 'apps', 'SA-Eventgen', 'lib'])) sys.path.insert( 0, make_splunkhome_path( ['etc', 'apps', 'SA-Eventgen', 'lib', 'splunk_eventgen', 'lib'])) from mod_input import ModularInput # noqa isort:skip from mod_input.fields import VerbosityField # noqa isort:skip from splunk_eventgen import eventgen_core # noqa isort:skip from splunk_eventgen.lib import eventgenconfig # noqa isort:skip from xmloutput import XMLOutputManager, setupLogger # noqa isort:skip # Initialize logging logger = setupLogger( logger=None, log_format='%(asctime)s %(levelname)s [Eventgen] %(message)s', level=logging.DEBUG, log_name="modinput_eventgen.log", logger_name="eventgen_app") class SimpleNamespace(dict): """dot.notation access to dictionary attributes""" __getattr__ = dict.get __setattr__ = dict.__setitem__ __delattr__ = dict.__delitem__ class Eventgen(ModularInput): scheme_args = { 'title': "SA-Eventgen", 'description': "This modular input generates data for Splunk.",
from .fields import FieldValidationException from .fields import FloatField from .fields import IntegerField from .fields import IntervalField from .fields import ListField from .fields import RangeField from .fields import RegexField from .fields import SeverityField from xmloutput import setupLogger, XMLOutputManager # Define logger using the name of the script here, versus in the modular_input class. #logger = log.setup_logger(name='python_modular_input', level=logging.INFO) logger = setupLogger( logger=None, log_format='%(asctime)s %(levelname)s [ModularInput] %(message)s', level=logging.INFO, log_name="python_modular_input.log", logger_name="modinput") class ModularInputConfig(object): def __init__(self, server_host, server_uri, session_key, checkpoint_dir, configuration): self.server_host = server_host self.server_uri = server_uri self.session_key = session_key self.checkpoint_dir = checkpoint_dir self.configuration = configuration def __str__(self): attrs = [