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.11 by root, Sun Oct 31 18:26:27 2010 UTC vs.
Revision 1.13 by root, Mon Nov 24 18:16:54 2014 UTC

32 32
33Also, the Net::SNMP scheduler is very inefficient with respect to both CPU 33Also, the Net::SNMP scheduler is very inefficient with respect to both CPU
34and memory usage. Most AnyEvent backends (including the pure-perl backend) 34and memory usage. Most AnyEvent backends (including the pure-perl backend)
35fare much better than the Net::SNMP dispatcher. 35fare much better than the Net::SNMP dispatcher.
36 36
37Another major added fetaure of this module over Net::SNMP is automatic 37Another major added feature of this module over Net::SNMP is automatic
38rate-adjustments: Net::SNMP is so slow that firing a few thousand 38rate-adjustments: Net::SNMP is so slow that firing a few thousand
39requests can cause many timeouts simply because Net::SNMP cannot process 39requests can cause many timeouts simply because Net::SNMP cannot process
40the replies in time. This module automatically adapts the send rate to 40the replies in time. This module automatically adapts the send rate to
41avoid false timeouts caused by slow reply processing. 41avoid false timeouts caused by slow reply processing.
42 42
43A potential disadvantage of this module is that replacing the dispatcher 43A potential disadvantage of this module is that replacing the dispatcher
44is not at all a documented thing to do, so future changes in Net::SNP 44is not at all a documented thing to do, so future changes in Net::SNMP
45might break this module (or the many similar ones). 45might break this module (or the many similar ones).
46 46
47This module does not export anything and does not require you to do 47This module does not export anything and does not require you to do
48anything special apart from loading it I<before doing any non-blocking 48anything special apart from loading it I<before doing any non-blocking
49requests with Net::SNMP>. It is recommended but not required to load this 49requests with Net::SNMP>. It is recommended but not required to load this
69case, this can lead to packet loss, when the receive queue overflows and 69case, this can lead to packet loss, when the receive queue overflows and
70the kernel can no longer accept new packets. 70the kernel can no longer accept new packets.
71 71
72To avoid this, you can (and should) limit the number of outstanding 72To avoid this, you can (and should) limit the number of outstanding
73requests to a number low enough so that parsing time doesn't introduce 73requests to a number low enough so that parsing time doesn't introduce
74noticable delays. 74noticeable delays.
75 75
76Unfortunately, this number depends not only on processing speed and load 76Unfortunately, this number depends not only on processing speed and load
77of the machine running Net::SNMP, but also on the network latency and the 77of the machine running Net::SNMP, but also on the network latency and the
78speed of your SNMP agents. 78speed of your SNMP agents.
79 79
80AnyEvent::SNMP tries to dynamically adjust this number upwards and 80AnyEvent::SNMP tries to dynamically adjust this number upwards and
81downwards. 81downwards.
82 82
83Increasing C<$MAX_OUTSTANDING> will not automatically use the 83Increasing C<$MAX_OUTSTANDING> will not automatically use the
84extra request slots. To increase C<$MAX_OUTSTANDING> and make 84extra request slots. To increase C<$MAX_OUTSTANDING> and make
85C<AnyEvent::SNMP> make use of the extra paralellity, call 85C<AnyEvent::SNMP> make use of the extra parallelity, call
86C<AnyEvent::SNMP::set_max_outstanding> with the new value, e.g.: 86C<AnyEvent::SNMP::set_max_outstanding> with the new value, e.g.:
87 87
88 AnyEvent::SNMP::set_max_outstanding 500; 88 AnyEvent::SNMP::set_max_outstanding 500;
89 89
90Although due to the dynamic adjustment, this might have little lasting 90Although due to the dynamic adjustment, this might have little lasting
103When AnyEvent::SNMP handles $MAX_RECVQUEUE or more packets per iteration 103When AnyEvent::SNMP handles $MAX_RECVQUEUE or more packets per iteration
104it will reduce $MAX_OUTSTANDING. If it handles less than $MIN_RECVQUEUE, 104it will reduce $MAX_OUTSTANDING. If it handles less than $MIN_RECVQUEUE,
105it increases $MAX_OUTSTANDING. 105it increases $MAX_OUTSTANDING.
106 106
107This has the result of adjusting the number of outstanding requests so that 107This has the result of adjusting the number of outstanding requests so that
108the recv queue is between the minimum and maximu, usually. 108the recv queue is between the minimum and maximum, usually.
109 109
110This algorithm works reasonably well as long as the responses, response 110This algorithm works reasonably well as long as the responses, response
111latencies and processing times are the same size per packet on average. 111latencies and processing times are the same per packet on average.
112 112
113=back 113=back
114 114
115=head1 COMPATIBILITY 115=head1 COMPATIBILITY
116 116
141 141
142# it is possible to do this without loading 142# it is possible to do this without loading
143# Net::SNMP::Dispatcher, but much more awkward. 143# Net::SNMP::Dispatcher, but much more awkward.
144use Net::SNMP::Dispatcher; 144use Net::SNMP::Dispatcher;
145 145
146# we could inherit fro Net:SNMP::Dispatcher, but since this is undocumented,
147# I'd rather see it die (and reported) than silenty and subtly fail.
148*msg_handle_alloc = \&Net::SNMP::Dispatcher::msg_handle_alloc;
149
146sub Net::SNMP::Dispatcher::instance { 150sub Net::SNMP::Dispatcher::instance {
147 AnyEvent::SNMP:: 151 AnyEvent::SNMP::
148} 152}
149 153
150use Net::SNMP (); 154use Net::SNMP ();
151use AnyEvent (); 155use AnyEvent ();
152 156
153our $VERSION = '1.0'; 157our $VERSION = '6.0';
154 158
155$Net::SNMP::DISPATCHER = instance Net::SNMP::Dispatcher; 159$Net::SNMP::DISPATCHER = instance Net::SNMP::Dispatcher;
156 160
157our $MESSAGE_PROCESSING = $Net::SNMP::Dispatcher::MESSAGE_PROCESSING; 161our $MESSAGE_PROCESSING = $Net::SNMP::Dispatcher::MESSAGE_PROCESSING;
158 162
337 kick_job; 341 kick_job;
338 342
339 1 343 1
340} 344}
341 345
342sub activate($) { 346sub loop($) {
343 while ($BUSY) { 347 while ($BUSY) {
344 $DONE = AE::cv; 348 $DONE = AE::cv;
345 $DONE->recv; 349 $DONE->recv;
346 undef $DONE; 350 undef $DONE;
347 } 351 }
348} 352}
349 353
354*activate = \&loop; # 5.x compatibility?
355*listen = \&loop; # 5.x compatibility?
356
350sub one_event($) { 357sub one_event($) {
351 # should not ever be used 358 # should not ever be used
352 AnyEvent->one_event; #d# todo 359 AnyEvent->one_event; #d# todo
353} 360}
354 361
355sub set_max_outstanding($) { 362sub set_max_outstanding($) {
356 $MAX_OUTSTANDING = $_[0]; 363 $MAX_OUTSTANDING = $_[0];
357 kick_job; 364 kick_job;
358} 365}
359 366
367# not provided yet:
368# schedule # apparently only used by Net::SNMP::Dispatcher itself
369# register # apparently only used by Net::SNMP::Dispatcher itself
370# deregister # apparently only used by Net::SNMP::Dispatcher itself
371# cancel # apparently only used by Net::SNMP::Dispatcher itself
372# return_response_pdu # apparently not used at all?
373# error # only used by Net::SNMP::Dispatcher itself?
374# debug # only used by Net::SNMP::Dispatcher itself?
375
360=head1 SEE ALSO 376=head1 SEE ALSO
361 377
362L<AnyEvent>, L<Net::SNMP>, L<Net::SNMP::XS>, L<Net::SNMP::EV>. 378L<AnyEvent>, L<Net::SNMP>, L<Net::SNMP::XS>, L<Net::SNMP::EV>.
363 379
364=head1 AUTHOR 380=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines