com.splunk.modularinput
Class Script

java.lang.Object
  extended by com.splunk.modularinput.Script
Direct Known Subclasses:
Program

public abstract class Script
extends java.lang.Object

The Script class is an abstract base class for implementing modular inputs. Subclasses should override getScheme and streamEvents, and optional configureValidator if the modular input is using external validation.


Constructor Summary
Script()
           
 
Method Summary
abstract  Scheme getScheme()
          Gets the scheme that defines the parameters understood by this modular input.
 int run(java.lang.String[] args)
          Encodes all the common behavior of modular inputs.
 int run(java.lang.String[] args, EventWriter eventWriter, java.io.InputStream in)
          Encodes all the common behavior of modular inputs.
abstract  void streamEvents(InputDefinition inputs, EventWriter ew)
          Streams events into Splunk.
 void validateInput(ValidationDefinition definition)
          Handles external validation for modular input kinds.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Script

public Script()
Method Detail

run

public int run(java.lang.String[] args)
Encodes all the common behavior of modular inputs. You should have no reason to override this method in most cases.

Parameters:
args - An array of command line arguments passed to this script.
Returns:
An integer to be used as the exit value of this program.

run

public int run(java.lang.String[] args,
               EventWriter eventWriter,
               java.io.InputStream in)
Encodes all the common behavior of modular inputs. You should have no reason to override this method in most cases.

Parameters:
args - An array of command line arguments passed to this script.
eventWriter - An EventWriter.
in - An InputStream.
Returns:
An integer to be used as the exit value of this program.

getScheme

public abstract Scheme getScheme()
Gets the scheme that defines the parameters understood by this modular input.

Returns:
A Scheme object representing the parameters for this modular input.

validateInput

public void validateInput(ValidationDefinition definition)
                   throws java.lang.Exception
Handles external validation for modular input kinds. When Splunk called a modular input script in validation mode, it will pass in an XML document giving information about the Splunk instance (so you can call back into it if needed) and the name and parameters of the proposed input. If this function does not throw an exception, the validation is assumed to succeed. Otherwise any error thrown will be turned into a string and logged back to Splunk. The default implementation always passes.

Parameters:
definition - The parameters for the proposed input passed by splunkd.
Throws:
java.lang.Exception

streamEvents

public abstract void streamEvents(InputDefinition inputs,
                                  EventWriter ew)
                           throws MalformedDataException,
                                  javax.xml.stream.XMLStreamException,
                                  java.io.IOException
Streams events into Splunk. It should do all of its output via EventWriter rather than assuming that there is a console attached.

Parameters:
ew - An object with methods to write events and log messages to Splunk.
Throws:
MalformedDataException
javax.xml.stream.XMLStreamException
java.io.IOException