Re: multiple Sub-agents managing the same table
"Arnaud BODENAN" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
OK, Thanks a lot for the answer.
I agree with you concerning the call to register_int_index, and I just
modify the code this morning ;o)
My initialization code now looks like this:
void init_GenServerTable()
{
netsnmp_table_data_set *genServerTable =
netsnmp_create_table_data_set("genServerTable");
netsnmp_table_dataset_add_index(genServerTable, ASN_UNSIGNED);
netsnmp_table_set_multi_add_default_row(genServerTable,
2,
ASN_OCTET_STR, 0, NULL, 0,
3,
ASN_OCTET_STR, 0, NULL, 0,
4,
ASN_OCTET_STR, 0, NULL, 0,
5,
ASN_UNSIGNED, 0, NULL, 0,
0);
netsnmp_register_table_data_set(netsnmp_create_handler_registration
("genServerTable",
NULL,
genServerTableOid,
genServerTableOidLen,
HANDLER_CAN_RWRITE), genServerTable,
NULL);
// Add a Row
netsnmp_table_row *row = netsnmp_create_table_data_row();
u_long ind = register_int_index(genServerTableOid, genServerTableOidLen,
ANY_INTEGER_INDEX);
if ( ind == 0 )
{
ind = register_int_index(genServerTableOid, genServerTableOidLen,
ANY_INTEGER_INDEX);
}
snmp_log(LOG_INFO,"Index found=%d.\n", ind);
netsnmp_table_row_add_index(row, ASN_UNSIGNED, &ind, sizeof(ind));
netsnmp_set_row_column(row, 2, ASN_OCTET_STR,
"Test1", strlen("Test1"));
netsnmp_set_row_column(row, 3, ASN_OCTET_STR, "Test2",
strlen("Test2"));
netsnmp_set_row_column(row, 4, ASN_OCTET_STR,
"Test3", strlen("Test3"));
u_long pid = 1500;
netsnmp_set_row_column(row, 5, ASN_UNSIGNED, (const char *)&pid,
sizeof(pid));
netsnmp_table_dataset_add_row(genServerTable, row);
}
When I launch my subagents twice, and execute an snmpwalk on
riskServerTable, I receive:
GEN-MONITORING-MIB::genServerName.1 = STRING: "Test1"
GEN-MONITORING-MIB::genServerProductName.1 = STRING: "Test2"
GEN-MONITORING-MIB::genServerHostname.1 = STRING: "Test3"
GEN-MONITORING-MIB::genServerPID.1 = Gauge32: 1500
but I hoped that it answers me the following added lines:
GEN-MONITORING-MIB::genServerName.2 = STRING: "Test1"
GEN-MONITORING-MIB::genServerProductName.2 = STRING: "Test2"
GEN-MONITORING-MIB::genServerHostname.2 = STRING: "Test3"
GEN-MONITORING-MIB::genServerPID.2 = Gauge32: 1500
I check netsnmp_table_dataset_add_row, but it returns no value (void).
Moreover, when I execute the second binary, I have no error message so it
seems to work ok.
>From: "Dave Shield" <[email protected]>
>To: "Arnaud BODENAN" <[email protected]>
>CC: [email protected]
>Subject: Re: multiple Sub-agents managing the same table
>Date: Mon, 4 Sep 2006 13:23:48 +0100
>
>On 02/09/06, Arnaud BODENAN <[email protected]> wrote:
>>I have tested the function register_int_index to generate an unique index
>>and added it in the registration of my table genServerTable.
>> .... I log the index returned by
>>the function register_int_index (I have to increment it after the call of
>>register_int_index, as the first index returned by register_int_index
>>begins
>>with 0 instead of 1)
>
>Errr... that doesn't sound safe.
>If you've asked 'register_int_index' to give you an arbitrary index,
>then you should be using the value that it gives you, since that's
>what it has allocated. You might get away with this as long as it's
>only your code that uses the result, and this *all* processes things
>in the same way.
> But it feels much safer for the first application to register *two*
>indexes (0 and 1), and only actually use the second one. Or in
>general, for each application to check the returned value, and request
>a second index if the first one was 0.
>
>
>
>>All seems to be OK (in the log and in the attribution of the index):
>>Application 1 registers the row 1
>>Application 2 registers the row 2
>>Application 3 registers the row 3
>>Application 4 registers the row 4
>
>This is extra code, registering the row using the index just supplied -
>yes?
>What does this code look like? Does the registration succeed?
>
>
>>But when I execute a snmpwalk or a snmpget, I only get metrics for the
>>index
>>1. The rows 2, 3, and 4 have not been registered.
>
>What does walking the nsRegistryTable look like?
>
>
>>I appreciate any help about this problem. and I would like to know if my
>>approach (share the same table by several applications) is possible or
>>not.
>
>Yes - this approach is certainly possible.
>The AgentX protocol was deliberately designed to support this mode of
>working, and the Net-SNMP code has been written to implement this
>behaviour.
>
>However, it's only fair to say that this style of working probably
>hasn't been used very widely, so won't have been tested to the same
>extent as registering full OID subtrees. It's quite possible that
>there are bugs in the code. You may need to proceed carefully, and
>check exactly what has/hasn't worked at each stage.
>
>
>dave
_________________________________________________________________
Don't just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/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
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users