ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-SNMP/SNMP.pm
(Generate patch)

Comparing AnyEvent-SNMP/SNMP.pm (file contents):
Revision 1.5 by root, Wed Apr 22 12:31:20 2009 UTC vs.
Revision 1.6 by root, Sat Apr 25 12:20:50 2009 UTC

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
54Use this package variable to restrict the number of outstanding SNMP 56Use this package variable to restrict the number of outstanding SNMP
55requests at any point in time. 57requests at any point in time.
56 58
57Net::SNMP is very fast at creating and sending SNMP requests, but much 59Net::SNMP is very fast at creating and sending SNMP requests, but much
58slower at parsing (big, bulk) responses. This makes it easy to request a 60slower at parsing (big, bulk) responses. This makes it easy to request a
61In the best case, this can lead to unnecessary delays (and even time-outs, 63In the best case, this can lead to unnecessary delays (and even time-outs,
62as the data has been received but not yet processed) and in the worst 64as the data has been received but not yet processed) and in the worst
63case, this can lead to packet loss, when the receive queue overflows and 65case, this can lead to packet loss, when the receive queue overflows and
64the kernel can no longer accept new packets. 66the kernel can no longer accept new packets.
65 67
66To avoid this, you can (and should) limit the number of outstanding requests 68To avoid this, you can (and should) limit the number of outstanding
67to a number low enough so that parsing time doesn't introduce noticable delays. 69requests to a number low enough so that parsing time doesn't introduce
70noticable delays.
68 71
69Unfortunately, this number depends not only on processing speed and load 72Unfortunately, this number depends not only on processing speed and load
70of the machine running Net::SNMP, but also on the network latency and the 73of the machine running Net::SNMP, but also on the network latency and the
71speed of your SNMP agents. 74speed of your SNMP agents.
72 75
73AnyEvent::SNMP tries to dynamically adjust this number dynamically upwards 76AnyEvent::SNMP tries to dynamically adjust this number dynamically upwards
74and downwards. 77and downwards.
78
79Increasing C<$MAX_OUTSTANDING> will not automatically use the
80C<extra request slots. To increase $MAX_OUTSTANDING> and make
81C<C<AnyEvent::SNMP> make use of the extra paralellity, call
82C<AnyEvent::SNMP::set_max_outstanding> with the new value, e.g.:
83
84 AnyEvent::SNMP::set_max_outstanding 500;
85
86Although due to the dynamic adjustment, this might have little lasting
87effect.
75 88
76Note that you can use L<Net::SNMP::XS> to speed up parsing of responses 89Note that you can use L<Net::SNMP::XS> to speed up parsing of responses
77considerably. 90considerably.
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
305sub send_pdu($$$) { 319sub 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
331sub one_event($) { 345sub one_event($) {
332 AnyEvent->one_event; 346 AnyEvent->one_event;
333} 347}
334 348
349sub set_max_outstanding($) {
350 $MAX_OUTSTANDING = $_[0];
351 kick_job;
352}
353
335=head1 SEE ALSO 354=head1 SEE ALSO
336 355
337L<AnyEvent>, L<Net::SNMP>, L<Net::SNMP::XS>, L<Net::SNMP::EV>. 356L<AnyEvent>, L<Net::SNMP>, L<Net::SNMP::XS>, L<Net::SNMP::EV>.
338 357
339=head1 AUTHOR 358=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines