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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...