Is it possible to create a scripted input that is launched directly from splunkd and not from a shell? I've tried shell script, a python script, and a .path file, and they all seem to be wrapped by a " /bin/sh -c <MY_COMMAND> " wrapper shell.
I have long-running scripted input, and the process is not being shutdown when splunkd restarts, which I think is due to the extra sh process not passing down the kill signal to my process.
Update / Additional info:
I know that splunkd is stopping the shell whenever splunkd is shutdown or whenever the scripted-input is disabled. (Note: To save time during testing, I've been enabling and disabling my scripted input stanza in inputs.conf , then issuing the the following refresh link: http://mysplunkserver:8000/en-US/debug/refresh?entity=admin%2Fscript , which has been working like a charm.) Whenever the input is disabled (or splunkd shutdown), the shell wrapper process goes away, but the child process (aka, my scripted input program) continues to run. But instead of my process being a grandchild of splunkd , now it's directly under process 1 (init).
Here are two examples showing the processes running on my system (output generated by pstree -A -p ).
Example 1: This shows my scripted input when it's enabled. My scripted input process is pid 4177, with several threads.
init(1)-+
|-splunkd(2642)-+-splunkd(2643)-+-sh(4176)---java(4177)-+-{java}(4185)
| | | |-{java}(4186)
| | | |-{java}(4187)
| | | |-{java}(4188)
| | | |-{java}(4189)
| | | |-{java}(4191)
| | | |-{java}(4194)
| | | |-{java}(4195)
| | | |-{java}(4201)
| | | |-{java}(4202)
| | | |-{java}(4203)
| | | |-{java}(4204)
| | | |-{java}(4205)
| | | |-{java}(4207)
| | | `-{java}(4211)
Example 2: I then disabled by input ( disabled=1 in inputs.conf ), then refreshed the "admin/script" entities, and now my process tree looks as follows: (Note that the "java" process is now owned by init, and the wrapper shell (4176) is now gone.
init(1)-+
|-java(4177)-+-{java}(4185)
| |-{java}(4186)
| |-{java}(4187)
| |-{java}(4188)
| |-{java}(4189)
| |-{java}(4191)
| |-{java}(4194)
| |-{java}(4195)
| |-{java}(4201)
| |-{java}(4202)
| |-{java}(4203)
| |-{java}(4204)
| |-{java}(4205)
| |-{java}(4207)
| `-{java}(4211)
|-splunkd(2642)-+-splunkd(2643)
The problem seems to be that the wrapper shell ( /bin/sh ) is simply not passing on the kill request.
Note: As shown above, I'm using my own wrapper script to setup the environment and launching the java executable using exec to prevent an additional shell layer in the mix. I've messed around with using traps and such (when I wasn't using exec , of course), but ultimately if the parent process (aka the /bin/sh wrapper shell) doesn't pass down the signal, there's nothing to trap. My only other option is implementing some kind of polling mechanism to see if my parent process is dead. So once again, I'm back to: How do I turn off that annoying wrapper shell and keep things simple?
I'm running Splunk 4.1.8 on Ubuntu 8.04 (32 bit) and /bin/sh is currently using dash (which is the Ubuntu default)
... View more