JavaScript response filter - DB2
The JavaScript request filter is the most flexible of all response filters. It can potentially be called for any packet type, and can modify traffic in any way it sees fit.
Parameters
Query pattern: optional. If specified, this filter will be invoked only if the current SQL matches this. Can be a string or a regular expression.
Packet types : optional. If specified, a comma-separated list of packet types for which this filter should be called, for instance: ACCRDBRM,SECCHKRM. Spaces are ignored.
Client IPs: optional. If specified, a comma-separated (or line break separated) list of IP4 or IP6 addresses or regular expressions for IP addresses.
Users: optional. If specified, a comma-separated (or line break separated) list of user names or regular expressions for user names.
Example
You can easily add up the execution time for a connection with a JavaScript response filter for MONITORRD packets, and the code:
if ( ! context.connectionContext.executionTime) {
context.connectionContext.executionTime = context.packet.ETIME;
}
else {
context.connectionContext.executionTime += context.packet.ETIME;
}
If you then wanted to show the total execution time when the connection is closed, you could do so in a Connection close filter with the code:
log.info("Connection is closing for: " + context.connectionContext.userName +
", execution time: " + context.connectionContext.executionTime);