Reply
Highlighted

Slow DHCP Lease remove using Perl script

Techie
Posts: 14
3762     0

I have finally  a Perl script running to connect to one of our Grid systems and issues DHCP Lease remove commands.  If the I have 2 leases in active state in a pool of 4343 leases in free state, the main loop will execute in 3 secondes. If I have 250 leases en active state, it take 335 secondes.  At  1.336 sec/remove, it would take more then 3 hours to delete 8500 leases, a job we have to run normally every 15 minutes (don't ask why, it's a network of 8500 POS)...

 

Any idea on how to accelerate this?

 

----------------------

Here the script

 


print scalar(localtime)." Retrieving AuthPolicy\n\n";
$session->get(object => "Infoblox::Grid::Admin::AuthPolicy");
my $total=0;

#Script pour effacer tous les leases dans un Network View.

# Get a All DHCP leases.
print scalar(localtime)." Recueille tous les leases DHCP, actif ou non\n\n";

my @retrieved_objs = $session->get(
object => "Infoblox:Smiley Very HappyHCP::Lease",
network_view => "xxxxxx"
);

# Iteratively Remove a DHCP Lease object
print scalar(localtime)." Debute la boucle pour effacer les lease\n\n";

foreach (@retrieved_objs) {
my $desired_lease = $_;
unless($desired_lease){
die("get lease failed: ",
$session->status_code() . ":" . $session->status_detail());
}

if ($desired_lease->{'binding_state'} eq "active") {
$session->remove($desired_lease)
or die("Remove dhcp lease failed: ",
$session->status_code() . ":" . $session->status_detail());
# print "Lease $desired_lease->{'ipv4addr'} a ete efface \n";
++$total
}

}

print "Nombre de commande Remove_lease: $total\n";

print scalar(localtime)." Termine\n";

 

Highlighted

Re: Slow DHCP Lease remove using Perl script

Community Manager
Community Manager
Posts: 248
3763     0

It looks like you want to reset ALL the active leases in the grid. As such you're getting all the leases in a network view. This is the slowdown.

 

There is no easy workaround to this. You can't search for leases by their binding_state. So you have to get all the leases.

 

What you can try is to batch the requests, either using paging, or getting the leases one network at a time.

 

 

Highlighted

Re: Slow DHCP Lease remove using Perl script

Techie
Posts: 14
3763     0

The problem is that we have 22 000 networks with 1 IP DHCP range each, of those, 8 500 are active and need to be reset...

In my lab, a delete take the same amount of time per lease with a 2 active lease network or a 250 leases network.  The «speed» of delete seem the issue here. 

 

Still waiting for a feedback from Support

Highlighted

Re: Slow DHCP Lease remove using Perl script

Techie
Posts: 14
3763     0

Definitively, the remove command is the source of the problem.  The Get for 7225 active leases take 3 minutes,  the loop to remove the 7225 active leases take 2h38m11s.

 

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin