Ejemplo n.º 1
0
    $offline = Router_old::countRoutersByCrawlCycleIdAndStatus($actual_crawl_cycle['id'], 'offline');
    $unknown = Router_old::countRoutersByCrawlCycleIdAndStatus($actual_crawl_cycle['id'], 'unknown');
    $total = $unknown + $offline + $online;
    RrdTool::updateNetmonHistoryRouterStatus($online, $offline, $unknown, $total);
    $client_count = Router_old::countRoutersByCrawlCycleId($actual_crawl_cycle['id']);
    RrdTool::updateNetmonClientCount($client_count);
} else {
    echo "There is an crawl cycle running actually. Doing nothing.\n";
}
/**
 * Clean database
 */
echo "Clean database\n";
//Delete old Crawls
echo "Remove old crawl data\n";
Crawling::deleteOldCrawlDataExceptLastOnlineCrawl($GLOBALS['hours_to_keep_mysql_crawl_data'] * 60 * 60);
//Remove old events
echo "Remove old events\n";
//Get number of total events in db
$total_count = new Eventlist();
$total_count->init(false, false, false, 0, 0);
$total_count = $total_count->getTotalCount();
//Fetch the 50 oldest events from db and check if they need to be deleted.
//Then fetch the next 50 oldest events until you get to an event that is not old enough to delete it
//or if you looped through all events.
for ($offset = 0; $offset < $total_count; $offset += 50) {
    $eventlist = new Eventlist();
    $eventlist->init(false, false, false, $offset, 50, 'create_date', 'asc');
    foreach ($eventlist->getEventlist() as $event) {
        if ($event->getCreateDate() < time() - 60 * 60 * $GLOBALS['hours_to_keep_history_table']) {
            $event->delete();