AW: Snmpget in net-snmp 5.2.1 hangs on windows 2003

"Mohr James" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
>> -----Ursprüngliche Nachricht-----
>> Von: Alex Burger [mailto:[email protected]] 
>> Gesendet: Mittwoch, 27. Juli 2005 04:17
>> An: Mohr James
>> Cc: [email protected]
>> Betreff: Re: Snmpget in net-snmp 5.2.1 hangs on windows 2003
>> 
>> 
>> Hi Jim.
>> 
>> Mohr James wrote:
>> > In order to record performance data, we have a construct 
>> that looks 
>> > like
>> > this:
>> > 
>> > - Nagios starts an NRPE job on another machine which starts a perl 
>> > script on a Windows 2003 machine
>> > - the perl script uses the snmpget command from net-snmp 
>> 5.2.1 to read 
>> > a single value from a remote machine.
>> > - The value is set in the perl script simply by 
>> $value=`$command`. (I 
>> > am not using the SNMP perl modules)
>> > -  The OID .1.3.6.1.4.1.1.1.101.1 is defined like this in 
>> snmpd.conf:
>> > exec .1.3.6.1.4.1.1.1 /usr/bin/perl /opt/elaxy/bin/get_cpu_usage.pl
>> > - This value is then written to a MS SQL Database using osql. 
>> > 
>> > What is happening is that I see dozens of snmpget.exe programms 
>> > running (occassionally a couple of perl.exe processes). 
>> Unfortunately, 
>> > I see no way of figuring out to where these processes are 
>> connected, 
>> > so I cannot tell if there are specific machine causing the 
>> problems. 
>> > Using netstat, I do see a number of connections to the MS 
>> SQL database 
>> > in TIMEWAIT. However, since we are checking a couple of dozens 
>> > machines, this is not surprising.
>> > 
>> > The Nagios is reporting both "CHECK_NRPE: Socket timeout after 10 
>> > seconds." and "connection refused". Obviously this could 
>> be a purely 
>> > Nagios problem, however, as far as I can see it seems to 
>> be behaving 
>> > correctly. Plus, we have the dozens of snmpget processes 
>> that do not 
>> > go away.
>> 
>> Do the snmpget.exe commands eventually disappear?
>> 
>> I suspect the timeouts are because snmpget is taking too long to 
>> respond, probably because of a bad community string.  The 
>> agent won't 
>> respond with a 'wrong community string'.  The client just 
>> keeps trying 
>> until the timeout occurs.  I'm not sure about the 
>> "connection refused" 
>> errors.
>> 
>> The default timeout for snmpget (and other commands) is 1 
>> second, and 
>> the default retries is 5 (man snmpcmd).  Try reducing the 
>> retries to 2 
>> using '-r 2'.
>> 
>> Snmpget errors are sent to STDERR.  To include STDERR in the 
>> result, use 
>> $value=`$command 2>&1`;
>> 
>> If you want to handle the errors by exit code, you can 
>> capture it from 
>> the command using:
>> 
>> $value=`$command`;
>> $errorlevel = $? >> 8;
>> 
>> Alex

Thanks Alex (and everyone else) for the prompt help. At the very least,  I definately have some nice tips how to improve my perl code.

It was/is difficult to tell if the snmpgets were disappearing because there were so many. In all honest, I must admit that I did not write down specific PIDs and track them. 

Because the command we all execute runs vmstat for a couple of seconds, we always running into the timeout, so I set it to 20 seconds when calling snmpget. 

I had forgotten about the catching the errors like that (or maybe never knew it). Definately a useful thing.

In the meantime, I installed the net-snmp perl module and change the code accordingly. The timeouts are still the same, so my *guess* at this point it was something specific to the snmpget.exe. Possibly it wasn't exiting cleaning and was just hanging around and causing problems with subsequent connections.

At any rate, things are happy now. Thanks again!

Regards,

Jim Mohr


-------------------------------------------------------
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_idt77&alloc_id492&op=click
_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.