`!/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]
sourcetype = status
index=tool_status
interval = 30
please let me know if am doing any mistake.
Thanks for the Help!!!!!
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.
Please edit your question to format your code. Highlight it and click the code button (labeled 101010).