[SNMP4J] R: SNMP4J Agent cannot be discovered (Netwrok Discovery)

Denis Ioan d.ioan at next-italia.it
Fri Sep 18 10:28:43 CEST 2015


Hi Frank,
   first of all thank you for the quick reply. I try to give you some more details about my issue:
As you could check in my lines of code I've implemented (or I tried to implement) an SNMP Agent v3.
I registered all my private OIDs and I've also implemented all the mib-2/system OIDs (sysName, sysDescription, etc). 
So you can "get" any the system OIDs and get/set all my enterprise OIDs (as well you can SnmpWalk, GetNext, etc). This works well.
Some software like "Whats Up Gold" in order to connect to a SNMP device uses such a "SNMP Network Discovery" where they poll all the subnet addresses looking for a SNMP Device. I've tried with a Cisco router (SNMPv3 and authentication) and the application discovers it immediately, but when I try on my device the software cannot discover it. As well if I use the "Network Discovery" function if the iReasoning MIB Browser (with the one I can work perfectly in terms of SnmpGet, SnmpSet and so on).
At this point I ask myself if I should register some other mandatory OIDs (not only the system OIDs) to let my device to be automatically discovered or I miss to implement in my software something important. 
I hope I could give some more indications and thank once more.
Best Regards
Denis

-----Messaggio originale-----
Da: SNMP4J [mailto:snmp4j-bounces at agentpp.org] Per conto di Frank Fock
Inviato: giovedì 17 settembre 2015 22:05
A: snmp4j at agentpp.org
Oggetto: Re: [SNMP4J] SNMP4J Agent cannot be discovered (Netwrok Discovery)

Hi Denis,

Before I can answer your question, I need to know what you exactly mean by "Network Discovery"?

Often IP multi-cast was used for that. Nowadays this is often no longer possible because switches/router/firewalls block multi-cast packets for security reasons.

In addition, multi-cast works only with SNMPv1 and v2c (community based) and
SNMPv3 with noAuthNoPriv.

Best regards,
Frank

