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
Legend

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
Legend

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
Legend

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
Legend

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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...