#!/usr/bin/perl use lib '/opt/nagios'; use assets; my $db = new assets; $db->init(); my $searchstring="disposed='0' and purpose like '%Desktop' order by rand()"; my $hosts = $db->get_assets($searchstring); foreach my $i (@$hosts){ my $hostname = $i->{'hostname'}; my @macs= split(/;/, $i->{'mac'}); foreach my $mac (@macs) { # print STDERR "Waking up $hostname\n"; system "/usr/bin/wakeonlan $mac > /dev/null"; #perl sleep only does integer seconds, #could use Time::HiRes but this `trick' is easier select(undef, undef, undef, 0.45); #without this delay each loop would take about 0.015 seconds } }