This note explains and gives examples how to use the Westhawk SNMP stack to send SNMPv2 traps in an Oracle JServer environment. Due to the unusual threading model (actually threads don't work at all :-) a dedicated set of classes has to be used to avoid starting threads that are difficult to kill in JServer.
The stack has been amended to send (i.e. not receive!) traps in an Oracle JServer environment for SNMP v1 and v2c. It will probably not be possible to do more in Oracle.
Running the stack in Oracle requires sufficient knowledge of Oracle, Java, SNMP and our stack.
The example runs in the following environment:
We run the trap example using XSQL using
The directory uk/co/westhawk/nothread/oscar
contains the
Oscar example. This example is a proof-of-principle example that has nothing
to do with the stack. The Oscar class has one static String method
public static String quote() { return "I can resist everything except temptation."; }
The example creates a stored function in PL/SQL with the call spec for
the method and then calls the example using SQL.
The example uses the scott
schema. This schema is used in
most of Oracle's examples and is usually created during Oracle's
installation time.
Oscar.java
- The java source fileloadOscarExample.sh
- The shell script that loads the
class file, using the Oracle tool loadjava
, and creates the
stored procedurecheckLoadResult.sql
- The SQL file that checks if the
status after loading the class in OraclecreateStoredProc.sql
- The SQL file that creates the
stored procedure (function)
checkStoredProc.sql
- The SQL file
that checks the stored procedurerunOscarExample.sh
- The bash script that calls the
stored procedurecallStoredProc.sql
- The
SQL file that calls the stored procedure
The directory uk/co/westhawk/nothread/trap
contains the
Trap example. The idea is that every time a row is inserted in the
(newly defined) scott.trap
table, a SNMPv2 trap is sent,
using the SendTrap.doSendTrap()
java method.
The field in the table represent the trap parameters.
To use the stack for sending traps in SNMPv2 without creating threads, use the classes
PassiveTrapPduv2
in place of OneTrapPduv2
.
The send operation will send the trap in the callers thread
PassiveSnmpContextv2c
in place of
SnmpContextv2c
Similar classes are available for SNMPv1.
All the necessary files are jarred in a cut-down version of the stack;
snmpOracle<no>.jar
, where no
is the
stack version number, like 4_12
.
The example uses the scott
schema. This schema is used in
most of Oracle's examples and is usually created during Oracle's
installation time.
SendTrap.java
- The java source fileloadTrapExample.sh
- The shell script that loads the
jar file, using the Oracle tool loadjava
, creates
the scott.trap
table and create the stored proceduregrantPermission.sql
- Grants the necessary Socket
permissionscheckLoadResult.sql
- Checks if all the classes in the
jar file have loaded and are resolved successfullycreateTrapTable.sql
- Creates the Oracle package with
the call spec, the trap
table and the database insert
trigger that will call the function to send the trapcheckStoredFunc.sql
- Checks the stored procedure
Resolving the jar file (see loadTrapExample.sh
) resulted in a
lot of complains about running out of shared pool memory, so the shared pool
size was enlarged.
Running the example can be done in two ways; via the
runTrapExample.sh
script or via XSQL.
The later
is much more fun, but requires Oracle's XSQL to work.
runTrapExample.sh
- The shell script that runs the
exampleinsertRow.sql
- Inserts a row in the trap table. The
trigger will cause the sending of the trap
xsql/
- The directory with HTML,
XSQL
and XSL
files.insert.html
- Offers a HTML
form to enter
the values of each field in the scott.trap
tabletable-post.xsql
- The action in the form above. It will
insert the data into the table and returns the result by querying the
last inserttable-transform-post.xsl
- The stylesheet used to
transform the data before being inserted into the tabletable-post.xsl
- The stylesheet used to transform the
result$Revision: 1.2 $, $Date: 2002/10/22 16:49:24 $
Contact the snmp group at Westhawk Ltd