Hi all,
How to register a table in subagent.
snmpwalk is not working for my table
here is my code..
======================================================
netsnmp_table_data_set *table_set;
netsnmp_table_row *row;
/* create the table structure itself */
table_set = netsnmp_create_table_data_set("abcTable");
/* comment this out or delete if you don't support creation of new rows
*/
table_set->allow_creation = 1;
/***************************************************
* Adding indexes
*/
DEBUGMSGTL(("initialize_table_abcTable",
"adding indexes to table abcTable\n"));
netsnmp_table_set_add_indexes(table_set,
ASN_INTEGER, /* index: abcIndex */
ASN_INTEGER, /* index: xyzIndex */
0);
DEBUGMSGTL(("initialize_table_abcTable",
"adding column types to table abcTable\n"));
netsnmp_table_set_multi_add_default_row(table_set,
COLUMN_ABCINDEX, ASN_INTEGER, 0,
NULL, 0,
COLUMN_XYZINDEX, ASN_INTEGER, 0,
NULL, 0,
COLUMN_LINENAME, ASN_OCTET_STR,
1,
NULL, 0,
COLUMN_GROUPNAME, ASN_OCTET_STR,
1,
NULL, 0,
COLUMN_IPADDRESS, ASN_OCTET_STR,
1,
NULL, 0,
COLUMN_PORT, ASN_INTEGER, 1,
NULL, 0,
0);
/* registering the table with the master agent */
/* note: if you don't need a subhandler to deal with any aspects
of the request, change abcTable_handler to "NULL" */
netsnmp_register_table_data_set(netsnmp_create_handler_registration("abcTabl
e", abcTable_handler,
abcTable_oid,
abcTable_oid_len,
HANDLER_CAN_RWRITE),
table_set, NULL);
int index1 = 1;
int index2 = 1;
row = netsnmp_create_table_data_row();
netsnmp_table_row_add_index(row, ASN_INTEGER, &index1 ,
sizeof(index1));
netsnmp_table_row_add_index(row, ASN_INTEGER, &index2 ,
sizeof(index2));
netsnmp_set_row_column(row, COLUMN_LINENAME, ASN_OCTET_STR,
lineName, strlen(lineName));
netsnmp_mark_row_column_writable(row, COLUMN_LINENAME, 1);
...
...
netsnmp_table_dataset_add_row(table_set, row);
}
/** Initializes the module */
void
init_ABC_TABLE(void)
{
/* here we initialize all the tables we're planning on supporting */
initialize_table_abcTable();
}
/** handles requests for the abcTable table, if anything else needs to be
done */
int
abcTable_handler(
netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests) {
/* perform anything here that you need to do. The requests have
already been processed by the master table_dataset handler, but
this gives you chance to act on the request in some other way
if need be. */
return SNMP_ERR_NOERROR;
}
Regards,
Prakash Raju
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders