How to check snmpd is running or not

Discussion in 'Ruby' started by Chandra Sekhar, Mar 11, 2011.

  1. 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

    --
    Posted via http://www.ruby-forum.com/.
     
    Chandra Sekhar, Mar 11, 2011
    #1
    1. Advertising

  2. 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.

    --
    Posted via http://www.ruby-forum.com/.
     
    Brian Candler, Mar 12, 2011
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Davisro
    Replies:
    1
    Views:
    695
    Michael D. Ober
    Jun 14, 2004
  2. sherazi
    Replies:
    1
    Views:
    558
    Mandar Amdekar
    Jan 2, 2006
  3. Joel Hedlund
    Replies:
    18
    Views:
    634
    Alex Martelli
    Sep 3, 2006
  4. Jason Stacy
    Replies:
    2
    Views:
    4,700
    Roedy Green
    Apr 27, 2008
  5. Mike
    Replies:
    12
    Views:
    716
    Daniel Pitts
    Sep 26, 2008
Loading...

Share This Page