Hi Robert, Have you had a chance to look at the below?
After retrieveing my cache object via netsnmp_cache_find_by_oid and updating the timeout value, how do I update the nsCacheTable so the new timeout can be used by my shared object? Thanks, Tim -----Original Message----- From: Tim Culhane [mailto:tim.j.culh...@gmail.com] Sent: 11 August 2015 15:59 To: 'net-snmp-coders@lists.sourceforge.net' <net-snmp-coders@lists.sourceforge.net> Subject: RE: making the cache timeout for container_load to be configurable Hi Robert, Being doing a bit of work on this and here is what I've got so far. Registered my config handler via a call to snmpd_register_config_handler My handler already handles other tokens, so here is the abridged version just showing code relevant to the caching: void config_razorgate_load(const char *key, char *value) { char *st = NULL; char *subtree = NULL; char *timeout = NULL; oid suboid[MAX_OID_LEN]; size_t suboid_len = 0; netsnmp_cache *cache = NULL; ... else if (compare(razorgate_cache_timeout_token, key)) { DEBUGMSGTL(("razorgate:config_razorgate_load", "called\n")); subtree = strtok_r(value, " \t\n", &st); if (!subtree) { config_perror("missing razorgate tablename parameter"); return; } timeout = strtok_r(NULL, " \n\t", &st); if (!timeout) { config_perror("missing timeout parameter"); return; } suboid_len = strlen(subtree)-1; if (subtree[suboid_len] == '.') subtree[suboid_len] = '\0'; /* stamp on a trailing . */ DEBUGMSGTL(("razorgate:config_razorgate_load", "subtree is %s, timeout is %s\n", subtree, timeout)); suboid_len = MAX_OID_LEN; if (!snmp_parse_oid(subtree, suboid, &suboid_len)) { config_perror("Invalid razorgate table object id"); return; } DEBUGMSGTL(("razorgate:config_razorgate_load", "suboid is %d\n", suboid)); cache = netsnmp_cache_find_by_oid(suboid, suboid_len); if (cache == NULL) { config_perror("Failed to retrieve cache object"); return; } DEBUGMSGTL(("razorgate:config_razorgate_load", "cache timeout is %d\n", cache->timeout)); } ... Debug output when running snmpd shows correct values being parsed and existing cache timeout value of 60 being returned: razorgate:config_razorgate_load: called razorgate:config_razorgate_load: subtree is razorgateSmtpStatusCountersTable, timeout is 30 razorgate:config_razorgate_load: suboid is -757531856 razorgate:config_razorgate_load: cache timeout is 60 However, I'm not sure how I now update the row entry in the nsCacheTable for my oid so that the new value is used. The only function which appears to do something like this is netsnmp_cache_create(), but this is already called in my interface code. What is the correct way of replacing the existing cache_entry with the new one containing the updated timeout value? Thanks, Tim -----Original Message----- From: NetSNMP Mailbox [mailto:net-snmp-m...@freesnmp.com] On Behalf Of Robert Story Sent: 14 July 2015 03:01 To: Tim Culhane <tim.j.culh...@gmail.com> Cc: net-snmp-coders@lists.sourceforge.net Subject: Re: making the cache timeout for container_load to be configurable On Fri, 10 Jul 2015 07:14:47 +0100 Tim wrote: TC> I've no problem giving it a shout. TC> TC> If you could give me some guideance that would really help. Ok, first the config token to specify the timeout. Take a look at ./agent/mibgroup/mibII/vacm_conf.c and search on vacm_parse_view. You should see code to register a config token ("view"), and to parse the view line (including parsing an OID, which will be the OID of the table). Register a new token ("myTableCacheTimeout") int your table's init routine, with a new parse routine that parses an OID and an integer timeout. Once you have an OID, netsnmp_cache_find_by_oid should find the cache. Then set cache_entry->timeout to the timeout value you parsed, and you should be all set. Hopefully that will get you started. Ask questions when you get stuck. Robert ------------------------------------------------------------------------------ _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders