int netsnmp_cpu_load( void ) { /* * If we're automatically updating the stats regularly, * then don't invoke the cache handling. */ return ( _cpuAutoUpdate ? 1 : netsnmp_cache_check_and_reload( _cpu_cache )); }
void Init_HR_FileSys(void) { netsnmp_cache *c = netsnmp_fsys_get_cache(); netsnmp_cache_check_and_reload( c ); HRFS_entry = NULL; HRFS_index = 0; }
void cpqSasPhyDrvTable_cache_reload() { netsnmp_cache *cpqSasPhyDrvTable_cache = NULL; cpqSasPhyDrvTable_cache = netsnmp_cache_find_by_oid(cpqSasPhyDrvTable_oid, cpqSasPhyDrvTable_oid_len); DEBUGMSGTL(("internal:cpqSasPhyDrvTable:_cache_reload", "triggered\n")); if (NULL != cpqSasPhyDrvTable_cache) { cpqSasPhyDrvTable_cache->valid = 0; netsnmp_cache_check_and_reload(cpqSasPhyDrvTable_cache); } }
int swrun_count_processes_by_name( char *name ) { netsnmp_swrun_entry *entry; netsnmp_iterator *it; int i = 0; netsnmp_cache_check_and_reload(swrun_cache); if ( !swrun_container || !name ) return 0; /* or -1 */ it = CONTAINER_ITERATOR( swrun_container ); while ((entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) != NULL) { if (0 == strcmp( entry->hrSWRunName, name )) i++; } ITERATOR_RELEASE( it ); return i; }
/** * Setup an iterator for scanning the interfaces using the cached entry * from if-mib/ifTable. */ void Interface_Scan_Init(void) { netsnmp_container *cont = NULL; netsnmp_cache *cache = NULL; cache = netsnmp_cache_find_by_oid(ifTable_oid, ifTable_oid_size); if (NULL != cache) { netsnmp_cache_check_and_reload(cache); cont = (netsnmp_container*) cache->magic; } if (NULL != cont) { if (NULL != it) ITERATOR_RELEASE(it); it = CONTAINER_ITERATOR(cont); } if (NULL != it) row = (ifTable_rowreq_ctx*)ITERATOR_FIRST(it); }
int swrun_count_processes( void ) { netsnmp_cache_check_and_reload(swrun_cache); return ( swrun_container ? CONTAINER_SIZE(swrun_container) : 0 ); }
/** Implements the cache handler */ int netsnmp_cache_helper_handler(netsnmp_mib_handler * handler, netsnmp_handler_registration * reginfo, netsnmp_agent_request_info * reqinfo, netsnmp_request_info * requests) { char addrstr[32]; netsnmp_cache *cache = NULL; netsnmp_handler_args cache_hint; DEBUGMSGTL(("helper:cache_handler", "Got request (%d) for %s: ", reqinfo->mode, reginfo->handlerName)); DEBUGMSGOID(("helper:cache_handler", reginfo->rootoid, reginfo->rootoid_len)); DEBUGMSG(("helper:cache_handler", "\n")); netsnmp_assert(handler->flags & MIB_HANDLER_AUTO_NEXT); cache = (netsnmp_cache *) handler->myvoid; if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_NO_CACHING) || !cache || !cache->enabled || !cache->load_cache) { DEBUGMSGT(("helper:cache_handler", " caching disabled or " "cache not found, disabled or had no load method\n")); return SNMP_ERR_NOERROR; } snprintf(addrstr,sizeof(addrstr), "%ld", (long int)cache); DEBUGMSGTL(("helper:cache_handler", "using cache %s: ", addrstr)); DEBUGMSGOID(("helper:cache_handler", cache->rootoid, cache->rootoid_len)); DEBUGMSG(("helper:cache_handler", "\n")); /* * Make the handler-chain parameters available to * the cache_load hook routine. */ cache_hint.handler = handler; cache_hint.reginfo = reginfo; cache_hint.reqinfo = reqinfo; cache_hint.requests = requests; cache->cache_hint = &cache_hint; switch (reqinfo->mode) { case MODE_GET: case MODE_GETNEXT: case MODE_GETBULK: #ifndef NETSNMP_NO_WRITE_SUPPORT case MODE_SET_RESERVE1: #endif /* !NETSNMP_NO_WRITE_SUPPORT */ /* * only touch cache once per pdu request, to prevent a cache * reload while a module is using cached data. * * XXX: this won't catch a request reloading the cache while * a previous (delegated) request is still using the cache. * maybe use a reference counter? */ if (netsnmp_cache_is_valid(reqinfo, addrstr)) break; /* * call the load hook, and update the cache timestamp. * If it's not already there, add to reqinfo */ netsnmp_cache_check_and_reload(cache); netsnmp_cache_reqinfo_insert(cache, reqinfo, addrstr); /** next handler called automatically - 'AUTO_NEXT' */ break; #ifndef NETSNMP_NO_WRITE_SUPPORT case MODE_SET_RESERVE2: case MODE_SET_FREE: case MODE_SET_ACTION: case MODE_SET_UNDO: netsnmp_assert(netsnmp_cache_is_valid(reqinfo, addrstr)); /** next handler called automatically - 'AUTO_NEXT' */ break; /* * A (successful) SET request wouldn't typically trigger a reload of * the cache, but might well invalidate the current contents. * Only do this on the last pass through. */ case MODE_SET_COMMIT: if (cache->valid && ! (cache->flags & NETSNMP_CACHE_DONT_INVALIDATE_ON_SET) ) { cache->free_cache(cache, cache->magic); cache->valid = 0; } /** next handler called automatically - 'AUTO_NEXT' */ break; #endif /* NETSNMP_NO_WRITE_SUPPORT */ default: snmp_log(LOG_WARNING, "cache_handler: Unrecognised mode (%d)\n", reqinfo->mode); netsnmp_request_set_error_all(requests, SNMP_ERR_GENERR); return SNMP_ERR_GENERR; } if (cache->flags & NETSNMP_CACHE_RESET_TIMER_ON_USE) netsnmp_set_monotonic_marker(&cache->timestampM); return SNMP_ERR_NOERROR; }
int netsnmp_memory_load( void ) { return netsnmp_cache_check_and_reload( _mem_cache ); }