So, it seems that I have to use the attributes range_subid and range_ubound 
of the netsnmp_handler_registration structure when I register a region of my 
table to the master agent.

I've tested the following case:
App1:
oid genServerTableOid[] =
    { 1, 3, 6, 1, 4, 1, 99999, 10000, 1, 1, 2 };

size_t genServerTableOidLen = OID_LENGTH(genServerTableOid);
netsnmp_handler_registration * handlerServerTable = 
netsnmp_create_handler_registration("genServerTable",
  NULL,
  genServerTableOid,
  genServerTableOidLen,
  HANDLER_CAN_RONLY);

handlerServerTable->range_subid = genServerTableOidLen;
handlerServerTable->range_ubound = 2;
netsnmp_register_table_data_set(handlerServerTable, genServerTable, NULL);

App2:

oid genServerTableOid[] =
    { 1, 3, 6, 1, 4, 1, 99999, 10000, 1, 1, 3 };

size_t genServerTableOidLen = OID_LENGTH(genServerTableOid);

netsnmp_handler_registration * handlerServerTable = 
netsnmp_create_handler_registration("genServerTable",
  NULL,
  genServerTableOid,
  genServerTableOidLen,
  HANDLER_CAN_RONLY);

handlerServerTable->range_subid = genServerTableOidLen;
handlerServerTable->range_ubound = 3;

int res = netsnmp_register_table_data_set(handlerServerTable, 
genServerTable, NULL);
if ( res != MIB_REGISTERED_OK )
{
    snmp_log(LOG_ERR,"Unable to register the Server Row: res = %d.\n", res);
}

And this seems to work (despite, the function register_int_index returns 
always 1)

But if for App1, I change
oid genServerTableOid[] =
    { 1, 3, 6, 1, 4, 1, 99999, 10000, 1, 1, 1 };

handlerServerTable->range_subid = genServerTableOidLen;
handlerServerTable->ubound = 10;

And for App2:

oid genServerTableOid[] =
    { 1, 3, 6, 1, 4, 1, 99999, 10000, 1, 1, 11 };

handlerServerTable->range_subid = genServerTableOidLen;
handlerServerTable->ubound = 20;

it's not working anymore. I thought that withe range Oids between 1 and 10, 
this allowes me to reserver a region between 1 and 10 for the current 
application; moreover, I expected that if I launch App1 for the first time, 
it will register the value 1, and if I launch App1 a second time, it will 
register it with the value 2. But practice shows me that it's not working 
this way.

Concretely, if I do a snmpwalk on App1, I get:
GEN-MONITORING-MIB::genServerIndex.2.1 = Wrong Type (should be Gauge32 or 
Unsigned32): STRING: "Test1"
GEN-MONITORING-MIB::genServerIndex.3.1 = Wrong Type (should be Gauge32 or 
Unsigned32): STRING: "Test2"
GEN-MONITORING-MIB::genServerIndex.4.1 = Wrong Type (should be Gauge32 or 
Unsigned32): STRING: "Test3"
GEN-MONITORING-MIB::genServerIndex.5.1 = Gauge32: 1500
GEN-MONITORING-MIB::genServerIndex.3.1 = Wrong Type (should be Gauge32 or 
Unsigned32): STRING: "Test2"
Error: OID not increasing: GEN-MONITORING-MIB::genServerIndex.5.1
 >= GEN-MONITORING-MIB::genServerIndex.3.1

If I just change the oid like this (to begin at 2 instead of 1) for App1:
oid genServerTableOid[] =
    { 1, 3, 6, 1, 4, 1, 99999, 10000, 1, 1, 2 };

I get another response for an snmpwalk on App1 (and still no error when I 
register my row):
GEN-MONITORING-MIB::genServerTable.2.1.2.1 = STRING: "Test1"
GEN-MONITORING-MIB::genServerTable.2.1.3.1 = STRING: "Test2"
GEN-MONITORING-MIB::genServerTable.2.1.4.1 = STRING: "Test3"
GEN-MONITORING-MIB::genServerTable.2.1.5.1 = Gauge32: 1500
GEN-MONITORING-MIB::genServerTable.2.1.3.1 = STRING: "Test2"
Error: OID not increasing: GEN-MONITORING-MIB::genServerTable.2.1.5.1
 >= GEN-MONITORING-MIB::genServerTable.2.1.3.1


I never get an error from the function netsnmp_register_table_data_set.

If somebody already tries to use this mechanism, it would be nice to have 
explanations.

Thanks in advance for the help you provided to me.

Arnaud.

>From: "Dave Shield" <[EMAIL PROTECTED]>
>To: "Arnaud BODENAN" <[EMAIL PROTECTED]>
>CC: net-snmp-users@lists.sourceforge.net
>Subject: Re: multiple Sub-agents managing the same table
>Date: Mon, 4 Sep 2006 13:56:07 +0100
>
>On 04/09/06, Arnaud BODENAN <[EMAIL PROTECTED]> wrote:
> >         
>netsnmp_register_table_data_set(netsnmp_create_handler_registration
> >                                     ("genServerTable",
> >                                      NULL,
> >                                      genServerTableOid,
> >                                      genServerTableOidLen,
> >                                      HANDLER_CAN_RWRITE), 
>genServerTable,
> > NULL);
>
>But that's registering the whole table.
>You don't want to do that - you need to register individual rows.
>
> > Moreover, when I execute the second binary, I have no error message so 
>it
> > seems to work ok.
>
>Well, given that you don't actually check the return value of the
>netsnmp_register_xxx
>call, that feels something of an optimistic assumption!
>
>
>As I said - the Net-SNMP agent has typically been used for
>implementing full OID subtrees (i.e. complete tables) and most of the
>helper modules have been designed with that model in mind.  If you're
>trying to split a table across several subagents, you're going to have
>to do a *lot* more work yourself.
>
>Start by having a look at the AgentX specifications, where it talks
>about "OID ranges".  That's the model that has been used in the
>Net-SNMP agent, so it's important to understand how this works before
>proceeding.
>    Then you'll have to register each row individually (probably in
>addition to registering the whole table) - which I suspect will
>require using the 'agent_registry.c' APIs.
>
>I'm afraid that you're on somewhat uncharted territory here, and
>there's a limit to the amount of help we can provide.  I'm not sure
>any of the core developers have actually tried to implement such a
>split-agent table.
>       [If I'm wrong about this, now would be a good time to speak up!!]
>
>And I give you due warning - the two or three weeks before the start
>of a new academic year is *the* busiest period of the whole year for
>me, so I won't have much time or energy for non-essential stuff (like
>this project).
>
>Good Luck.
>
>Dave
>
>-------------------------------------------------------------------------
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job 
>easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>_______________________________________________
>Net-snmp-users mailing list
>Net-snmp-users@lists.sourceforge.net
>Please see the following page to unsubscribe or change other options:
>https://lists.sourceforge.net/lists/listinfo/net-snmp-users
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to