org.apache.log4j.ext
Class WengsoftSNMPTrapSender
java.lang.Object
|
+--org.apache.log4j.ext.WengsoftSNMPTrapSender
- All Implemented Interfaces:
- SnmpTrapSenderFacade
- public class WengsoftSNMPTrapSender
- extends java.lang.Object
- implements SnmpTrapSenderFacade
Title: WengsoftSNMPTrapSender
Description: This class makes use of the Wengsoft SNMP library to implement
the underlying SNMP protocol(s).
You can get a copy of Wengsoft SNMP here.
You will need a copy of the library ("snmpv3.jar" at a minimum) to use
and/or compile this class.
The source code of the Wengsoft SNMP library includes the following comment:
COPYRIGHT (c) 1999 by WENG-SOFT Inc. Brosard QC CA
All Rights Reserved.
The copyright to the computer program(s) herein is the property of WENG-SOFT
Inc. It's a free software, The program(s) may be used and/or copied freely.
Contact : wweng@videotron.ca
- Version:
- 1.0.1
2002-10-03
changes ---
2002-10-15: mwm : changed the sysUpTime value to a long, to cope with the SysUpTimeResolver mechanism.
2002-12-10: mwm : minor tweaks and prettying up of code.
- Author:
- Mark Masterson (m.masterson@computer.org)
http://www.m2technologies.net/
Method Summary |
void |
addTrapMessageVariable(java.lang.String applicationTrapOIDValue,
java.lang.String value)
Adds a new Varbind to the SNMP PDU. |
void |
initialize(java.lang.String managementHostValue,
int managementHostTrapListenPortValue,
java.lang.String enterpriseOIDValue,
java.lang.String localIPAddressValue,
int localTrapSendPortValue,
int genericTrapTypeValue,
int specificTrapTypeValue,
java.lang.String communityStringValue,
long sysUpTimeValue)
This method is called to set the values of all of the class fields used
as parameters to the underlying SNMP API. |
void |
sendTrap()
Sends the PDU defined by the variables of the fields of this class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WengsoftSNMPTrapSender
public WengsoftSNMPTrapSender()
- Default constructor.
initialize
public void initialize(java.lang.String managementHostValue,
int managementHostTrapListenPortValue,
java.lang.String enterpriseOIDValue,
java.lang.String localIPAddressValue,
int localTrapSendPortValue,
int genericTrapTypeValue,
int specificTrapTypeValue,
java.lang.String communityStringValue,
long sysUpTimeValue)
- Description copied from interface:
SnmpTrapSenderFacade
- This method is called to set the values of all of the class fields used
as parameters to the underlying SNMP API. This method must be
called prior to calling either of the other methods in this class.
- Specified by:
initialize
in interface SnmpTrapSenderFacade
- Following copied from interface:
org.apache.log4j.ext.SnmpTrapSenderFacade
- Parameters:
managementHostValue
- - the numeric IP address of the host
to which traps should be sent, e.g. "10.255.255.1".
managementHostTrapListenPortValue
- - any valid TCP/IP port
number. This is the port that the host specified in the
"managementHostValue" variable will listen on for SNMP traps.
enterpriseOIDValue
- - formatted as an OID
E.g. "1.3.6.1.2.1.1.2.0" -- this OID would point to the standard
sysObjectID of the "systemName" node of the standard "system" MIB.
If you want(need) to use custom OIDs (such as ones from the
"private.enterprises" node -- "1.3.6.1.4.1.x.x.x..."), you always need
to provide the fully qualified OID as the value of this
variable.
localIPAddressValue
- - an IP address, as a String, in
numeric, dotted decimal format. E.g. "10.255.255.2". This is the IP
address of the host that is using this appender to send SNMP traps.
This address will be encoded in the SNMP PDU, and used to provide
things like the "agent"'s IP address.
localTrapSendPortValue
- - the port that should be used on the
local host by the appender to send the trap.
genericTrapTypeValue
- - generic trap type for this SNMP PDU.
One of the following values (from the SNMP standard):
0 -- cold start
1 -- warm start
2 -- link down
3 -- link up
4 -- authentification failure
5 -- EGP neighbor loss
6 -- enterprise specific
specificTrapTypeValue
- - any value within the range defined
for an INTEGER in the ASN.1/BER notation; i.e. -128 to 127.
communityStringValue
- - E.g. "public".
sysUpTimeValue
- - this is meant to be the amount of time, in
seconds, elapsed since the last re-start or re-initialization of the
calling application. Of course, to set this, your application needs
to keep track of the value.
addTrapMessageVariable
public void addTrapMessageVariable(java.lang.String applicationTrapOIDValue,
java.lang.String value)
- Description copied from interface:
SnmpTrapSenderFacade
- Adds a new Varbind to the SNMP PDU. The Varbind is made of the value
of the application trap OID (applicationTrapOID) parameter, as the key, and the
value paramater to this method as the value. A PDU has a collection
of Varbind variables -- repeated calls to this method will add to that
collection successively.
- Specified by:
addTrapMessageVariable
in interface SnmpTrapSenderFacade
- Following copied from interface:
org.apache.log4j.ext.SnmpTrapSenderFacade
- Parameters:
applicationTrapOIDValue
- - formatted as an OID
E.g. "1.3.6.1.2.1.1.2.0.0.0.0" -- this OID would point to the standard
sysObjectID of the "systemName" node of the standard "system" MIB.
This is the default value, if none is provided.
If you want(need) to use custom OIDs (such as ones from the
"private.enterprises" node -- "1.3.6.1.4.1.x.x.x..."), you always need
to provide the fully qualified OID as the parameter for this
variable.
value
- - the text to append to the Varbind that will be added to
the SNMP PDU.
sendTrap
public void sendTrap()
- Description copied from interface:
SnmpTrapSenderFacade
- Sends the PDU defined by the variables of the fields of this class.
This method should always be called last by an application, after having
called the initialization() method once, and the addTrapMessageVariable()
method one or more times.
- Specified by:
sendTrap
in interface SnmpTrapSenderFacade