/** * For SNMP Runtime internal use only. You should specify the <CODE>SnmpVarBindList</CODE> at * SnmpInformRequest creation time. You cannot modify it during the life-time of the object. */ final synchronized void setVarBindList(SnmpVarBindList newvblst) { varBindList = newvblst; if (internalVarBind == null || internalVarBind.length != varBindList.size()) { internalVarBind = new SnmpVarBind[varBindList.size()]; } varBindList.copyInto(internalVarBind); }
public void handleNotification(Notification notification, Object handback) { log.debug("handleNotification", "Received notification [ " + notification.getType() + "]"); String type = notification.getType(); if (type.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED) || type.equals(MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED)) { MemoryNotificationInfo minfo = MemoryNotificationInfo.from((CompositeData) notification.getUserData()); SnmpCounter64 count = new SnmpCounter64(minfo.getCount()); SnmpCounter64 used = new SnmpCounter64(minfo.getUsage().getUsed()); SnmpString poolName = new SnmpString(minfo.getPoolName()); SnmpOid entryIndex = getJvmMemPoolEntryIndex(minfo.getPoolName()); if (entryIndex == null) { log.error( "handleNotification", "Error: Can't find entry index for Memory Pool: " + minfo.getPoolName() + ": " + "No trap emitted for " + type); return; } SnmpOid trap = null; final SnmpOidTable mibTable = getOidTable(); try { SnmpOid usedOid = null; SnmpOid countOid = null; if (type.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) { trap = new SnmpOid(mibTable.resolveVarName("jvmLowMemoryPoolUsageNotif").getOid()); usedOid = new SnmpOid(mibTable.resolveVarName("jvmMemPoolUsed").getOid() + "." + entryIndex); countOid = new SnmpOid( mibTable.resolveVarName("jvmMemPoolThreshdCount").getOid() + "." + entryIndex); } else if (type.equals(MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED)) { trap = new SnmpOid(mibTable.resolveVarName("jvmLowMemoryPoolCollectNotif").getOid()); usedOid = new SnmpOid( mibTable.resolveVarName("jvmMemPoolCollectUsed").getOid() + "." + entryIndex); countOid = new SnmpOid( mibTable.resolveVarName("jvmMemPoolCollectThreshdCount").getOid() + "." + entryIndex); } // Datas SnmpVarBindList list = new SnmpVarBindList(); SnmpOid poolNameOid = new SnmpOid(mibTable.resolveVarName("jvmMemPoolName").getOid() + "." + entryIndex); SnmpVarBind varCount = new SnmpVarBind(countOid, count); SnmpVarBind varUsed = new SnmpVarBind(usedOid, used); SnmpVarBind varPoolName = new SnmpVarBind(poolNameOid, poolName); list.add(varPoolName); list.add(varCount); list.add(varUsed); sendTrap(trap, list); } catch (Exception e) { log.error("handleNotification", "Exception occured : " + e); } } }