Getting Data In

splunk shell scripted input not working

saifuddin9122
Path Finder
`!/bin/sh
touch $SPLUNK_HOME/etc/apps/check-status-inputs/status.txt
SERVICE_STATUS=`systemctl status stackdriver-agent | grep active &> /dev/null`
STATUS=$?
if [ ${STATUS} -eq 0 ]
then
echo "${SERVICE_STATUS}"
else
#echo "Service is not running.."
status_new="Service is not running.."
fi
my_hostname=`hostname`
cur_date=`date`
echo "$cur_date - $my_hostname - $status_new" >> $SPLUNK_HOME/etc/apps/check-status-inputs/status.txt
#echo "$cur_date - $my_hostname - $status_new"`

Hello All,

i have created app with a script which creates a text file and write the output of the script to that text file and reads the event from file and send to splunk. i'm doing all this using splunk universal forwarder. if run it manually it is working fine but not if i use inputs.conf.

here is my app structure

$SPLUNK_HOME/etc/apps -->
check-status-inputs -->
bin local metadata

and my inputs.conf is

[script://./bin/check_status.sh]

disabled = false

sourcetype = status
index=tool_status
interval = 30

please let me know if am doing any mistake.
Thanks for the Help!!!!!

0 Karma

micahkemp
Champion

The posted script won't return anything to splunk. Instead it writes to a file (that you probably don't have Splunk configured to monitor). I see commented out lines that suggest you may have tried this or something similar, but try having your script only echo to stdout instead of redirecting to a file.

micahkemp
Champion

Please edit your question to format your code. Highlight it and click the code button (labeled 101010).

0 Karma
Get Updates on the Splunk Community!

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...

AI for AppInspect

We’re excited to announce two new updates to AppInspect designed to save you time and make the app approval ...

App Platform's 2025 Year in Review: A Year of Innovation, Growth, and Community

As we step into 2026, it’s the perfect moment to reflect on what an extraordinary year 2025 was for the Splunk ...