Database Command Destination

Definition

Protocol

Action

 

 

Description

Execute SQL Expression. Log into DatabaseLogin.
Create a new event from the results of the SQL command execution, setting FieldName to the returned result, FieldName to its error output, sending the new event to DestinationName

 

 

Comments

The SQL command is triggered by the arrival of an event so that it can write events into a database table depending on the specified SQL expression.

If Expression or DatabaseLogin is missing, blank or invalid the writer will be disabled.

If DestinationName is missing, blank or invalid a new event will not be sent.

If DestinationName exists, an event will be created and sent to it.

In addition to custom set output and error fields, event will also have following fields:

Event Field Contents
ev:host hostname
ev:app command being executed
ev:log "SQL Command"
ev:SQLCommand.StartTime command execution start time
ev:SQLCommand.EndTime command execution end time
ev:SQLCommand.ExecutionSecs command execution time in seconds
ev:SQLCommand.CommandString SQL Command String

 

Special XML characters are translated according to the XML Character Translation Table.

 

Example

<destination objectId="DbCmdSource" type="DatabaseWriter" stdout="FS.DemoAlive">
	<parameter type="Command">select * from Events where Events.host = ‘SafeHost'</parameter>
	<parameter type="FieldName">ev:dbErrs</parameter>
	<parameter type="DestinationName">Dest.tcpOut</parameter>
	<parameter type=”DatabaseLogin”>
		<url>jdbc:mysql://localhost/events</url>
		<driver>org.gjt.mm.mysql.Driver</driver>
		<user>username</user>
		<password>pass</password>
	</parameter>
</destination> 

 

Event Mapping

Resulting XML:

<event xmlns:ev="http://www.eventgnosis.com/">
	<ev:host>filipov</ev:host>
	<ev:app>SQL Command</ev:app>
	<ev:log> jdbc:mysql://localhost/events</ev:log>
	<ev:dbErrs></ev:dbErrs>
	<ev:SQLCommand.StartTime> Feb 25 2003 12:34:56 </ev:SQLCommand.StartTime>
	<ev: SQLCommand.EndTime> Feb 20, 2003 13:45:53 </ev:SQLCommand.EndTime>
	<ev: SQLCommand.ExecutionSecs>13</ev:SQLCommand.ExecutionSecs>
	<ev:SQLCommand.CommandString>select * from hostJZ where event.host = ‘JP'</ev:SQLCommand.CommandString>
	<ev:SQLCommand.ErrorStatus>-32</ev:SQLCommand.ErrorStatus>
</event>