Find the answer to your Linux question:
Results 1 to 5 of 5

Thread: SNMP Timeout

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2012
    Athens, Greece

    Unhappy SNMP Timeout


    This is my first message in this forum, so please excuse me if I created a wrong or repeated thread.

    I've been facing a really tricky problem, concerning the SNMP platform and more specifically it's Timing Out. I have already searched for answers and solutions but nothing seems to help me.

    I have the following system :

    One remote PC (Debian) runs an SNMP Daemon with an snmp agent (SNMP Version : 2).
    The agent listens for "get" requests on a certain OID of a MIB I created.
    When he receives a "get" request for this OID, he sleeps for 10 seconds and then returns a "0". All codes are implemented in C.

    Another PC (Debian) runs an Python SNMP Client that runs snmpget to that OID.

    The reason I created the above system is to test the Timeout of the client.

    The results have come out badly. The Daemon sleeps for 10 seconds, while the Python Client times out in 6 seconds.

    I have tried setting the client's request as follows:

    netsnmp.snmpget(trigger_oid, Version = ConfSNMPVersion, DestHost= ConfDemonHost, Community= ConfCommunityName, Timeout = 150000000, Retries = 1000)

    telling the client to wait for 150 seconds and run 1000 retries in case of a failure. No matter how big or small intervals do I set, the client ALWAYS times out in 6 seconds.

    Here is the output of my Python Client at some point of the execution :

    time python
    Getting SNMP configuration...
    Triggering Active Measurements Information...
    150000000 //this is the timeout interval
    1000 //this is the retries count
    Waiting for Sleepy OID...

    real 0m6.063s
    user 0m0.024s
    sys 0m0.016s

    I have also tried to run a Command Line snmpget, for example :
    snmpget -v2c -c public remotedebian -r 500 -t 10000000 .

    And again, it times out.

    Do you have any clue on how to solve the above problem?
    I REALLY need the SNMP agent on the Demon pc to execute some things for several seconds (even more than 10) but I can't have the client to time out so quickly...

    ANY insight on this issue will be greatly appreciated!!!

  2. #2
    Not much help, but have you tried to run ie 'tcpdump' with appropreate options on both server and client to see what happends when the snmp-request is run?

    Do you get an answer to the client if you remove the sleep from the server, or if you set sleep to < 6 sec?

  3. #3
    very strange - I'm still using the following SNMP Module from Simon Leinen within Perl for several years now:
    64.2 KB - all explanations and examples are included in the gz file - easy to use + with all parameters to adjust what I need,
    but I never had this kind of problem.
    1. SNMP is UDP (sessionless) ==> is a connection always possible and given during the whole request ?
    = start an ICMP PING continuously during your action, just to verify that not the OS is raising an event that something is happening like your used IP port is going down (maybe only for a short time) and due to that is influencing your whole application !
    2. It looks like your PC running ANY SNMP client has a problem, because the used SNMP application does not matter.

    Regards, P.

  4. $spacer_open
  5. #4
    also in use by me and would be very helpful: free SNMP MIB Browsers like
    or (no installation needed)
    to use a total different OS (like MS Windows)
    Last edited by phelest; 02-22-2012 at 11:45 PM.

  6. #5
    Just Joined!
    Join Date
    Feb 2012
    Athens, Greece

    Red face

    Hello and thank you all for the replies.
    I tried everything (netstat, wireshark, tutorials and so on and so forth) and nothing helped.
    The moment my brains started to melt down, I found the solution!!!
    I'm gonna post it here in case someone else faces this problem.

    As I said I had :
    1. A Python Client
    2. An SNMP Daemon
    3. A Master Agent (since I created a MIB of my own)

    Setting the Timeout and Retries on the Client did not work.
    Setting the Timeout on the SNMP Daemon did not work.
    Setting the Timeouts on both of the above, did not work.
    Every freakin' time, the Client timed out in 6 seconds.

    So, I started digging the guts of all the source codes and realized that, that snicky, undocumented little bastard, AgentX, has Timeouts too!
    You can see some defined timeout times in the .../snmplib/snmp_client.c code.

    So I realized that :
    When the Client connects to the SNMP Daemon, it exchanges protocol information NOT with the Daemon itself but with the Master Agent!
    And it was the Master Agent that was telling my Client to Timeout in 6 seconds no matter what!
    (At least, this is my explanation. I didn't find any soluction in the net, so I imagine that this is what happens. I could be wrong, ofcourse.)

    So, the solution is :
    1. I set the Agent's time out
    Went to the SNMP Config file (net-snmp-config --snmpconfpath) and added the following lines:
    agentXTimeout 60 #60 seconds = 1 minute
    agentXRetries 10 #10 retries of 1 minute each => 1 hour timeout. Seems legit
    2. Set the Clients time out
    netsnmp.snmpget(trigger_oid, Version = ConfSNMPVersion, DestHost= ConfDemonHost, Community= ConfCommunityName, Timeout = 360000000, Retries = 10)

    And it worked!
    Note that you should set large timeouts for BOTH the AgentX and the Client. If you set only the AgentX's and leave the Client with it's default values, it will timeout way before the AgentX manages to send the answer.

    So, by setting my Client and AgentX in the way shown, I solved the problem and now the AgentX does some work for 15 seconds and replies to the Client that waits politely!

    Tah dah !!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts