Getting Data In

Why my inputs.conf doesn't run?

sjlin
Explorer

I have a starter_script.bat in $splunk_home\etc\apps\MyApp\bin, and its content are:
@echo off
python "C:\Program Files\Splunk\etc\apps\MyApp\bin\execute.py" arg1 arg2

and the $splunk_home\etc\apps\MyApp\default\inputs.conf:

[script://.\bin\starter_script.bat]
disabled = false
interval = 10
index = default

after restart inputs.conf, I use the command "splunk.exe cmd btool inputs list" to see if the bat is running, and I can see that:

[script://C:\Program Files\Splunk\etc\apps\MyApp\bin\starter_script.bat]
_rcvbuf = 1572864
disabled = false
evt_dc_name =
evt_dns_name =
evt_resolve_ad_obj = 0
host = WIN-MyHost
index = default
interval = 10

The .bat is not working, but I am sure it can be working when I try it manually.
I am wondering if any configuration I set is wrong?
Any response is appreciated.

Tags (3)
0 Karma

MuS
SplunkTrust
SplunkTrust

Hi sjlin,

use this as start script for your input:

$SPLUNK_HOME\bin\splunk cmd python execute.py arg1 arg2

this way all Splunk relevant environment settings are made and the script will be executed as Splunk user.
Or you call/start your execute.py directly and use $SPLUNK_HOME\bin\python as shebang ...
like this:

$SPLUNK_HOME\bin\python execute.py arg1 arg2

hope this helps ...

cheers, MuS

MuS
SplunkTrust
SplunkTrust

since your on windows your path must look like this:

[script://.\bin\execute.py arg1 arg2]

sjlin
Explorer

I change inputs.conf as:
[script://.\bin\execute.py arg1 arg2]
disabled = false
interval = 10
index = default

and add #!$SPLUNK_HOME\bin\python to the first line of execute.py

It is still not working...
I have read http://docs.splunk.com/Documentation/Splunk/latest/AdvancedDev/ScriptWriting, but I can't get something useful...

0 Karma

MuS
SplunkTrust
SplunkTrust

no, you can call your execute.py as input script. place #!$SPLUNK_HOME\bin\python at the first line of execute.py

if it still fails, read this http://docs.splunk.com/Documentation/Splunk/latest/AdvancedDev/ScriptWriting

0 Karma

sjlin
Explorer

Do you mean modify inputs.conf as below?
[script://$SPLUNK_HOME\bin\python $SPLUNK_HOME\etc\apps\MyApp\bin\execute.py arg1 arg2]
disabled = false
interval = 10
index = default

And I find some error message in splunkd.log in either way:
03-17-2014 19:40:01.181 +0800 ERROR ExecProcessor - Ignoring: ""C:\Program Files\Splunk\bin\python" "C:\Program Files\Splunk\etc\apps\MyApp\bin\execute.py" arg1 arg2"

0 Karma

MuS
SplunkTrust
SplunkTrust

why are you using a .bat to start a python script? start the python script directly instead

0 Karma

sjlin
Explorer

Thanks for your reply.
I modify the bat as:
@echo off
"C:\Program Files\Splunk\bin\python" "C:\Program Files\Splunk\etc\apps\MyApp\bin\execute.py" arg1 arg2

and
@echo off
"C:\Program Files\Splunk\bin\splunk" cmd python "C:\Program Files\Splunk\etc\apps\MyApp\bin\execute.py" arg1 arg2

It seems like the neither of the two ways is working...

0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...