Hi Guys,
I am using NET_SNMP 5.9.1.
I am working on a SNMP agent implementation for a MIB with some snmp tables. It
is done via the main agent mib extension.
All is working now .
Though, we would like to use stash cache for one of the snmp tables in the MIB.
The handler of this snmp table reads a database table.
(The cache would save us on database load if the manager polls the table too
frequently. )
We made an attempt to do that happen with configuring injectHandler in the
snmpd.conf file & snmpd restarted.
However, at the end, we did not have luck.
What we got:
- seemingly the stash_cache handler injected (the "handler:inject"
debug token print outs confirmed this) but
- all of the snmpget queries caused to hit the database (seemingly no
change in the request processing)
- We turned on "helper:stash_cache" debug token but we were not able
to see any such log print out from the snmpd process.
This is the line in snmpd.conf for the stash cache handler injection we applied.
injectHandler stash_cache deviceInfoTable table_iterator
We use netsnmp_register_table_iterator2() in the snmp table implementation.
Below is how the snmp table init is implemented.
/*****************************************
* MIB EXTENSION EXPORTED initializer
*
* Initializes the deviceInfoTable module
* Initialize the deviceInfoTable table
* by defining its contents and how it's structured
*****************************************/
void
init_deviceInfoTable(void)
{
DEBUGMSGTL(("verbose:deviceInfoTable:init",
"initializing "
"table deviceInfoTable\n"));
const oid deviceInfoTable_oid[] = {1,3,6,1,4,1,6878,100,1,1};
const size_t deviceInfoTable_oid_len =
OID_LENGTH(deviceInfoTable_oid);
netsnmp_handler_registration *my_handler;
netsnmp_iterator_info *iinfo;
netsnmp_table_registration_info *table_info;
table_info =
SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
iinfo =
SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
my_handler = netsnmp_create_handler_registration(
"deviceInfoTable",
deviceInfoTable_handler,
deviceInfoTable_oid,
/*deviceInfoTable_oid_len,*/
OID_LENGTH(deviceInfoTable_oid),
HANDLER_CAN_RONLY
);
if (!my_handler || !table_info || !iinfo) {
snmp_log(LOG_ERR,
"malloc failed in "
"init_deviceInfoTable");
return;
}
/***************************************************
* Setting up the table's definition
*/
netsnmp_table_helper_add_indexes(table_info,
ASN_OCTET_STR,
0);
table_info->min_column = COLUMN_DEVICENAME;
table_info->max_column = COLUMN_DEVICESTATE;
iinfo->get_first_data_point =
deviceInfoTable_get_first_data_point;
iinfo->get_next_data_point =
deviceInfoTable_get_next_data_point;
iinfo->make_data_context =
deviceInfoTable_make_data_context;
iinfo->free_data_context =
deviceInfoTable_free_data_context;
iinfo->free_loop_context_at_end =
deviceInfoTable_free_loop_context_at_end;
iinfo->table_reginfo = table_info;
netsnmp_register_table_iterator2(my_handler, iinfo);
/* Initialise the contents of the table here */
}
I would appreciate if anybody could help me out on this issue.
Has anybody similar experience on net-snmp v5.9.1?
Can somebody point me out for a good working example for stash_cache?
Thanks for any feedback in advance.
Jeno
________________________________
This email and any files transmitted with it are confidential and are intended
for the sole use of the individual to whom they are addressed. Black Box
Corporation reserves the right to scan all e-mail traffic for restricted
content and to monitor all e-mail in general. If you are not the intended
recipient or you have received this email in error, any use, dissemination or
forwarding of this email is strictly prohibited. If you have received this
email in error, please notify the sender by replying to this email.
_______________________________________________
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