>>>>> On Mon, 20 Jun 2005 14:46:54 +0800, "Ying Wang(CD)" <[EMAIL PROTECTED]> 
>>>>> said:

Ying> When I walking (use the command snmpwalk) ifNumber repeatedly, I
Ying> found the memory is largely leaking, increasing 388k or 4k at
Ying> once. But if I just get (use the command snmpget) it repeatly,
Ying> it will not happen. And, this does not always happened in every
Ying> objects or table in mib-2. I don't know why, please help me!

Since this is on a linux machine, I suggest you try running it using
"valgrind' which is an excellent memory leak checker.  Use "valgrind
--num-callers=16 --leak-check=yes snmpd"

 

Ying> The shell script I used to walk is as follows:

Ying> #!/bin/bash

Ying> declare -i count

Ying> count=1

Ying> while [ $count -le 10000 ]

Ying> do

Ying> echo "~~~~~~~~~~~~~~~~~$count~~~~~~~~"

Ying> snmpwalk -v 2c -c public 10.23.0.122 ifNumber

Ying> count=$count+1

Ying> done

 

Ying> My agent is running on Linux Redhat 9.0, and the version of net-snmp is
Ying> net-snmp-5.2.rc4.

 

Ying> My agent is created by mib2c use the template mib2c.scalar.conf, and is
Ying> dlmoded into net-snmp. The compiled source code is as follows:

 

Ying> #include <net-snmp/net-snmp-config.h>

Ying> #include <net-snmp/net-snmp-includes.h>

Ying> #include <net-snmp/agent/net-snmp-agent-includes.h>

Ying> #include "interfaces.h"

 

Ying> static int ifNumber = 0;

 

Ying> void init_interfaces(void)

Ying> {

Ying> static oid      ifNumber_oid[] = { 1, 3, 6, 1, 2, 1, 2, 1 };

Ying> netsnmp_register_scalar(netsnmp_create_handler_registration

Ying> ("ifNumber", handle_ifNumber, ifNumber_oid,

Ying> OID_LENGTH(ifNumber_oid),
Ying> HANDLER_CAN_RONLY));

Ying> }

Ying> Int handle_ifNumber(netsnmp_mib_handler *handler,

Ying> netsnmp_handler_registration *reginfo,

Ying> netsnmp_agent_request_info *reqinfo,

Ying> netsnmp_request_info *requests)

Ying> {

Ying> switch (reqinfo->mode) {

Ying> case MODE_GET:

Ying> snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,

Ying> (u_char *)(&ifNumber)

Ying> ,sizeof(ifNumber));

Ying> break;

Ying> default:

Ying> snmp_log(LOG_ERR, "unknown mode (%d) in handle_ifNumber\n",

reqinfo-> mode);

Ying> return SNMP_ERR_GENERR;

Ying> }

Ying> return SNMP_ERR_NOERROR;

Ying> }

 


-- 
Wes Hardaker
Sparta, Inc.


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to