Am 17.09.2015 um 11:14 schrieb Denis Ioan:
> Hi to everybody,
>     I'm new to the SNMP protocol but I had to implement an Agent in v3.
> Using SNMP4J I've implemented and all works fine except the agent 
> cannot be discovered automatically from the Network Discovery functions.
> I guess I forgot to insert something in the configuration. I post here 
> the Agent class and the way I use it in the software:
>
> public class SNMPAgent extends BaseAgent {
>      
>      private final String GROUP_NAME = "v3group";
>       
>      private String address;
>      private String baseOID;
>      private String securityName; // User
>      private String SHAPassword;
>      private String AES128Passphrase;
>      private String trapIPAddress;
>      private String trapPort;
>          
>      /**
>       *
>       * @param address
>       * @throws IOException
>       */
>      public SNMPAgent(String address, String baseOID,
>              String securityName, String SHAPassword, String 
> AES128Passphrase, String trapIPAddress, String trapPort) throws 
> IOException {
>
>              /**
>               * Creates a base agent with boot-counter, config file, 
> and a
>               * CommandProcessor for processing SNMP requests.
> Parameters:
>               * "bootCounterFile" - a file with serialized 
> boot-counter information
>               * (read/write). If the file does not exist it is created 
> on shutdown of
>               * the agent. "configFile" - a file with serialized 
> configuration
>               * information (read/write). If the file does not exist 
> it is created on
>               * shutdown of the agent. "commandProcessor" - the 
> CommandProcessor
>               * instance that handles the SNMP requests.
>               */
>              super(new File("conf.agent"), new File("bootCounter.agent"),
>                              new CommandProcessor(
>                                              new 
> OctetString(MPv3.createLocalEngineID())));
>              
>              this.address = address;
>              this.baseOID = baseOID;
>              this.securityName = securityName;
>              this.SHAPassword = SHAPassword;
>              this.AES128Passphrase = AES128Passphrase;
>              this.trapIPAddress = trapIPAddress;
>              this.trapPort = trapPort;
>              
>      }
>
>      /**
>       * Adds community to security name mappings needed for SNMPv1 and 
> SNMPv2c.
>       */
>      @Override
>      protected void addCommunities(SnmpCommunityMIB communityMIB) {
>          
>      }
>
>      /**
>       * Adds initial notification targets and filters.
>       */
>      @Override
>      protected void addNotificationTargets(final SnmpTargetMIB targetMIB,
>          final SnmpNotificationMIB notificationMIB) {
>      }
>
>      /**
>       * Adds all the necessary initial users to the USM.
>       */
>      @Override
>      protected void addUsmUser(USM usm)
>      {
>          UsmUser user = new UsmUser(
>                          new OctetString(securityName),
>                          AuthSHA.ID,
>                          new OctetString(SHAPassword),
>                          PrivAES128.ID,
>                          new OctetString(AES128Passphrase)
>                          );
>
>          usm.addUser(user.getSecurityName(), null, user);
>      }
>
>      /**
>       * Adds initial VACM configuration.
>       */
>      @Override
>      protected void addViews(VacmMIB vacm)
>      {		
>          vacm.addGroup(
>                  SecurityModel.SECURITY_MODEL_USM,
>                  new OctetString(securityName),
>                  new OctetString(GROUP_NAME),
>                  StorageType.nonVolatile
>                  );
>
>          vacm.addAccess(
>                  new OctetString(GROUP_NAME),
>                  new OctetString(),
>                  SecurityModel.SECURITY_MODEL_USM,
>                  SecurityLevel.AUTH_PRIV,
>                  MutableVACM.VACM_MATCH_EXACT,
>                  new OctetString("fullReadView"),
>                  new OctetString("fullWriteView"),
>                  new OctetString("fullNotifyView"),
>                  StorageType.nonVolatile
>                  );
>
>          vacm.addViewTreeFamily(
>                  new OctetString("fullReadView"),
>                  new OID(baseOID),
>                  new OctetString(),
>                  VacmMIB.vacmViewIncluded,
>                  StorageType.nonVolatile
>                  );
>
>          vacm.addViewTreeFamily(
>                  new OctetString("fullWriteView"),
>                  new OID(baseOID),
>                  new OctetString(),
>                  VacmMIB.vacmViewIncluded,
>                  StorageType.nonVolatile
>                  );
>          
>          vacm.addViewTreeFamily(new OctetString("fullReadView"), new 
> OID("1.3"),
> 				new OctetString(), VacmMIB.vacmViewIncluded,
> 				StorageType.nonVolatile);
>      }
>
>      /**
>       * Unregister the basic MIB modules from the agent's MOServer.
>       */
>      @Override
>      protected void unregisterManagedObjects() {
>              // TODO Auto-generated method stub
>
>      }
>
>      /**
>       * Register additional managed objects at the agent's server.
>       */
>      @Override
>      protected void registerManagedObjects() {
>              // TODO Auto-generated method stub
>
>      }
>
>      protected void initTransportMappings() throws IOException {
>              transportMappings = new TransportMapping[1];
>              Address addr = GenericAddress.parse(address);
>              TransportMapping tm = TransportMappings.getInstance()
>                              .createTransportMapping(addr);
>              transportMappings[0] = tm;
>      }
>
>      /**
>       * Start method invokes some initialization methods needed to 
> start the
>       * agent
>       *
>       * @throws IOException
>       */
>      public void start() throws IOException {
>
>              init();
>              // This method reads some old config from a file and causes
>              // unexpected behavior.
>              // loadConfig(ImportModes.REPLACE_CREATE);
>              addShutdownHook();
>              //getServer().addContext(new OctetString("public"));
>              finishInit();
>              run();
>              sendColdStartNotification();
>      }
>
>      /**
>       * Clients can register the MO they need
>       */
>      public void registerManagedObject(ManagedObject mo) {
>              try {
>                      server.register(mo, null);
>              } catch (DuplicateRegistrationException ex) {
>                      throw new RuntimeException(ex);
>              }
>      }
>
>      public void unregisterManagedObject(MOGroup moGroup) {
>              moGroup.unregisterMOs(server, getContext(moGroup));
>      }
>
> }
>
> I user the Agent in this way:
>
>
> agent = new SNMPAgent(
>                      LOCALHOST + '/' + configuration.getAgentSnmpPort(),
>                      configuration.getAgentBaseOID(),
>                      configuration.getAgentSnmpUser(),
>                      configuration.getAgentSHAPassword(),
>                      configuration.getAgentAES128PassPhrase(),
>                      configuration.getTrapDestIPAddress(),
>                      configuration.getTrapPort());
>
>              agent.start();
>
> // Since BaseAgent registers some mibs by default we need to unregister
> 	// one before we register our own sysDescr. Normally you would
> 	// override that method and register the mibs that you need
> 	agent.unregisterManagedObject(agent.getSnmpv2MIB());
>   
> 	// Register a system description, use one from you product environment
> 	// to test with
>
> agent.registerManagedObject(MOCreator.createReadOnly(sysDescr,SYS_DESC
> RIPTION));
>
> agent.registerManagedObject(MOCreator.createReadOnly(sysObjectID, new 
> OID(configuration.getAgentBaseOID())));
>
> agent.registerManagedObject(MOCreator.createReadOnly(sysContact,SYS_CO
> NTACT));
>
> agent.registerManagedObject(MOCreator.createReadOnly(sysName,SYS_NAME)
> );
>
> agent.registerManagedObject(MOCreator.createReadOnly(sysLocation,SYS_L
> OCATION));
>
> agent.registerManagedObject(MOCreator.createReadOnly(sysServices,SYS_S
> ERVICES));
>          
>          MOSSysUpTime = MOCreator.createReadWrite(sysUpTime, new 
> TimeTicks((long)0));
>          agent.registerManagedObject(MOSSysUpTime);
>
>
> I thank you in advance everybody will answer me.
> Denis
>
>
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> https://oosnmp.net/mailman/listinfo/snmp4j

--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231

_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
https://oosnmp.net/mailman/listinfo/snmp4j





More information about the SNMP4J mailing list