The Sybase CEP Generic Plugin

Sybase CEP provides a generic plugin that enables you to invoke a specified executable program when a specified status event occurs.

To use this plugin, update Sybase CEP Server's configuration file (c8-server.conf by default) to specify the event that you want to watch for and the name of the program that you want to execute when that event occurs. The relevant section of the configuration file looks like the following:

<section name="ManagerFailoverDDNSPlugin">
<preference name="LibraryName" 
           value="c8_server_plugins_lib"/>
<preference name="InitializeFunction" 
           value="c8_command_line_plugin_initialize"/>
<preference name="ExecuteFunction" 
           value="c8_command_line_plugin_execute"/>
<preference name="ShutdownFunction" 
           value="c8_command_line_plugin_shutdown"/>
<preference name="MessageGroup" 
           value="ManagerInfo"/>
<preference name="MessageName" 
           value="ManagerHAPromotedToPrimary"/>
<preference name="CommandName" 
           value="REPLACE_WITH_PATH_TO_NSUPDATE"/>
<preference name="CommandArgument1" 
           value="-k"/>
<preference name="CommandArgument2" 
           value="REPLACE_WITH_PATH_TO_KEY_FILE"/>
<preference name="CommandArgument3" 
           value="-v"/>
<preference name="CommandArgument4" 
           value="REPLACE_WITH_PATH_TO_UPDATE_COMMANDS"/>
<preference name="MaxRunningProcesses" value="1"/>
<preference name="CommandTimeoutSeconds" value="30"/>
</section>

The section name ("ManagerFailoverDNSPlugin" in this case) may be any valid section name, but must be unique within this configuration file.

The first four preferences are required. You must specify:

When you use the generic plugin supplied by Sybase CEP, the name of the library, and the names of the the initialize(), execute() and shutdown() functions are always the same.

The next preference, the EventType, is also required. Specify a value that is listed as an event type in the event tables shown earlier in this chapter.

The next preference, the CommandName, is also required. This is the name of the executable program that you want to run. The actual value depends upon what action you want to take when the event occurs.

Note: On UNIX-like operating systems, the full path must be specified as well as the program name. On Microsoft Windows, only the name of the program needs to be specified if the path to the program appears in the %PATH% environment variable.

The command argument parameters are command-line arguments to the program specified in the CommandName parameter. These are optional and will vary depending on what action you want to take and what parameters your command requires. You can have up to 1024 of these parameters.

The last two parameters, MaxRunningProcesses and CommandTimeoutSeconds, are also optional.

The MaxRunningProcesses parameter allows you to set an upper limit on the number of event-handling programs that are spawned by this instance of the plugin and are still executing. If you have already reached this limit and a new event arrives, the server checks which of the event-handling processes have been running for at least the amount of time specified by the CommandTimeoutSeconds parameter; if there are any, the server will try to kill one of those processes. If the server is unable to kill an old process, then it will not launch a new one. The default value for MaxRunningProcesses is 32.

The CommandTimeoutSeconds parameter should be used in conjunction with MaxRunningProcesses preference. If MaxRunningProcesses is reached, processes that have been running longer than the CommandTimeoutSeconds interval will be terminated, so that other processes can be spawned in their place.

Note: CommandTimeoutSeconds has no effect until MaxRunningProcesses is reached. The default value of CommandTimeoutSeconds is 60. A value of 0 means that the processes should not be timed out.

For events that occur once per second, most event-handling programs finish quickly. For example, if you want to update a display showing CPU consumption, the Nth update should finish before the N+1th update starts, which means that each update should take less than 1 second .

For events that occur infrequently the running time of event handling programs is less of a concern. However, you must have a good idea of the "worst-case scenario" so that you can set MaxRunningProcesses high enough. You may specify as many event/program pairs as you wish for each server. A single event can spawn multiple programs. You must specify a separate event/program pair for each of these as there is no direct way to specify that a single event will run multiple programs. Conversely, more than one type of event can spawn the same program. You'll need to specify a separate event/program pair for each of these as there is no direct way to specify that multiple events can spawn the same program. In each of these cases, you'll specify the parameters independently.

Server plugins may be used with either managers or containers. Make sure that you put the plugins section in the correct part of the server configuration file. Manager plugin information should go in the manager section and container plugin information should go in the container section.