Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: limiting number of snmp requests

by choroba (Cardinal)
on Nov 06, 2015 at 16:03 UTC ( [id://1147107]=note: print w/replies, xml ) Need Help??


in reply to limiting number of snmp requests

I don't know how snmp works and what an oid is. But to process an array in batches of 50, you can use splice:
#!/usr/bin/perl use warnings; use strict; my @oids = (1 .. 370); while (@oids) { print "Starting iteration\n"; my @process = splice @oids, 0, 50; print "probe $_\n" for @process; }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: limiting number of snmp requests
by karlgoethebier (Abbot) on Nov 09, 2015 at 21:52 UTC
Re^2: limiting number of snmp requests
by t_rex_joe (Sexton) on Nov 10, 2015 at 19:44 UTC
    Dilip, Here's another way of doing the loop. I am assuming the oids are the same everytime you execute the script. You did not specify if the script was executed once or many times to remember it's stopping point. I took the code from choroba and changed a few lines.
    #!/usr/bin/perl use warnings; use strict; my @oids = ( '.1.2.3.4.2.1.3.0', '.1.23.4.2.1.3.4.0'); my $oid = undef; my $ct = 0; foreach $oid (@oids) { if ($ct > 50) { print "PROBED CT: \"$ct\" OIDS. SLEEPING X\n"; sleep + 10; $ct = 0; } print "PROCESSING OID: \"$oid\" \n"; $ct += 1; }
    Joe

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1147107]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-25 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found