RE: snmp walk does not work
"Harendra Pratap Singh" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Yes it is always happens to be the same place in the get/getnext/walk
command. Below is the code I forgot to put it.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int
nx_subagent_agentx_init (char *subagent_idp, char *logfilep)
{
netsnmp_ds_set_boolean (NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_ROLE, 1);
netsnmp_ds_set_boolean (NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_NO_CONNECTION_WARNINGS, 1);
snmp_enable_filelog (logfilep, 1);
init_agent (subagent_idp);
init_snmp (subagent_idp);
return NX_SUBAGENT_SUCCESS;
}
int
nx_subagent_agentx_select (fd_set * read_setp, struct timeval *timeoutp,
int *maxfds)
{
int numfds = 0;
int block = 1;
if ((!read_setp) || (!timeoutp))
{
return NX_SUBAGENT_FAILURE;
}
snmp_select_info (&numfds, read_setp, timeoutp, &block);
*maxfds = numfds;
return NX_SUBAGENT_SUCCESS;
}
int
nx_subagent_agentx_process (fd_set * read_setp)
{
if (!read_setp)
{
return NX_SUBAGENT_FAILURE;
}
snmp_read (read_setp);
snmp_timeout ();
run_alarms ();
netsnmp_check_outstanding_agent_requests ();
return NX_SUBAGENT_SUCCESS;
}
++++++++++++++++++++++++++++++++++++++++
Thanks,
Harendra
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Dave Shield
Sent: Saturday, April 24, 2010 2:14 PM
To: Harendra Pratap Singh
Cc: [email protected]
Subject: Re:
On 24 April 2010 09:12, Harendra Pratap Singh
<[email protected]> wrote:
Firstly - please direct queries to the list, *not* to me directly.
Secondly - the code fragment you posted looks nothing like
our subagent framework. I have absolutely no idea what the
various 'nx_agentx_subagent_{xxx}' routines do.
Thirdly, I think you need to identify more closely the circumstances
in which the problem occurs. Is it always at the same place in the
walk, or does it occur randomly? Do you get the same problem
with individual GETNEXT or GET requests?
Does it coincide with AgentX PING requests?
Try turning on debugging within the master agent, and see
if you can identify what is happening when the problem arises.
Dave
________________________________
From: Harendra Pratap Singh [mailto:[email protected]]
Sent: Saturday, April 24, 2010 1:43 PM
To: Dave Shield
Cc: [email protected]
Subject:
Hi Dave,
I have written a subagent. Sometimes which works fine but sometimes it
stucks and snmpwalk returns with time out. I have taken the back trace
of stack when it works fine and when it does not work fine as below. I
am using net-snmp code.
When it works find
Thread 6 (Thread 0x7f491b0bd950 (LWP 19287)):
#0 0x00007f4918eab642 in select () from /lib64/libc.so.6
#1 0x000000000044abe3 in GisSnmpThreadProcedure (arg=0x0) at
gis_snmp.c:82
#2 0x00000000004d63c1 in ThreadFn (arg1=0xec8790) at
/repos/harendra/iserver_6_0_0_0_d18/common/thutils.c:285
#3 0x00007f4919f14070 in start_thread () from /lib64/libpthread.so.0
#4 0x00007f4918eb20ed in clone () from /lib64/libc.so.6
#5 0x0000000000000000 in ?? ()
When it gets stuck
Thread 6 (Thread 0x7f4f6940b950 (LWP 17138)):
#0 0x00007f4f6826887b in read () from /lib64/libpthread.so.0
#1 0x000000000056b280 in netsnmp_callback_recv (t=<value optimized
out>, buf=<value optimized out>, size=<value optimized out>,
opaque=0x7f4f6940a6f8,
olength=0x7f4f6940a704) at snmpCallbackDomain.c:194
#2 0x0000000000542447 in _sess_read (sessp=0xeec760,
fdset=0x7f4f6940abd0) at snmp_api.c:5544
#3 0x00000000005431e9 in snmp_sess_read (sessp=0xb,
fdset=0x7f4f6940a69f) at snmp_api.c:5761
#4 0x0000000000543223 in snmp_read (fdset=0x7f4f6940abd0) at
snmp_api.c:5378
#5 0x00000000004ede02 in nx_subagent_agentx_process
(read_setp=0x7f4f6940abd0) at
/repos/harendra/iserver_6_0_0_0_d18/common/nx_subagent.c:103
#6 0x000000000044abef in GisSnmpThreadProcedure (arg=0x0) at
gis_snmp.c:88
#7 0x00000000004d63c1 in ThreadFn (arg1=0xec8790) at
/repos/harendra/iserver_6_0_0_0_d18/common/thutils.c:285
#8 0x00007f4f68262070 in start_thread () from /lib64/libpthread.so.0
#9 0x00007f4f672000ed in clone () from /lib64/libc.so.6
#10 0x0000000000000000 in ?? ()
This is my piece of code.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void *
GisSnmpThreadProcedure (void *arg)
{
fd_set read_set = { 0 };
int maxfds = 0;
struct timeval agentx_timeout = { 0 };
NETERROR (MGISA, ("thread harendra - running\n"));
/* Initialize the AgentX/SNMP library. */
if (nx_subagent_agentx_init ("GISSubagent", "/var/log/gis_sa.log")
!=
NX_SUBAGENT_SUCCESS)
{
NETERROR (MGISA, ("thread harendra 0- running\n"));
return NULL;
}
init_sipCommonMIB ();
NETERROR (MGISA, ("thread harendra 2- running\n"));
while (1)
{
FD_ZERO (&read_set);
/* Get the AgentX timeout and add the AgentX socket
* descriptor to the read set.
*/
nx_subagent_agentx_select (&read_set, &agentx_timeout, &maxfds);
maxfds += 1;
if (select (maxfds, &read_set, NULL, NULL, &agentx_timeout) < 0)
{
/* Error in select. */
}
/* Process AgentX messages */
nx_subagent_agentx_process (&read_set);
}
return NULL;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++
Thanks,
Harendra
------------------------------------------------------------------------------
_______________________________________________
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