foreach ($testers as $id => $info) { $lifetime = 0; if (array_key_exists('first_contact', $info) && $info['first_contact'] < $now) { $lifetime = $now - $info['first_contact']; } $busy = false; if (array_key_exists('test', $info) && strlen($info['test'])) { $busy = true; } if ($info['locCount'] < $locCount && !$busy && $lifetime > 600) { echo "{$id} needs to be rebooted\n"; $reboot[] = $id; } } if (count($reboot)) { $ec2->reboot_instances($reboot); } // get the list of current running ec2 instances $terminate = array(); $count = 0; $response = $ec2->describe_instances(); $activeCount = 0; $idleCount = 0; $offlineCount = 0; if ($response->isOK()) { foreach ($response->body->reservationSet->item as $item) { foreach ($item->instancesSet->item as $instance) { if ($instance->imageId == $ami && $instance->instanceState->code <= 16) { $id = (string) $instance->instanceId; if (array_key_exists($id, $testers) || $addOnly) { if ($testers[$id]['offline']) {