Ho hortonew,
I agree the path could be a problem. Add some debugging to your script like this:
#myDebug="no" # debug disabled
myDebug="yes" # debug enabled
# get SPLUNK_HOME form OS
SPLUNK_HOME = os.environ['SPLUNK_HOME']
# get myScript name and path
myScript = os.path.basename(__file__)
myPath = os.path.dirname(os.path.realpath(__file__))
# define the logger to write into log file
def setup_logging(n):
logger = logging.getLogger(n)
if myDebug == "yes":
logger.setLevel(logging.DEBUG)
else:
logger.setLevel(logging.ERROR)
LOGGING_DEFAULT_CONFIG_FILE = os.path.join(SPLUNK_HOME, 'etc', 'log.cfg')
LOGGING_LOCAL_CONFIG_FILE = os.path.join(SPLUNK_HOME, 'etc', 'log-local.cfg')
LOGGING_STANZA_NAME = 'python'
LOGGING_FILE_NAME = "%s.log" % myScript
BASE_LOG_PATH = os.path.join('var', 'log', 'splunk')
LOGGING_FORMAT = "%(asctime)s %(levelname)-s\t%(module)s:%(lineno)d - %(message)s"
splunk_log_handler = logging.handlers.RotatingFileHandler(os.path.join(SPLUNK_HOME, BASE_LOG_PATH, LOGGING_FILE_NAME), mode='a')
splunk_log_handler.setFormatter(logging.Formatter(LOGGING_FORMAT))
logger.addHandler(splunk_log_handler)
splunk.setupSplunkLogger(logger, LOGGING_DEFAULT_CONFIG_FILE, LOGGING_LOCAL_CONFIG_FILE, LOGGING_STANZA_NAME)
return logger
# start the logger for troubleshooting
if myDebug == "yes": logger = setup_logging( "Logger started ..." ) # logger
This will produce a logfile for your script in $SPLUNK_HOME/var/log/splunk/
Hope this helps ...
cheers, MuS
... View more