How to check snmpd is running or not

C

Chandra Sekhar

Hi

I am working with SNMP in ruby, I have installed the SNMP library and
Written two functions for Set and Get request but when i run this
I am getting below error.

Then I cross-checked again, and notice that "snmp client" is not
running.

I want to handle this exception. What is the preferred way to do that?

"c:/ruby/lib/ruby/gems/1.8/gems/snmp-1.0.3/lib/snmp/manager.rb:462:
warning: An existing connection was forcibly closed by the remote host.
- recvfrom(2)"


If anybody can help me with this task

Thanks in advance :)

-- Chandrasekhar
 
B

Brian Candler

Chandra Sekhar wrote in post #986837:
I am working with SNMP in ruby, I have installed the SNMP library and
Written two functions for Set and Get request

Do you mean that you are writing an SNMP *client* application in Ruby -
that is, something which *sends* set and get requests?
but when i run this
I am getting below error.

Then I cross-checked again, and notice that "snmp client" is not
running.

Which "snmp client" are you talking about?

If your ruby code is an snmp client, then it needs to talk to an snmp
server ("snmp agent"). If this is on a Windows box then you need to
start the snmp service. You also need to know the shared secret.
I want to handle this exception. What is the preferred way to do that?

"c:/ruby/lib/ruby/gems/1.8/gems/snmp-1.0.3/lib/snmp/manager.rb:462:
warning: An existing connection was forcibly closed by the remote host.
- recvfrom(2)"

That doesn't look like an exception to me - it says "warning"

If you look at manager.rb around line 462, you'll see this code:

def warn(message)
trace = caller(2)
location = trace[0].sub(/:in.*/,'')
Kernel::warn "#{location}: warning: #{message}"
end

def load_modules(module_list, mib_dir)
module_list.each { |m| @mib.load_module(m, mib_dir) }
end

def try_request(request, community=@community, host=@host,
port=@port)
(@retries + 1).times do |n|
send_request(request, community, host, port)
begin
Timeout.timeout(@timeout) do
return get_response(request)
end
rescue Timeout::Error
# no action - try again
rescue => e
warn e.to_s
end
end
raise RequestTimeout, "host #{@config[:Host]} not responding",
caller
end

That is: the snmp gem has already caught the exception (rescue => e),
and turned it into a warning (warn e.to_s); the warn method calls
Kernel::warn which just prints it out.

The warning message isn't particularly helpful, but it might mean that
it got an ICMP port unreachable message in response - which means
there's nothing listening on the SNMP port (udp 161), which in turn
means you're not running an SNMP agent/service.

You can use wireshark to capture the SNMP packets and their responses,
to see if that's actually the case.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top