Hi ninjas ;-)
I have a quite tricky question and I'm wondering if this is a bug with the script handling of splunk. I have a scripted input (which is a python script) that opens a tcp server socket (listens on a tcp port). The script generates events and sends them to stdout. The problem is when I restart splunk or disable the scripted input via the manager the python script keeps running. I've tried to configure all interval settings that made sence IMO (-1, 0 and 1) but none of them worked. Once the splunk server is restarted or the input is re-enabled the script crashed because the port is already in use by the previously started script.
before stopping splunk:
$ ps -ef | grep myscript
root 1734 1582 0 21:58 ? 00:00:00 /bin/sh -c python /opt/splunk/etc/apps/myapp/bin/myscript.py
root 1735 1734 0 21:58 ? 00:00:00 python /opt/splunk/etc/apps/myapp/bin/myscript.py
after stopping splunk:
$ ps -ef | grep myscript
root 1735 1 0 21:58 ? 00:00:00 python /opt/splunk/etc/apps/myapp/bin/myscript.py
Is there a way for the python script to detect that it's not attached to the splunk instance anymore? One solution that crossed my mind is to observe the parent process id but I don't like this solution as it will only work on *NIX or at least I haven't figured a way to do it on windows yet.
Any hints greatly appreciated!
Cheers, Siegfried
Tags: python, scripted-input
-
▶ Reply to This