[SNMP4J] Updating registered managed objects (adding rows to MIB table)

Frank Fock fock at agentpp.com
Tue Feb 26 17:46:04 CET 2013


Hi,

The answer is very simple: Just add rows to the table (i.e. its table 
model).
You can do this while the table itself is registered (operation is 
thread safe).

Best regards,
Frank

Am 26.02.2013 17:17, schrieb Marek Hajduczenia:
> Dear all,
>
>   
>
> I am writing a small SNMP related project for my course. The task is to
> create an SNMP agent that will monitor a local selected folder and list all
> files stored in this folder in a MIB. I have already MIB designed, agent
> working fine on the initial pass, i.e., it creates a MIB table, populates
> initial values (files found at first pass through the folder) and then
> registers MIB with the agent.
>
>   
>
> The code snippet building the table structure is shown below:
>
>   
>
> MOTableBuilder builder = new MOTableBuilder(oidNewRoot);
>
>                                                  
>
> // MIB structure
>
>                                  
>
> builder.addColumnType(SMIConstants.SYNTAX_INTEGER32,MOAccessImpl.ACCESS_READ
> _ONLY);
>
> builder.addColumnType(SMIConstants.SYNTAX_OCTET_STRING,MOAccessImpl.ACCESS_R
> EAD_ONLY);
>
> builder.addColumnType(SMIConstants.SYNTAX_INTEGER,MOAccessImpl.ACCESS_READ_O
> NLY);
>
> builder.addColumnType(SMIConstants.SYNTAX_OCTET_STRING,MOAccessImpl.ACCESS_R
> EAD_ONLY);
>
> builder.addColumnType(SMIConstants.SYNTAX_INTEGER32,MOAccessImpl.ACCESS_READ
> _ONLY);
>
> builder.addColumnType(SMIConstants.SYNTAX_INTEGER32,MOAccessImpl.ACCESS_READ
> _ONLY);
>
> builder.addColumnType(SMIConstants.SYNTAX_OCTET_STRING,MOAccessImpl.ACCESS_R
> EAD_ONLY);
>
> builder.addColumnType(SMIConstants.SYNTAX_OCTET_STRING,MOAccessImpl.ACCESS_R
> EAD_ONLY);
>
> builder.addColumnType(SMIConstants.SYNTAX_INTEGER32,MOAccessImpl.ACCESS_READ
> _ONLY);
>
> builder.addColumnType(SMIConstants.SYNTAX_INTEGER,MOAccessImpl.ACCESS_READ_W
> RITE);
>
>   
>
> The code snippet adding a row is shown below (it is repeated in a loop to
> add all found files):
>
>   
>
> builder.addRowValue(new Integer32(index));
>
> index++;
>
> builder.addRowValue(new OctetString(fileName.getName()));
>
> builder.addRowValue(new Integer32(3));
>
> builder.addRowValue(new OctetString(fileName.getPath()));
>
> builder.addRowValue(new Integer32((int)fileName.length()));
>
> builder.addRowValue(new Integer32(323));
>
> builder.addRowValue(new OctetString("Artista"));
>
> builder.addRowValue(new OctetString("Album"));
>
> builder.addRowValue(new Integer32(1980));
>
> builder.addRowValue(new Integer32(4));
>
>   
>
> Finally, I register the new MIB with the agent:
>
>   
>
> server.registerManagedObject(builder.build());
>
>   
>
> After that, I run agent on a loop, every 5 seconds checking whether a new
> file was added to the folder. When that happens, I can detect a new file
> added and create list of such files. However, I do not know (could not find
> any information) on how to add row to already registered MIB. One thought
> was on reusing previously constructed table and just deregister it, then add
> new rows as needed and the register again but it seems like a very crude
> solution to me. Is there any way to do that better? if so, I would
> appreciate any pointers.
>
>   
>
> Thank you in advance
>
>   
>
> Marek
>
>   
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

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




More information about the SNMP4J mailing list