Getting Data In

Configured .sh scripts not being run/reporting data

joewetzel63
Loves-to-Learn

I created .sh scripts that do the following:

#!/bin/bash

# Name of the service to monitor
SERVICE_NAME="tomcat9"

# Check if the service is running
SERVICE_STATUS=$(systemctl is-active "$SERVICE_NAME.service")

# Output status for Splunk
if [ "$SERVICE_STATUS" == "active" ]; then
echo "$(date): Service $SERVICE_NAME is running."
else
echo "$(date): Service $SERVICE_NAME is NOT running."
fi



The above is obviously what Im using for Tomcat but I have others all doing the thing just different service names. These scripts reside in:

/opt/splunkforwarder/bin/scripts

Additionally I have configured these scripts to be run in /opt/splunkforwarder/etc/system/local/inputs.conf an example of what that looks like is below:

[script:///opt/splunkforwarder/bin/scripts/monitor_service_<service_name>.sh]

disabled = false
interval = 60
index = services
sourcetype = service_status



As you can see I also have configured the following:

index = services
sourcetype = service_status


These are also configured in Splunk Enterprise respectively and the index is configured for Search, in linux  Splunk is the owner and the group is also Splunk. Additionally all of the scripts are executable and successfully run when I test them, however none of this data seems to be passed from the forwarder as none of the expected data is returned including the recognition of the index and sourcetype in Search.  Additionally I have attached a screen capture of splunkd.log showing the scripts as being recognized.  

2025-01-24_08-46-50.png

Labels (1)
0 Karma

splunkreal
Influencer

Hello, as best practise you should create and deploy an app from deployment server with your inputs.conf and script. Also make sure you include a valid timestamp at the beginning of the output in US format.

Follow these instructions : https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/custominputs/scriptedinputsexampl...

* If this helps, please upvote or accept solution if it solved *
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Yes, packaging your content into an app is a good practice but it shouldn't matter much if it's in apps/<app>/local or system/local for actually running the config (unless the settings get overwritten of course).

And no, timestamp doesn't have to be in US format. That's what time parsing sourcetype settings are for.

But back to the @joewetzel63 's issue - did you try running the script "as Splunk"? With

splunk cmd /opt/splunkforwarder/bin/scripts/whatever.sh
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!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...