Shell Command Destination  






Execute Expression as a shell command using Shell.
Create a new event from the results of the shell command execution, setting FieldName to the returned result, FieldName to its error output, FieldName to its return status, and send the new event to DestinationName.




New created event will contain the following:

Event Field Contents
ev:host hostname
ev:app %Shell% %Expression%
ev:log Shell Command
ev:protocol Shell Command
ev:srctime Source time

If Expression or Shell is missing, blank or invalid, the destination will be disabled.

If DestinationName is missing, blank or invalid, no new event will be generated and any command output will be discarded.


If the first FieldName is missing, blank or invalid, make its default ev:msg. If the other FieldName parameters are missing, blank or invalid, do not set their values.

When the shell command completes, the new event is created and sent to DestinationName, creating the following event fields:

ev:shellCommand.StartTime = StartingTime
ev:shellCommand.EndTime = EndingTime
ev:shellCommand.ExecutionSecs = time in seconds for shell command to execute
ev:shellCommand.CommandString = the shell command string that was executed
ev:shellCommand.ProcessId = process ID, if available

Only one command shell will be executing at a given time. The prior command shell must complete its execution before the next event can be processed, possibly filling up the incoming event queue if shell execution is slower than event arrival.

Typically, Shell is set to "/bin/sh –c" for Linux and "C:\cmd.exe \C" for Windows, allowing for execution of multiple commands in Expression. Under Linux, the commands will execute using the uid and environment of the ECS and '/' as its current working directory, and under Windows the command will execute with 'C:\' as its working directory and the privileges of the ECS process.



<source objectId="ShellCmdDest" type="ShellCommandDestination" stdout="FS.DemoAlive">
	<parameter type=”Expression”>
		<formatString>ps –ef %1% | grep host %2%</formatString>
		<formatParmSpec> <!—0..N of these, 0 is fixed format string -->
			<type>EventType</type> <!—many of these types in the future -->
		<formatParmSpec> <!—0..N of these, 0 is fixed format string -->
			<type>EventType</type> <!—many of these types in the future -->
	<parameter type="Shell">/bin/sh -c</parameter>
	<parameter type="FieldName">ev:msg2</parameter>
	<parameter type="FieldName">ev:msg3</parameter>
	<parameter type="FieldName">ev:msg4</parameter>

Event Mapping

Resulting XML:

<event xmlns:ev="">
	<ev:log>D\Program Files\EventGnosis\logs\textLog3.txt</ev:log>
	<ev:shellCommand.StartTime> Feb 25 2003 12:34:56 </ev:shellCommand.StartTime>
	<ev:shellCommand.EndTime> Feb 26 2003 12:34:57 </ev:shellCommand.EndTime>
	<ev:shellCommand.CommandString>ps –ef | grep host hostJZ.txt</ev:shellCommand.CommandString>
	<ev:protocol>Text Log</ev:protocol>
	<ev:msg2> This new line with &lt;/event&gt; inside has just arrived in the end of log.</ev:msg2>