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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...