use of com.sun.jmx.snmp.SnmpVarBindList in project jdk8u_jdk by JetBrains.
the class SnmpAdaptorServer method snmpV2Trap.
/**
* Sends a trap using SNMP V2 trap format.
* <BR>The trap is sent to each destination defined in the ACL file
* (if available). If no ACL file or no destinations are available,
* the trap is sent to the local host.
* <BR>The variable list included in the outgoing trap is composed of
* the following items:
* <UL>
* <LI><CODE>sysUpTime.0</CODE> with its current value</LI>
* <LI><CODE>snmpTrapOid.0</CODE> with the value specified by
* <CODE>trapOid</CODE></LI>
* <LI><CODE>all the (oid,values)</CODE> from the specified
* <CODE>varBindList</CODE></LI>
* </UL>
*
* @param trapOid The OID identifying the trap.
* @param varBindList A list of <CODE>SnmpVarBind</CODE> instances or null.
*
* @exception IOException An I/O error occurred while sending the trap.
* @exception SnmpStatusException If the trap exceeds the limit defined
* by <CODE>bufferSize</CODE>.
*/
@Override
public void snmpV2Trap(SnmpOid trapOid, SnmpVarBindList varBindList) throws IOException, SnmpStatusException {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "snmpV2Trap", "trapOid=" + trapOid);
}
// First, make an SNMP V2 trap pdu
// We clone varBindList and insert sysUpTime and snmpTrapOid
//
SnmpPduRequest pdu = new SnmpPduRequest();
pdu.address = null;
pdu.port = trapPort;
pdu.type = pduV2TrapPdu;
pdu.version = snmpVersionTwo;
pdu.community = null;
SnmpVarBindList fullVbl;
if (varBindList != null)
fullVbl = varBindList.clone();
else
fullVbl = new SnmpVarBindList(2);
SnmpTimeticks sysUpTimeValue = new SnmpTimeticks(getSysUpTime());
fullVbl.insertElementAt(new SnmpVarBind(snmpTrapOidOid, trapOid), 0);
fullVbl.insertElementAt(new SnmpVarBind(sysUpTimeOid, sysUpTimeValue), 0);
pdu.varBindList = new SnmpVarBind[fullVbl.size()];
fullVbl.copyInto(pdu.varBindList);
// Next, send the pdu to all destinations defined in ACL
//
sendTrapPdu(pdu);
}
Aggregations