I am writing my own search command and writing a python scripts for that. To start with, I am reading the results and writing to a log file. I see the same results are being logged twice. I also printed the os.getpid() and see that was different in both the calls.
I turned the streaming = true in commands.conf, I still see the script is being called twice but this time results were empty in one of the calls.
Please let me know what should I do to fix this problem?
import sys, os, gzip, csv, time, traceback
import splunk.Intersplunk
def logger(string):
log.write(string + "\n")
return 0
log = open(os.path.join(os.environ["SPLUNK_HOME"], 'var', 'log', 'splunk','my_results.log'), 'a')
results = splunk.Intersplunk.getOrganizedResults()
logger("called" + str(os.getpid()))
logger((str(results))
splunk.Intersplunk.outputResults(results)
... View more