From: Marcus Bristav Date: 2007-04-15T01:31:35+09:00 Subject: Re: SNMP agent library? Ok. You can send me offlist to my address used here. This sounds very interesting indeed. Thanks a lot :) /Marcus On 4/14/07, Francis Cianfrocca wrote: > On 4/13/07, Marcus Bristav wrote: > > > > On 4/13/07, Francis Cianfrocca wrote: > > > > I can help with documentation. Keep in mind though that I'm still in > > research mode so the speed won't be that great initially. But I've > > heard only good things about Eventmachine so it will be exciting to > > test it out and learn to use it. Maybe we can find more uses for it > > here :) > > > > Ok, I refactored our app-specific MIB handling out and I have a > functionally-complete SNMP agent (minus trap support). You have to add your > own MIBs. Eventually we should have built-in support > for the standard ones, as long as they are easily scriptable. Here's what > your code would look like: > > #-------------------------------------------------------- > require "rubygems" > require "eventmachine" > require "net/snmp" > > require 'snmpagent' > include EventMachine::SnmpAgent > > agnt = Agent.new :verbose=>true > > agnt.add_object [1,3,6,1,2,1,1,1,0], "baloney" > agnt.add_object [1,3,6,1,2,1,1,3,0], proc {`cat > /proc/uptime`.split.first.to_i * 100} > > agnt.run > #-------------------------------------------------------- > > > You can test with snmpwalk or any "real" management system. This code has > been tested against OpenView, Argent, SolarWinds, and some others. Obviously > the example only adds two managed objects. In practice you would add your > "real" objects in a Ruby module whose name you pass to > EventMachine::SnmpAgent::Agent#new. > > If you're interested, I can send the library to your private email. If > anyone else is interested, let me know here and I'll put a distro package on > the EventMachine rubyforge page. > > The net/snmp library comes from the Net::LDAP library (on Rubyforge). >