… | |
… | |
75 | |
75 | |
76 | Unfortunately, this number depends not only on processing speed and load |
76 | Unfortunately, this number depends not only on processing speed and load |
77 | of the machine running Net::SNMP, but also on the network latency and the |
77 | of the machine running Net::SNMP, but also on the network latency and the |
78 | speed of your SNMP agents. |
78 | speed of your SNMP agents. |
79 | |
79 | |
80 | AnyEvent::SNMP tries to dynamically adjust this number dynamically upwards |
80 | AnyEvent::SNMP tries to dynamically adjust this number upwards and |
81 | and downwards. |
81 | downwards. |
82 | |
82 | |
83 | Increasing C<$MAX_OUTSTANDING> will not automatically use the |
83 | Increasing C<$MAX_OUTSTANDING> will not automatically use the |
84 | extra request slots. To increase C<$MAX_OUTSTANDING> and make |
84 | extra request slots. To increase C<$MAX_OUTSTANDING> and make |
85 | C<AnyEvent::SNMP> make use of the extra paralellity, call |
85 | C<AnyEvent::SNMP> make use of the extra paralellity, call |
86 | C<AnyEvent::SNMP::set_max_outstanding> with the new value, e.g.: |
86 | C<AnyEvent::SNMP::set_max_outstanding> with the new value, e.g.: |
… | |
… | |
135 | |
135 | |
136 | =cut |
136 | =cut |
137 | |
137 | |
138 | package AnyEvent::SNMP; |
138 | package AnyEvent::SNMP; |
139 | |
139 | |
140 | no warnings; |
140 | use common::sense; |
141 | use strict qw(subs vars); |
|
|
142 | |
141 | |
143 | # it is possible to do this without loading |
142 | # it is possible to do this without loading |
144 | # Net::SNMP::Dispatcher, but much more awkward. |
143 | # Net::SNMP::Dispatcher, but much more awkward. |
145 | use Net::SNMP::Dispatcher; |
144 | use Net::SNMP::Dispatcher; |
146 | |
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 | |
147 | sub Net::SNMP::Dispatcher::instance { |
150 | sub Net::SNMP::Dispatcher::instance { |
148 | AnyEvent::SNMP:: |
151 | AnyEvent::SNMP:: |
149 | } |
152 | } |
150 | |
153 | |
151 | use Net::SNMP (); |
154 | use Net::SNMP (); |
152 | use AnyEvent (); |
155 | use AnyEvent (); |
153 | |
156 | |
154 | our $VERSION = '1.0'; |
157 | our $VERSION = '6.0'; |
155 | |
158 | |
156 | $Net::SNMP::DISPATCHER = instance Net::SNMP::Dispatcher; |
159 | $Net::SNMP::DISPATCHER = instance Net::SNMP::Dispatcher; |
157 | |
160 | |
158 | our $MESSAGE_PROCESSING = $Net::SNMP::Dispatcher::MESSAGE_PROCESSING; |
161 | our $MESSAGE_PROCESSING = $Net::SNMP::Dispatcher::MESSAGE_PROCESSING; |
159 | |
162 | |
… | |
… | |
338 | kick_job; |
341 | kick_job; |
339 | |
342 | |
340 | 1 |
343 | 1 |
341 | } |
344 | } |
342 | |
345 | |
343 | sub activate($) { |
346 | sub loop($) { |
344 | while ($BUSY) { |
347 | while ($BUSY) { |
345 | $DONE = AE::cv; |
348 | $DONE = AE::cv; |
346 | $DONE->recv; |
349 | $DONE->recv; |
347 | undef $DONE; |
350 | undef $DONE; |
348 | } |
351 | } |
349 | } |
352 | } |
350 | |
353 | |
|
|
354 | *activate = \&loop; # 5.x compatibility? |
|
|
355 | *listen = \&loop; # 5.x compatibility? |
|
|
356 | |
351 | sub one_event($) { |
357 | sub one_event($) { |
352 | # should not ever be used |
358 | # should not ever be used |
353 | AnyEvent->one_event; #d# todo |
359 | AnyEvent->one_event; #d# todo |
354 | } |
360 | } |
355 | |
361 | |
356 | sub set_max_outstanding($) { |
362 | sub set_max_outstanding($) { |
357 | $MAX_OUTSTANDING = $_[0]; |
363 | $MAX_OUTSTANDING = $_[0]; |
358 | kick_job; |
364 | kick_job; |
359 | } |
365 | } |
360 | |
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 | |
361 | =head1 SEE ALSO |
376 | =head1 SEE ALSO |
362 | |
377 | |
363 | L<AnyEvent>, L<Net::SNMP>, L<Net::SNMP::XS>, L<Net::SNMP::EV>. |
378 | L<AnyEvent>, L<Net::SNMP>, L<Net::SNMP::XS>, L<Net::SNMP::EV>. |
364 | |
379 | |
365 | =head1 AUTHOR |
380 | =head1 AUTHOR |