/**
  * @see parent::getSpec()
  */
 function getSpec()
 {
     $spec = parent::getSpec();
     $spec->table = 'access_log_archive';
     $spec->archive = true;
     return $spec;
 }
/**
 * Génération des données des graphiques du palmarès ressources
 *
 * @param string $module   Module concerné
 * @param string $date     Date de référence
 * @param string $element  Type de données à afficher
 * @param string $interval Interval de temps à analyser
 * @param int    $numelem  Nombre d'éléments maximum
 *
 * @return array Les données de palmarès
 */
function graphRessourceLog($module, $date, $element = 'duration', $interval = 'day', $numelem = 4)
{
    if (!$date) {
        $date = CMbDT::date();
    }
    switch ($interval) {
        default:
        case "day":
            $startx = "{$date} 00:00:00";
            $endx = "{$date} 23:59:59";
            break;
        case "month":
            $startx = CMbDT::dateTime("-1 MONTH", "{$date} 00:00:00");
            $endx = "{$date} 23:59:59";
            break;
        case "year":
            $startx = CMbDT::dateTime("-27 WEEKS", "{$date} 00:00:00");
            $endx = "{$date} 23:59:59";
            break;
    }
    if ($module == "total") {
        $groupmod = 0;
        $module_name = null;
    } elseif ($module == "modules") {
        $groupmod = 1;
        $module_name = null;
    } else {
        $groupmod = 0;
        $module_name = $module;
    }
    $logs = CAccessLog::loadAggregation($startx, $endx, $groupmod, $module_name);
    $series = array();
    $i = 0;
    foreach ($logs as $data) {
        $series[$i]["data"] = array(array(0, $data->{$element}));
        $series[$i]["label"] = $module != 'modules' ? $data->_action : $data->_module;
        $i++;
    }
    if (!function_exists('compareDataPie')) {
        /**
         * Comparaison entre deux données du graphique en pie
         *
         * @param array $a Première donnée
         * @param array $b Deuxième donnée
         *
         * @return bool La première valeur est-elle inférieure à la deuxième
         */
        function compareDataPie($a, $b)
        {
            return $a["data"][0][1] < $b["data"][0][1];
        }
    }
    usort($series, "compareDataPie");
    $seriesNew = array_slice($series, 0, $numelem);
    if (count($series) > $numelem) {
        $other = array_slice($series, $numelem);
        $seriesNew[$numelem]["data"] = array(array(0, 0));
        $seriesNew[$numelem]["label"] = "Autres";
        $n = 0;
        foreach ($other as $_other) {
            $seriesNew[$numelem]["data"][0][1] += $_other["data"][0][1];
            $n++;
        }
        $seriesNew[$numelem]["label"] .= " ({$n})";
    }
    $series = $seriesNew;
    // Set up the title for the graph
    $title = CMbDT::format($date, "%A %d %b %Y");
    if ($module) {
        $title .= " : " . CAppUI::tr($module);
    }
    $options = array('title' => utf8_encode($title), 'HtmlText' => false, 'grid' => array('verticalLines' => false, 'horizontalLines' => false, 'outlineWidth' => 0), 'xaxis' => array('showLabels' => false), 'yaxis' => array('showLabels' => false), 'pie' => array('show' => true, 'sizeRatio' => 0.5), 'legend' => array('backgroundOpacity' => 0.3));
    return array('series' => $series, 'options' => $options);
}
Esempio n. 3
0
// System probes
$rusage = getrusage();
$log->processus += round(floatval($rusage["ru_utime.tv_usec"]) / 1000000 + $rusage["ru_utime.tv_sec"], 3);
$log->processor += round(floatval($rusage["ru_stime.tv_usec"]) / 1000000 + $rusage["ru_stime.tv_sec"], 3);
$log->peak_memory += memory_get_peak_usage();
// SQL stats
$log->request += round(floatval($ds->chrono->total), 3);
$log->nb_requests += $ds->chrono->nbSteps;
// Bandwidth
$log->size += CApp::getOuputBandwidth();
//$log->other_bandwidth += CApp::getOtherBandwidth();
// Error log stats
$log->errors += CApp::$performance["error"];
$log->warnings += CApp::$performance["warning"];
$log->notices += CApp::$performance["notice"];
CAccessLog::bufferize(array($log));
if (!CAppUI::conf("log_datasource_metrics")) {
    return;
}
$dslogs = array();
foreach (CSQLDataSource::$dataSources as $_datasource) {
    if ($_datasource) {
        $dslog = new CDataSourceLog();
        $dslog->module_action_id = $log->module_action_id;
        $dslog->datasource = $_datasource->dsn;
        $dslog->requests = $_datasource->chrono->nbSteps;
        $dslog->duration = round(floatval($_datasource->chrono->total), 3);
        $dslog->period = $log->period;
        $dslog->aggregate = $log->aggregate;
        $dslog->bot = $log->bot;
        $dslogs[] = $dslog;
Esempio n. 4
0
            $_graph = call_user_func("{$log->_class}::graphAccessLog", $log->_module, null, $from, $to, $interval, $left, $right, $human_bot);
            if (!isset($graphs_by_module[$log->_module])) {
                // 1st iteration => graph initialisation
                $graphs_by_module[$log->_module] = $_graph;
            } else {
                // Merging of module series and datetime_by_index
                foreach ($_graph["series"] as $_k1 => $_serie) {
                    foreach ($_graph["series"][$_k1]["data"] as $_k2 => $_data) {
                        $graphs_by_module[$log->_module]["series"][$_k1]["data"][$_k2][1] += $_data[1];
                    }
                }
                $graphs_by_module[$log->_module]["datetime_by_index"] += $_graph["datetime_by_index"];
            }
            break;
        case 2:
            $_graph = CAccessLog::graphAccessLog(null, null, $from, $to, $interval, $left, $right, $human_bot);
            $_archive_graph = CAccessLogArchive::graphAccessLog(null, null, $from, $to, $interval, $left, $right, $human_bot);
            // Merging of series and datetime_by_index
            foreach ($_archive_graph["series"] as $_k1 => $_serie) {
                foreach ($_archive_graph["series"][$_k1]["data"] as $_k2 => $_data) {
                    $_graph["series"][$_k1]["data"][$_k2][1] += $_data[1];
                }
            }
            $_graph["datetime_by_index"] += $_archive_graph["datetime_by_index"];
            $graphs[] = $_graph;
            break;
    }
}
switch ($groupmod) {
    case 0:
    case 1:
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkAdmin();
CApp::setTimeLimit(0);
CApp::setMemoryLimit("1024M");
$dry_run = CValue::get("dry_run", false);
$table = CValue::get("table");
switch ($table) {
    case "access_log":
        CAccessLog::aggregate(10, 60, 1440, $dry_run);
        break;
    case "access_log_archive":
        CAccessLogArchive::aggregate(10, 60, 1440, $dry_run);
        break;
    case "datasource_log":
        CDataSourceLog::aggregate(10, 60, 1440, $dry_run);
        break;
    case "datasource_log_archive":
        CDataSourceLogArchive::aggregate(10, 60, 1440, $dry_run);
        break;
    default:
        CAccessLog::aggregate(10, 60, 1440, $dry_run);
        CAccessLogArchive::aggregate(10, 60, 1440, $dry_run);
        CDataSourceLog::aggregate(10, 60, 1440, $dry_run);
        CDataSourceLogArchive::aggregate(10, 60, 1440, $dry_run);
}
echo CAppUI::getMsg();
Esempio n. 6
0
        $from = CMbDT::date("-1 DAY", $next);
        break;
    case "month":
        $from = CMbDT::date("-1 MONTH", $next);
        break;
    case "year":
        $from = CMbDT::date("-6 MONTH", $next);
        break;
}
$graphs = array();
if ($groupres == 1) {
    if ($element != "_average_duration" && $element != "_average_request" && $element != "_average_nb_requests") {
        $graphs[] = graphRessourceLog('modules', $date, $element, $interval, $numelem);
    }
    $graphs[] = graphRessourceLog('total', $date, $element, $interval, $numelem);
} else {
    $logs = CAccessLog::loadAggregation($from, $next, $groupres + 1, 0);
    foreach ($logs as $log) {
        $graphs[] = graphRessourceLog($log->_module, $date, $element, $interval, $numelem);
    }
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("graphs", $graphs);
$smarty->assign("date", $date);
$smarty->assign("groupres", $groupres);
$smarty->assign("element", $element);
$smarty->assign("interval", $interval);
$smarty->assign("numelem", $numelem);
$smarty->assign("listModules", CModule::getInstalled());
$smarty->display("view_ressources_logs.tpl");