1 | =head1 NAME |
1 | =head1 NAME |
2 | |
2 | |
3 | AnyEvent::SNMP - adaptor to integrate Net::SNMP into Anyevent. |
3 | AnyEvent::SNMP - adaptor to integrate Net::SNMP into AnyEvent. |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use AnyEvent::SNMP; |
7 | use AnyEvent::SNMP; |
8 | use Net::SNMP; |
8 | use Net::SNMP; |
… | |
… | |
49 | |
49 | |
50 | =over 4 |
50 | =over 4 |
51 | |
51 | |
52 | =item $AnyEvent::SNMP::MAX_OUTSTANDING (default: C<50>, dynamic) |
52 | =item $AnyEvent::SNMP::MAX_OUTSTANDING (default: C<50>, dynamic) |
53 | |
53 | |
|
|
54 | =item AnyEvent::SNMP::set_max_outstanding $new_value |
|
|
55 | |
54 | Use this package variable to restrict the number of outstanding SNMP |
56 | Use this package variable to restrict the number of outstanding SNMP |
55 | requests at any point in time. |
57 | requests at any point in time. |
56 | |
58 | |
57 | Net::SNMP is very fast at creating and sending SNMP requests, but much |
59 | Net::SNMP is very fast at creating and sending SNMP requests, but much |
58 | slower at parsing (big, bulk) responses. This makes it easy to request a |
60 | slower at parsing (big, bulk) responses. This makes it easy to request a |
… | |
… | |
61 | In the best case, this can lead to unnecessary delays (and even time-outs, |
63 | In the best case, this can lead to unnecessary delays (and even time-outs, |
62 | as the data has been received but not yet processed) and in the worst |
64 | as the data has been received but not yet processed) and in the worst |
63 | case, this can lead to packet loss, when the receive queue overflows and |
65 | case, this can lead to packet loss, when the receive queue overflows and |
64 | the kernel can no longer accept new packets. |
66 | the kernel can no longer accept new packets. |
65 | |
67 | |
66 | To avoid this, you can (and should) limit the number of outstanding requests |
68 | To avoid this, you can (and should) limit the number of outstanding |
67 | to a number low enough so that parsing time doesn't introduce noticable delays. |
69 | requests to a number low enough so that parsing time doesn't introduce |
|
|
70 | noticable delays. |
68 | |
71 | |
69 | Unfortunately, this number depends not only on processing speed and load |
72 | Unfortunately, this number depends not only on processing speed and load |
70 | of the machine running Net::SNMP, but also on the network latency and the |
73 | of the machine running Net::SNMP, but also on the network latency and the |
71 | speed of your SNMP agents. |
74 | speed of your SNMP agents. |
72 | |
75 | |
73 | AnyEvent::SNMP tries to dynamically adjust this number dynamically upwards |
76 | AnyEvent::SNMP tries to dynamically adjust this number dynamically upwards |
74 | and downwards. |
77 | and downwards. |
|
|
78 | |
|
|
79 | Increasing C<$MAX_OUTSTANDING> will not automatically use the |
|
|
80 | C<extra request slots. To increase $MAX_OUTSTANDING> and make |
|
|
81 | C<C<AnyEvent::SNMP> make use of the extra paralellity, call |
|
|
82 | C<AnyEvent::SNMP::set_max_outstanding> with the new value, e.g.: |
|
|
83 | |
|
|
84 | AnyEvent::SNMP::set_max_outstanding 500; |
|
|
85 | |
|
|
86 | Although due to the dynamic adjustment, this might have little lasting |
|
|
87 | effect. |
75 | |
88 | |
76 | Note that you can use L<Net::SNMP::XS> to speed up parsing of responses |
89 | Note that you can use L<Net::SNMP::XS> to speed up parsing of responses |
77 | considerably. |
90 | considerably. |
78 | |
91 | |
79 | =item $AnyEvent::SNMP::MIN_RECVQUEUE (default: C<8>) |
92 | =item $AnyEvent::SNMP::MIN_RECVQUEUE (default: C<8>) |
… | |
… | |
300 | ++$BUSY; |
313 | ++$BUSY; |
301 | |
314 | |
302 | _send_pdu $pdu, $pdu->retries; |
315 | _send_pdu $pdu, $pdu->retries; |
303 | } |
316 | } |
304 | } |
317 | } |
|
|
318 | |
305 | sub send_pdu($$$) { |
319 | sub send_pdu($$$) { |
306 | my (undef, $pdu, $delay) = @_; |
320 | my (undef, $pdu, $delay) = @_; |
307 | |
321 | |
308 | # $delay is not very sensibly implemented by AnyEvent::SNMP, |
322 | # $delay is not very sensibly implemented by AnyEvent::SNMP, |
309 | # but apparently it is not a very sensible feature. |
323 | # but apparently it is not a very sensible feature. |
… | |
… | |
330 | |
344 | |
331 | sub one_event($) { |
345 | sub one_event($) { |
332 | AnyEvent->one_event; |
346 | AnyEvent->one_event; |
333 | } |
347 | } |
334 | |
348 | |
|
|
349 | sub set_max_outstanding($) { |
|
|
350 | $MAX_OUTSTANDING = $_[0]; |
|
|
351 | kick_job; |
|
|
352 | } |
|
|
353 | |
335 | =head1 SEE ALSO |
354 | =head1 SEE ALSO |
336 | |
355 | |
337 | L<AnyEvent>, L<Net::SNMP>, L<Net::SNMP::XS>, L<Net::SNMP::EV>. |
356 | L<AnyEvent>, L<Net::SNMP>, L<Net::SNMP::XS>, L<Net::SNMP::EV>. |
338 | |
357 | |
339 | =head1 AUTHOR |
358 | =head1 AUTHOR |