Getting Data In

Windows/Linux scripted inputs and setup.xml

bojanz
Communicator

Hi,

I'm building an application that should work both on Linux/Unix Splunk installations as well as Windows.
The application uses several external python scripts to pull/populate indexes.

On Linux, these can be easily defined as follows:

[script://$SPLUNK_HOME/etc/apps/myapp/bin/pull_logs.py]
interval = 15 15 * * *
index = myindex
sourcetype = mysourcetype

However, the problem is that Splunk on Windows doesn't understand the path and refuses to run the script with the following error:

06-24-2012 18:16:12.580 +0200 ERROR FrameworkUtils - Incorrect path to script: C:\Program Files\Splunk/etc/apps/myapp/bin/pull_logs.py.  Script must be in a bin subdirectory in $SPLUNK_HOME.
06-24-2012 18:16:12.580 +0200 ERROR ExecProcessor - Ignoring: ""C:\Program Files\Splunk/etc/apps/myapp/bin/pull_logs.py""

In order to get it to work, I have to change the paths to contain backslash.
However, then I'm having problems with the setup endpoint which is like this:

<block title="Myapp" endpoint="data/inputs/script" entity="%24SPLUNK_HOME%252Fetc%252Fapps%252Fmyapp%252Fbin%252Fpull_logs.py">

Is there a recommended way on doing this?

Tags (1)
0 Karma
1 Solution

Drainy
Champion

Ok well firstly you could just create an inputs for both locations, one will show as an error for not being found but the other will work - the proper way to do this is to have a custom python setup handler to check what system is running and write through an endpoint to the inputs.conf for the correct location.

Secondly, I don't have time to go check the docs but the slashes in the endpoint registration shouldn't matter as you are referencing your registered endpoint from restmap.conf and not directly to the script.

View solution in original post

Drainy
Champion

Ok well firstly you could just create an inputs for both locations, one will show as an error for not being found but the other will work - the proper way to do this is to have a custom python setup handler to check what system is running and write through an endpoint to the inputs.conf for the correct location.

Secondly, I don't have time to go check the docs but the slashes in the endpoint registration shouldn't matter as you are referencing your registered endpoint from restmap.conf and not directly to the script.

Drainy
Champion

No worries, glad you've got it going!

0 Karma

bojanz
Communicator

Thanks, that seems to be the way. I wrote a custom python setup handler that takes care of the OS and sets up a proper inputs.conf file in local.

0 Karma
Get Updates on the Splunk Community!

Financial Services Industry Use Cases, ITSI Best Practices, and More New Articles ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Splunk Federated Analytics for Amazon Security Lake

Thursday, November 21, 2024  |  11AM PT / 2PM ET Register Now Join our session to see the technical ...

Splunk With AppDynamics - Meet the New IT (And Engineering) Couple

Wednesday, November 20, 2024  |  10AM PT / 1PM ET Register Now Join us in this session to learn all about ...