Hi net-snmp-coders, Analyzing why when done to hpux time snmpwalk -v 1 -c public localhost 1.3.6.1.2.1.25.3.2 always getting timeout, I found that it is due to the way it fetches the mib info using nm library. For each query for instance snmpwalk -v 1 -c public localhost 1.3.6.1.2.1.25.3.2.1.3.1035 HOST-RESOURCES-MIB::hrDeviceDescr.1035 = STRING: network interface lan900
It scans the full interface table, but reload the interface table at every calls. As a consequence Fetching 1.3.6.1.2.1.25.3.2.1.3.1025 need 3 fetch of the interface table, while 1.3.6.1.2.1.25.3.2.1.3.1079 ( lan944) will fetch it 3 + 5 + 7 +...+ 109 times so 3024 times Tests had been made on 5.6.1.1 for compilation facility but the same apply to 5.8 Since the function Interface_Scan_Next() is always called to walk the interface table after an Interface_Scan_Init() which always reset the scanIndex to 0, I propose to get the count and the if_ptr only when scanIndex is 0 ( or ifptr is 0) Changes are the same on 5.8 but in the function Interface_Scan_NextInt() and not Interface_Scan_Next() int Interface_Scan_Next(short *Index, char *Name, nmapi_phystat * Retifnet) { static nmapi_phystat *if_ptr = (nmapi_phystat *) 0; - int count = Interface_Scan_Get_Count(); + static int count = 0; unsigned int ulen; int ret; + int count_prev; - if (count) { - if_ptr = - (nmapi_phystat *) malloc(sizeof(nmapi_phystat) * count); - if (if_ptr == NULL) - return (0); + if (!if_ptr || (saveIndex==0)) { + count_prev=count; + count=Interface_Scan_Get_Count(); + if (count) { + if (!if_ptr){ + if_ptr = + (nmapi_phystat *) malloc(sizeof(nmapi_phystat) * count); + } else if (count != count_prev) { + if_ptr = + (nmapi_phystat *) realloc((void *)if_ptr,sizeof(nmapi_phystat) * count); + } + if (if_ptr == NULL) { + return (0); + count = 0; + } + ulen = (unsigned int) count *sizeof(nmapi_phystat); + if ((ret = get_physical_stat(if_ptr, &ulen)) < 0) + return (0); /* EOF */ + } else return (0); /* EOF */ } if (saveIndex >= count) return (0); /* EOF */ - ulen = (unsigned int) count *sizeof(nmapi_phystat); - if ((ret = get_physical_stat(if_ptr, &ulen)) < 0) - return (0); /* EOF */ if (Retifnet) *Retifnet = if_ptr[saveIndex]; if (Name) strcpy(Name, if_ptr[saveIndex].nm_device); saveIndex++; if (Index) *Index = saveIndex; return (1); /* DONE */ } Best regards, Laurent Menase
_______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders