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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...