![]() |
![]()
| ![]() |
![]()
NAMEAnyEvent::SNMP - adaptor to integrate Net::SNMP into AnyEvent. SYNOPSISuse AnyEvent::SNMP; use Net::SNMP; # just use Net::SNMP and AnyEvent as you like: # use a condvar to transfer results, this is # just an example, you can use a naked callback as well. my $cv = AnyEvent->condvar; # ... start non-blocking snmp request(s)... Net::SNMP->session (-hostname => "127.0.0.1", -community => "public", -nonblocking => 1) ->get_request (-callback => sub { $cv->send (@_) }); # ... do something else until the result is required my @result = $cv->wait; DESCRIPTIONThis module implements an alternative "event dispatcher" for Net::SNMP, using AnyEvent as a backend. This integrates Net::SNMP into AnyEvent. That means you can make non-blocking Net::SNMP calls and as long as other parts of your program also use AnyEvent (or some event loop supported by AnyEvent), they will run in parallel. Also, the Net::SNMP scheduler is very inefficient with respect to both CPU and memory usage. Most AnyEvent backends (including the pure-perl backend) fare much better than the Net::SNMP dispatcher. Another major added fetaure of this module over Net::SNMP is automatic rate-adjustments: Net::SNMP is so slow that firing a few thousand requests can cause many timeouts simply because Net::SNMP cannot process the replies in time. This module automatically adapts the send rate to avoid false timeouts caused by slow reply processing. A potential disadvantage of this module is that replacing the dispatcher is not at all a documented thing to do, so future changes in Net::SNP might break this module (or the many similar ones). This module does not export anything and does not require you to do anything special apart from loading it before doing any non-blocking requests with Net::SNMP. It is recommended but not required to load this module before "Net::SNMP". GLOBAL VARIABLES
COMPATIBILITYThis module may be used as a drop in replacement for the Net::SNMP::Dispatcher in existing programs. You can still call "snmp_dispatcher" to start the event-loop, but then you loose the benefit of mixing Net::SNMP events with other events. use AnyEvent::SNMP; use Net::SNMP; # just use Net::SNMP as before # ... start non-blocking snmp request(s)... Net::SNMP->session ( -hostname => "127.0.0.1", -community => "public", -nonblocking => 1, )->get_request (-callback => sub { ... }); snmp_dispatcher; SEE ALSOAnyEvent, Net::SNMP, Net::SNMP::XS, Net::SNMP::EV. AUTHORMarc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/
|