Getting Data In

Deploy custom script, then upload the results

mlorrette
Path Finder

Newbie here. How can I output the result of a bash script back into Splunk? The script periodically sends netstat commands.

Tags (1)
0 Karma
1 Solution

98123722
Explorer

The easiest ways I can think that would solve this for you (If I understand the question correctly), would be to either monitor stdout of the netstat script, or write the results to a file and monitor that file.

Here are some suggested steps:

-Create a new app. Follow the instructions for Scripted Inputs. In general:

  1. Under /etc/deployment-apps/ , create a new app, for example: myapp .
  2. Under /etc/deployment-apps/myapp/bin , place your .sh script. Out of the box, Splunk should be able to run it. Make sure to add the correct interpreter in the first line (usually /bin/bash).
  3. You can output the script to a file, and have Splunk monitor that file (“Writing data to a file for indexing”). Another – quick – alternative would be to echo your netstat results to stdout (“Streaming data”). The Splunk service, which runs your script, will watch stdout and will send it back to the indexer as a single event.

View solution in original post

Damien_Dallimor
Ultra Champion

Simple :

Wire up your script using the Command Modular Input

https://splunkbase.splunk.com/app/1553/

alt text

Of course you can also refactor your script into a Splunk Scripted Input or Modular Input and deploy it in it's own App , but if you simply want to execute your script as is and capture the STDOUT in Splunk , then the Command Modular Input will work. And has some advanced stuff like plugging in your own preprocessing if you want.

98123722
Explorer

The easiest ways I can think that would solve this for you (If I understand the question correctly), would be to either monitor stdout of the netstat script, or write the results to a file and monitor that file.

Here are some suggested steps:

-Create a new app. Follow the instructions for Scripted Inputs. In general:

  1. Under /etc/deployment-apps/ , create a new app, for example: myapp .
  2. Under /etc/deployment-apps/myapp/bin , place your .sh script. Out of the box, Splunk should be able to run it. Make sure to add the correct interpreter in the first line (usually /bin/bash).
  3. You can output the script to a file, and have Splunk monitor that file (“Writing data to a file for indexing”). Another – quick – alternative would be to echo your netstat results to stdout (“Streaming data”). The Splunk service, which runs your script, will watch stdout and will send it back to the indexer as a single event.
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 ...