public interface ScriptHandler
1. Implement Custom class
package com.adventnet.snmp.scripting;
import com.adventnet.snmp.snmp2.SnmpPDU;
class CustomTrapForwarder implements ScriptHandler
{
SnmpPDU pdu;
public CustomTrapForwarder(SnmpPDU tpdu)
{
//Should define a Parameterized Contructor with parameter type SnmpPDU
this.pdu = tpdu;//receives the SNMP pdu
System.out.println("Commmunity Value : "+pdu.getCommunity());
}
public void execute()
{
// executes the set of codes which defined in this method
}
public void setFilePath(String path)
{
// set a file location to execute any script files
}
}
Compile the java file for Windows in
any of the following ways :
Open the Command Prompt, change the directory to
<Product_Home>
Run the
setclasspath.bat, which is used to set the required jars in
classpath
Compile
java file, javac -d classes "<java file
location>\SampleCustomClass.java"
(or)
Open the
Command Prompt, go to custom java file location
Set the
required classpath, ( e.g. set
classpath=<product_home>\jars\AdventNetScript.jar;<product_home>\jars\AdventNetSnmp.jar
)
Compile
java file, javac -d <Product_Home>\classes
SampleCustomClass.java
Compile the java file for Linux :
Open the
Terminal, change the directory to <Product_Home>
Run the
setclasspath.sh, which is used to set the required jars in
classpath (. <SPACE> setclasspath.sh)
Compile
java file, javac -d classes "<java file
location>\SampleCustomClass.java"
(or)
Open
the Terminal, go to custom java file location
Set the
required classpath, ( e.g. export
classpath=<product_home>/jars/AdventNetScript.jar:<product_home>/jars/AdventNetSnmp.jar:$CLASSPATH
)
Compile java file, javac -d <Product_Home>\classes
SampleCustomClass.java
Note : Compile your java file in JDK 1.6.0
Now the compiled customized classes will be present in
<ProductHome>\classes directory.
Download the sample code for custom class CustomTrapForwarder.java
Method Summary | |
---|---|
void |
execute()
This is method execute the customized code that defined by the user. |
void |
setFilePath(java.lang.String path)
This is method used to set the location for the file. |
Method Detail |
---|
void execute()
void setFilePath(java.lang.String path)
path
- set the location for the file