[SNMP4J] Re: How to initialize SnmpNotificationMIB (WANG Chi)

通子 ytsun04 at 163.com
Thu Jun 28 02:52:37 CEST 2007


 protected void addNotificationTargets(SnmpTargetMIB targetMIB,
   SnmpNotificationMIB notificationMIB)
 {  targetMIB.addDefaultTDomains();  // 配置的vnmserver的地址
  String target = confManager.getConfigInfor().vnmserverIP + "/"
    + confManager.getConfigInfor().vnmserverPort;  targetMIB.addTargetAddress(new OctetString(target),
    TransportDomains.transportDomainUdpIpv4, new OctetString(
      new UdpAddress(target).getValue()), 200, 2,
    new OctetString(TAG_NOTIFY + " " + TAG_REQUEST),
    new OctetString("v2c"), StorageType.volatile_);  String com = confManager.getInitialConfig().getSnmpConf().readCommunity;  targetMIB.addTargetParams(new OctetString("v2c"),
    MessageProcessingModel.MPv2c,
    SecurityModel.SECURITY_MODEL_SNMPv2c, new OctetString(com),
    SecurityLevel.NOAUTH_NOPRIV, StorageType.volatile_);  // 告警地址
  notificationMIB.addNotifyEntry(new OctetString("default"),
    new OctetString(TAG_NOTIFY),
    SnmpNotificationMIB.SnmpNotifyTypeEnum.trap,
    StorageType.volatile_);  // 查询地址
  Collection matches = targetMIB.getTargetAddrRowsForTag(new OctetString(
    TAG_REQUEST));
  for (Iterator it = matches.iterator(); it.hasNext();)
  {   SnmpTargetAddrEntryRow row = (SnmpTargetAddrEntryRow) it.next();   OctetString mask = OctetString.fromHexString(MASK);
   Variable[] ext = new Variable[]
   { mask, new Integer32(MMS) };
   MOTableRow extRow = getSnmpCommunityMIB()
     .getSnmpTargetAddrExtEntry().createRow(row.getIndex(), ext);
   getSnmpCommunityMIB().getSnmpTargetAddrExtEntry().addRow(extRow);
  }
 }  
在2007-06-27,snmp4j-request at agentpp.org 写道:
Send SNMP4J mailing list submissions to snmp4j at agentpp.org To subscribe or unsubscribe via the World Wide Web, visit http://lists.agentpp.org/mailman/listinfo/snmp4j or, via email, send a message with subject or body 'help' to snmp4j-request at agentpp.org You can reach the person managing the list at snmp4j-owner at agentpp.org When replying, please edit your Subject line so it is more specific than "Re: Contents of SNMP4J digest..." Today's Topics: 1. How to initialize SnmpNotificationMIB (WANG Chi) 2. Notification Listener (Vinay_Kenchappa) ---------------------------------------------------------------------- Message: 1 Date: Tue, 26 Jun 2007 19:01:45 +0800 From: "WANG Chi" <Chi.WANG at gemalto.com> Subject: [SNMP4J] How to initialize SnmpNotificationMIB To: <snmp4j at agentpp.org> Message-ID: <C59C93331BA8EC4D87ABC4366625196DBFE96A at BJSEXC01.CORP.DS.GEMPLUS.COM> Content-Type: text/plain; charset="gb2312" Hi, I'm a new user of SNMP4j, I studied the TestAgent, and find that to use NotificationOriginator to send traps, the traps are all sent to SnmpNotificationMIB. I need to start the agent with an trap target address(just the address of NMS) initialized. I want to put the trap target address and trap version in a properties file and when the program starts, the program will read this property file and add the target address and trap version into SnmpNotificationMIB. Then after the program starts, I can send traps to the target address. Can you show me some code examples on how to add some targets into SnmpNotificationMIB when the program starts. Thank you very much. Best Regards, Wang Chi ------------------------------ Message: 2 Date: Wed, 27 Jun 2007 11:03:30 +0530 From: "Vinay_Kenchappa" <Vinay_Kenchappa at Satyam.com> Subject: [SNMP4J] Notification Listener To: <snmp4j at agentpp.org> Message-ID: <20B811C4F7C2E340BAAE112DBA86F10A0298013A at blamsg001.corp.satyam.ad> Content-Type: text/plain; charset="us-ascii" Hi Frank, The baseAgent class has a method by name finishInit() which would be called by Agent class. In the finishInit() method there is call to send a coldStartNotification. How do I receive the cold start notification in the snmp manager? Do I have to write a notification Listener to receive a notification or can I receive it through the snmp4j trap listener? protected void finishInit() { if (agentState < STATE_INIT_STARTED) { logger.fatal("Agent initialization finish is called before "+ "initialization, current state is "+agentState); } agent.setNotificationOriginator(notificationOriginator); agent.addMOServer(server); agent.setCoexistenceProvider(snmpCommunityMIB); agent.setVacm(vacmMIB); dispatcher.addCommandResponder(agent); agentState = STATE_INIT_FINISHED; sendColdStartNotification(); } protected void sendColdStartNotification() { notificationOriginator.notify(new OctetString("public"), SnmpConstants.coldStart, new VariableBinding[0]); } -Regards Vinay DISCLAIMER: This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated. ------------------------------ _______________________________________________ SNMP4J mailing list SNMP4J at agentpp.org http://lists.agentpp.org/mailman/listinfo/snmp4j End of SNMP4J Digest, Vol 41, Issue 18 **************************************


More information about the SNMP4J mailing list