This documentation does not apply to the most recent version of Splunk.
This documentation applies to the following versions of Splunk: 3.2 , 3.2.1 , 3.2.2 , 3.2.3 , 3.2.4 , 3.2.5 , 3.2.6
By configuring inputs.conf, Splunk can also accept events from scripts. Scripted input is useful for command-line tools, such as vmstat, iostat, netstat, top, etc.
Note: Currently, scripted inputs do not get bundled in the deployment server. In the future, Splunk will support this behavior. For now, use your preferred configuration automation tool to push your script directory to your server classes.
$SPLUNK_HOME/etc/bundles/.
scripts/.
scripts/ directory, create a directory bin/ to contain the actual script.
Note: Your script must be in the bin/ directory underneath your scripts/ directory.
$SPLUNK_HOME/etc/bundles/scripts/inputs.conf file:
[script://$SCRIPT]
interval = X
index = {main, $YOUR_INDEX}
sourcetype = {iostat, vmstat, etc} OPTIONAL
source = {iostat, vmstat, etc} OPTIONAL
disabled = false
script is the fully-qualified path to the location of the script
interval is in seconds
index can be any index in your Splunk instance
disabled is a boolean value that can be set to true if you want to disable the input
sourcetype and source can be any value you'd like. Optional.
This example shows the use of the UNIX top command as a data input source.
scripts/:
$ mkdir $SPLUNK_HOME/etc/bundles/scripts
bin/ directory inside your bundle directory:
$ mkdir $SPLUNK_HOME/etc/bundles/scripts/bin
top.sh:
$ #!/bin/sh top -bn 1 # linux only - different OSes have different paramaters
chmod +x $SPLUNK_HOME/etc/bundles/scripts/bin/top.sh
$SPLUNK_HOME/etc/bundles/scripts/bin/top.sh
top output.
inputs.conf in {{$SPLUNK_HOME/etc/bundles/scripts}:
[script:///opt/splunk/etc/bundles/scripts/bin/top.sh] interval = 5 # run every 5 seconds sourcetype = top # set sourcetype to top source = script://./bin/top.sh # set source to name of script
Note:
top entry into multiple events.
$SPLUNK_HOME/etc/bundles/scripts/props.conf forces all lines into a single event:
[top] BREAK_ONLY_BEFORE = GobblyGook
props.conf by setting:
DATETIME_CONFIG = CURRENT