1 |
root |
1.1 |
NAME |
2 |
root |
1.2 |
AnyEvent::SNMP - adaptor to integrate Net::SNMP into Anyevent. |
3 |
root |
1.1 |
|
4 |
|
|
SYNOPSIS |
5 |
root |
1.2 |
use AnyEvent::SNMP; |
6 |
root |
1.1 |
use Net::SNMP; |
7 |
|
|
|
8 |
root |
1.2 |
# just use Net::SNMP and AnyEvent as you like: |
9 |
root |
1.1 |
|
10 |
root |
1.2 |
# use a condvar to transfer results, this is |
11 |
|
|
# just an example, you can use a naked callback as well. |
12 |
|
|
my $cv = AnyEvent->condvar; |
13 |
|
|
|
14 |
|
|
# ... start non-blocking snmp request(s)... |
15 |
|
|
Net::SNMP->session (-hostname => "127.0.0.1", |
16 |
|
|
-community => "public", |
17 |
|
|
-nonblocking => 1) |
18 |
|
|
->get_request (-callback => sub { $cv->send (@_) }); |
19 |
root |
1.1 |
|
20 |
root |
1.2 |
# ... do something else until the result is required |
21 |
|
|
my @result = $cv->wait; |
22 |
root |
1.1 |
|
23 |
|
|
DESCRIPTION |
24 |
root |
1.2 |
This module implements an alternative "event dispatcher" for Net::SNMP, |
25 |
|
|
using AnyEvent as a backend. |
26 |
|
|
|
27 |
|
|
This integrates Net::SNMP into AnyEvent: You can make non-blocking |
28 |
|
|
Net::SNMP calls and as long as other parts of your program also use |
29 |
|
|
AnyEvent (or some event loop supported by AnyEvent), they will run in |
30 |
|
|
parallel. |
31 |
|
|
|
32 |
|
|
Also, the Net::SNMP scheduler is very inefficient with respect to both |
33 |
|
|
CPU and memory usage. Most AnyEvent backends (including the pure-perl |
34 |
|
|
backend) fare much better than the Net::SNMP dispatcher. |
35 |
|
|
|
36 |
|
|
A potential disadvantage is that replacing the dispatcher is not at all |
37 |
|
|
a documented thing to do, so future changes in Net::SNP might break this |
38 |
|
|
module (or the many similar ones). |
39 |
root |
1.1 |
|
40 |
|
|
This module does not export anything and does not require you to do |
41 |
root |
1.2 |
anything special apart from loading it *before doing any non-blocking |
42 |
|
|
requests with Net::SNMP*. It is recommended but not required to load |
43 |
|
|
this module before "Net::SNMP". |
44 |
root |
1.1 |
|
45 |
|
|
SEE ALSO |
46 |
root |
1.2 |
AnyEvent, Net::SNMP, Net::SNMP::EV. |
47 |
root |
1.1 |
|
48 |
|
|
AUTHOR |
49 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
50 |
|
|
http://home.schmorp.de/ |
51 |
|
|
|