5include_once 
"Services/Authentication/classes/class.ilSessionStatistics.php";
 
   38                switch($ilCtrl->getNextClass())
 
   52                $ilTabs->addSubTab(
"current", 
$lng->txt(
"trac_current_system_load"),
 
   53                        $ilCtrl->getLinkTarget($this, 
"current"));
 
   54                $ilTabs->addSubTab(
"short", 
$lng->txt(
"trac_short_system_load"),
 
   55                        $ilCtrl->getLinkTarget($this, 
"short"));
 
   56                $ilTabs->addSubTab(
"long", 
$lng->txt(
"trac_long_system_load"),
 
   57                        $ilCtrl->getLinkTarget($this, 
"long"));
 
   58                $ilTabs->addSubTab(
"periodic", 
$lng->txt(
"trac_periodic_system_load"),
 
   59                        $ilCtrl->getLinkTarget($this, 
"periodic"));             
 
   62        protected function current($a_export = 
false)
 
   66                $ilTabs->activateSubTab(
"current");
 
   86                                $time_from = strtotime(
"today"); 
 
   87                                $time_to = strtotime(
"tomorrow")-1;
 
   93                                $time_from = $time_to-60*60*24;
 
   99                                $time_from = $time_to-60*60*24*7;
 
  105                                $time_from = $time_to-60*60*24*30;
 
  110                $mode_options = array(
 
  111                        self::MODE_TODAY => 
$lng->txt(
"trac_session_statistics_mode_today"),
 
  112                        self::MODE_LAST_DAY => 
$lng->txt(
"trac_session_statistics_mode_last_day"),
 
  113                        self::MODE_LAST_WEEK => 
$lng->txt(
"trac_session_statistics_mode_last_week"),
 
  114                        self::MODE_LAST_MONTH => 
$lng->txt(
"trac_session_statistics_mode_last_month"));
 
  116                $title = 
$lng->txt(
"trac_current_system_load").
" - ".$mode_options[$mode];                      
 
  122                        include_once 
"Services/Form/classes/class.ilPropertyFormGUI.php";                       
 
  123                        $ilToolbar->setFormAction(
$ilCtrl->getFormAction($this, 
"current"));                    
 
  126                        $mode_selector->setOptions($mode_options);              
 
  127                        $mode_selector->setValue($mode);
 
  128                        $ilToolbar->addInputItem($mode_selector, 
true);
 
  130                        $measure_options = array(
 
  131                                "avg" => 
$lng->txt(
"trac_session_active_avg"),
 
  132                                "min" => 
$lng->txt(
"trac_session_active_min"),
 
  133                                "max" => 
$lng->txt(
"trac_session_active_max"));
 
  136                        $measure_selector->setOptions($measure_options);                
 
  137                        $measure_selector->setValue($measure);
 
  138                        $ilToolbar->addInputItem($measure_selector, 
true);
 
  140                        $ilToolbar->addFormButton(
$lng->txt(
"ok"), 
"current");
 
  142                        if(
sizeof(
$data[
"active"]))
 
  144                                $ilToolbar->addSeparator();
 
  145                                $ilToolbar->addFormButton(
$lng->txt(
"export"), 
"currentExport");
 
  163        protected function short($a_export = 
false)
 
  167                $ilTabs->activateSubTab(
"short");
 
  178                                str_pad($org[
"m"], 2, 
"0", STR_PAD_LEFT).
 
  179                                str_pad($org[
"d"], 2, 
"0", STR_PAD_LEFT);
 
  198                $time_to = mktime(23, 59, 59, substr($start, 4, 2), substr($start, 6, 2),
 
  199                        substr($start, 0, 4));          
 
  203                                $time_from = $time_to-60*60*24;
 
  208                                $time_from = $time_to-60*60*24*7;
 
  213                $mode_options = array(
 
  214                                self::MODE_DAY => 
$lng->txt(
"trac_session_statistics_mode_day"),
 
  215                                self::MODE_WEEK => 
$lng->txt(
"trac_session_statistics_mode_week")
 
  218                $title = 
$lng->txt(
"trac_short_system_load").
" - ".$mode_options[$mode];                        
 
  224                        include_once 
"Services/Form/classes/class.ilPropertyFormGUI.php";
 
  225                        $ilToolbar->setFormAction(
$ilCtrl->getFormAction($this, 
"short"));                      
 
  229                        $ilToolbar->addInputItem($start_selector, 
true);
 
  232                        $mode_selector->setOptions($mode_options);              
 
  233                        $mode_selector->setValue($mode);
 
  234                        $ilToolbar->addInputItem($mode_selector, 
true);
 
  236                        $measure_options = array(
 
  237                                "avg" => 
$lng->txt(
"trac_session_active_avg"),
 
  238                                "min" => 
$lng->txt(
"trac_session_active_min"),
 
  239                                "max" => 
$lng->txt(
"trac_session_active_max"));
 
  242                        $measure_selector->setOptions($measure_options);                
 
  243                        $measure_selector->setValue($measure);
 
  244                        $ilToolbar->addInputItem($measure_selector, 
true);
 
  246                        $ilToolbar->addFormButton(
$lng->txt(
"ok"), 
"short");
 
  248                        if(
sizeof(
$data[
"active"]))
 
  250                                $ilToolbar->addSeparator();
 
  251                                $ilToolbar->addFormButton(
$lng->txt(
"export"), 
"shortExport");
 
  267        protected function long($a_export = 
false)
 
  271                $ilTabs->activateSubTab(
"long");
 
  282                                str_pad($org[
"m"], 2, 
"0", STR_PAD_LEFT).
 
  283                                str_pad($org[
"d"], 2, 
"0", STR_PAD_LEFT);
 
  295                $time_to = mktime(23, 59, 59, substr($start, 4, 2), substr($start, 6, 2),
 
  296                        substr($start, 0, 4));          
 
  300                                $time_from = $time_to-60*60*24*7;
 
  305                                $time_from = $time_to-60*60*24*30;
 
  310                                $time_from = $time_to-60*60*24*365;
 
  315                $mode_options = array(
 
  316                                self::MODE_WEEK => 
$lng->txt(
"trac_session_statistics_mode_week"),
 
  317                                self::MODE_MONTH => 
$lng->txt(
"trac_session_statistics_mode_month"),
 
  318                                self::MODE_YEAR => 
$lng->txt(
"trac_session_statistics_mode_year")
 
  321                $title = 
$lng->txt(
"trac_long_system_load").
" - ".$mode_options[$mode];         
 
  327                        include_once 
"Services/Form/classes/class.ilPropertyFormGUI.php";               
 
  328                        $ilToolbar->setFormAction(
$ilCtrl->getFormAction($this, 
"long"));                                               
 
  332                        $ilToolbar->addInputItem($start_selector, 
true);
 
  335                        $mode_selector->setOptions($mode_options);              
 
  336                        $mode_selector->setValue($mode);
 
  337                        $ilToolbar->addInputItem($mode_selector, 
true);
 
  339                        $ilToolbar->addFormButton(
$lng->txt(
"ok"), 
"long");
 
  341                        if(
sizeof(
$data[
"active"]))
 
  343                                $ilToolbar->addSeparator();
 
  344                                $ilToolbar->addFormButton(
$lng->txt(
"export"), 
"longExport");
 
  364                $ilTabs->activateSubTab(
"periodic");
 
  375                                "-".str_pad($org[
"m"], 2, 
"0", STR_PAD_LEFT).
 
  376                                "-".str_pad($org[
"d"], 2, 
"0", STR_PAD_LEFT);
 
  383                        $_REQUEST[
"sto"] = date(
"Y-m-d", strtotime(
"-7 days"));
 
  389                                "-".str_pad($org[
"m"], 2, 
"0", STR_PAD_LEFT).
 
  390                                "-".str_pad($org[
"d"], 2, 
"0", STR_PAD_LEFT);
 
  395                $time_to = mktime(23, 59, 59, substr($start, 5, 2), substr($start, 8, 2),
 
  396                        substr($start, 0, 4));  
 
  397                $time_from = mktime(0, 0, 1, substr($end, 5, 2), substr($end, 8, 2),
 
  401                if($time_to < $time_from)
 
  404                        $time_to = $time_from;
 
  408                $title = 
$lng->txt(
"trac_periodic_system_load");
 
  414                        include_once 
"Services/Form/classes/class.ilPropertyFormGUI.php";               
 
  415                        $ilToolbar->setFormAction(
$ilCtrl->getFormAction($this, 
"periodic"));                   
 
  419                        $ilToolbar->addInputItem($end_selector, 
true);
 
  423                        $ilToolbar->addInputItem($start_selector, 
true);
 
  425                        $ilToolbar->addFormButton(
$lng->txt(
"ok"), 
"periodic");
 
  427                        if(
sizeof(
$data[
"active"]))
 
  429                                $ilToolbar->addSeparator();
 
  430                                $ilToolbar->addFormButton(
$lng->txt(
"export"), 
"periodicExport");
 
  452                include_once 
"Services/Authentication/classes/class.ilSessionControl.php";
 
  455                $control_active = (
$ilSetting->get(
'session_handling_type', 0) == 1);
 
  470                $left = 
new ilTemplate(
"tpl.session_statistics_left.html", 
true, 
true, 
"Services/Authentication");
 
  472                $left->setVariable(
"CAPTION_CURRENT", 
$lng->txt(
"users_online"));
 
  473                $left->setVariable(
"VALUE_CURRENT", $active);
 
  475                $left->setVariable(
"CAPTION_LAST_AGGR", 
$lng->txt(
"trac_last_aggregation"));
 
  478                $left->setVariable(
"CAPTION_LAST_MAX", 
$lng->txt(
"trac_last_maxed_out_sessions"));
 
  481                $left->setVariable(
"CAPTION_SESSION_CONTROL", 
$lng->txt(
"sess_load_dependent_session_handling"));
 
  484                        $left->setVariable(
"VALUE_SESSION_CONTROL", 
$lng->txt(
"no"));
 
  488                        $left->setVariable(
"VALUE_SESSION_CONTROL", 
$lng->txt(
"yes"));
 
  490                        $left->setCurrentBlock(
"control_details");
 
  492                        $left->setVariable(
"CAPTION_SESSION_CONTROL_LIMIT", 
$lng->txt(
"session_max_count"));
 
  493                        $left->setVariable(
"VALUE_SESSION_CONTROL_LIMIT", $control_max_sessions);
 
  495                        $left->setVariable(
"CAPTION_SESSION_CONTROL_IDLE_MIN", 
$lng->txt(
"session_min_idle"));
 
  496                        $left->setVariable(
"VALUE_SESSION_CONTROL_IDLE_MIN", $control_min_idle);
 
  498                        $left->setVariable(
"CAPTION_SESSION_CONTROL_IDLE_MAX", 
$lng->txt(
"session_max_idle"));
 
  499                        $left->setVariable(
"VALUE_SESSION_CONTROL_IDLE_MAX", $control_max_idle);
 
  501                        $left->setVariable(
"CAPTION_SESSION_CONTROL_IDLE_FIRST", 
$lng->txt(
"session_max_idle_after_first_request"));
 
  502                        $left->setVariable(
"VALUE_SESSION_CONTROL_IDLE_FIRST", $control_max_idle_first);
 
  504                        $left->parseCurrentBlock();
 
  508                if($ilAccess->checkAccess(
"write", 
"", (
int)
$_REQUEST[
"ref_id"]))
 
  510                        $left->setVariable(
"URL_SYNC", 
$ilCtrl->getFormAction($this, 
"adminSync"));             
 
  511                        $left->setVariable(
"CMD_SYNC", 
"adminSync");            
 
  512                        $left->setVariable(
"TXT_SYNC", 
$lng->txt(
"trac_sync_session_stats"));           
 
  518        protected function buildData($a_time_from, $a_time_to, $a_title)
 
  526                $opened = (int)$counters[
"opened"];
 
  527                $closed_limit = (int)$counters[
"closed_limit"];
 
  528                unset($counters[
"opened"]);
 
  529                unset($counters[
"closed_limit"]);
 
  537                $data[
"title"] = $a_title.
" (".
 
  541                $data[
"maxed_out_time"] = array(
$lng->txt(
"trac_maxed_out_time"), $maxed_out_duration);
 
  542                $data[
"maxed_out_counter"] = array(
$lng->txt(
"trac_maxed_out_counter"), $closed_limit);
 
  543                $data[
"opened"] = array(
$lng->txt(
"trac_sessions_opened"), $opened);
 
  544                $data[
"closed"] = array(
$lng->txt(
"trac_sessions_closed"), array_sum($counters));
 
  545                foreach($counters as $type => $counter)
 
  547                        $data[
"closed_details"][] = array(
$lng->txt(
"trac_".$type), (
int)$counter);
 
  555        protected function render($a_data, $a_scale, $a_measure = 
null)
 
  559                $center = 
new ilTemplate(
"tpl.session_statistics_center.html", 
true, 
true, 
"Services/Authentication");          
 
  561                foreach($a_data as $idx => $item)
 
  570                                case "closed_details":
 
  571                                        $center->setCurrentBlock(
"closed_details");
 
  572                                        foreach($item as $detail)
 
  574                                                $center->setVariable(
"CAPTION_CLOSED_DETAILS", $detail[0]);
 
  575                                                $center->setVariable(
"VALUE_CLOSED_DETAILS", $detail[1]);
 
  576                                                $center->parseCurrentBlock();
 
  581                                        $tpl_var = strtoupper($idx);
 
  582                                        $center->setVariable(
"CAPTION_".$tpl_var, $item[0]);
 
  583                                        $center->setVariable(
"VALUE_".$tpl_var, $item[1]);
 
  588                if($a_data[
"active"])
 
  590                        $center->setVariable(
"CHART", $this->
getChart($a_data[
"active"], $a_data[
"title"], $a_scale, $a_measure));
 
  597                return $center->get();                                  
 
  609        protected function getChart($a_data, $a_title, $a_scale = self::SCALE_DAY, $a_measure = 
null)
 
  613                include_once 
"Services/Chart/classes/class.ilChart.php";
 
  615                $chart->setsize(700, 500);              
 
  616                $chart->setYAxisToInteger(
true);
 
  619                $chart->setLegend($legend);
 
  623                        $a_measure = array(
"min", 
"avg", 
"max");
 
  625                else if(!is_array($a_measure))
 
  627                        $a_measure = array($a_measure);
 
  630                $colors_map = array(
"min" => 
"#00cc00",
 
  634                $colors = $act_line = array();          
 
  635                foreach($a_measure as $measure)
 
  638                        $act_line[$measure]->setLineSteps(
true);
 
  639                        $act_line[$measure]->setLabel(
$lng->txt(
"trac_session_active_".$measure));
 
  640                        $colors[] = $colors_map[$measure];
 
  643                if($a_scale != self::SCALE_PERIODIC_WEEK)
 
  646                        $max_line->setLabel(
$lng->txt(
"session_max_count"));
 
  647                        $colors[] = 
"#cc0000";
 
  650                $chart->setColors($colors);             
 
  655                $scale = ceil(
sizeof($chart_data)/5);
 
  657                foreach($chart_data as $idx => $item)
 
  659                    $date = $item[
"slot_begin"];
 
  661                        if($a_scale == self::SCALE_PERIODIC_WEEK || !($idx % ceil($scale)))
 
  666                                                $labels[$date] = date(
"H:i", $date);
 
  670                                                $labels[$date] = date(
"d.m. H", $date).
"h";
 
  674                                                $labels[$date] = date(
"d.m.", $date);
 
  678                                                $labels[$date] = date(
"Y-m", $date);
 
  682                                                $day = substr($date, 0, 1);                                             
 
  683                                                $hour = substr($date, 1, 2);
 
  684                                                $min = substr($date, 3, 2);
 
  687                                                $day_value = ($day-1)*60*60*24;
 
  688                                                $date = $day_value+$hour*60*60+$min*60;
 
  691                                                if($hour != $old_hour && $hour && $hour%6 == 0)
 
  693                                                        $labels[$date] = $hour;
 
  706                        foreach($a_measure as $measure)
 
  708                                $value = (int)$item[
"active_".$measure];                                                
 
  709                                $act_line[$measure]->addPoint($date, $value);   
 
  712                        if($a_scale != self::SCALE_PERIODIC_WEEK)
 
  714                                $max_line->addPoint($date, (
int)$item[
"max_sessions"]);
 
  718                foreach($act_line as $line)
 
  720                        $chart->addData($line);
 
  722                if($a_scale != self::SCALE_PERIODIC_WEEK)
 
  724                        $chart->addData($max_line);
 
  727                $chart->setTicks($labels, 
null, 
true);
 
  729                return $chart->getHTML();
 
  747                foreach($a_data as $item)
 
  749                        $date_parts = getdate($item[
"slot_begin"]);
 
  756                                        $slot = mktime($date_parts[
"hours"], 0, 0, $date_parts[
"mon"], $date_parts[
"mday"], $date_parts[
"year"]);                                       
 
  761                                        $slot = mktime(0, 0, 1, $date_parts[
"mon"], $date_parts[
"mday"], $date_parts[
"year"]);  
 
  766                                        $day = $date_parts[
"wday"];
 
  771                                        $slot = $day.date(
"His", $item[
"slot_begin"]);  
 
  776                        foreach($item as $id => $value)
 
  778                                switch(substr($id, -3))
 
  781                                                if(!$tmp[$slot][$id] || $value < $tmp[$slot][$id])
 
  783                                                        $tmp[$slot][$id] = $value;
 
  788                                                if(!$tmp[$slot][$id] || $value > $tmp[$slot][$id])
 
  790                                                        $tmp[$slot][$id] = $value;
 
  795                                                $tmp[$slot][$id][] = $value; 
 
  801                foreach($tmp as $slot => $attr)
 
  803                        $tmp[$slot][
"active_avg"] = (int)round(array_sum($attr[
"active_avg"])/
sizeof($attr[
"active_avg"]));                                                                                                     
 
  804                        $tmp[$slot][
"slot_begin"] = $slot;
 
  807                return array_values($tmp);
 
  828                include_once 
'./Services/Link/classes/class.ilLink.php';
 
  830                include_once 
"./Services/Utilities/classes/class.ilCSVWriter.php";
 
  832                $csv->setSeparator(
";");
 
  838                        $lng->txt(
"trac_name_of_installation") => $ilClientIniFile->readVariable(
'client', 
'name'),
 
  839                        $lng->txt(
"trac_report_date") =>
 
  841                        $lng->txt(
"trac_report_owner") => 
$ilUser->getFullName(),
 
  843                foreach($a_data as $idx => $item)
 
  848                                        $meta[
$lng->txt(
"title")] = $item;
 
  855                                case "closed_details":                                  
 
  856                                        foreach($item as $detail)
 
  858                                                $meta[$a_data[
"closed"][0].
" - ".$detail[0]] = $detail[1];
 
  863                                        $meta[$item[0]] = $item[1];
 
  867                foreach($meta as  $caption => $value)
 
  869                        $csv->addColumn(strip_tags($caption));
 
  870                        $csv->addColumn(strip_tags($value));
 
  881                $first = array_keys(array_shift($first));
 
  882                foreach ($first as $column)
 
  885                        if($a_scale == self::SCALE_PERIODIC_WEEK && $column == 
"slot_begin")
 
  887                                $csv->addColumn(
"weekday");
 
  888                                $csv->addColumn(
"time");
 
  892                                $csv->addColumn(strip_tags($column));
 
  898                foreach($aggr_data as 
$row)
 
  900                        foreach (
$row as $column => $value)
 
  904                                        $value = implode(
', ', $value);
 
  910                                                if($a_scale == self::SCALE_PERIODIC_WEEK)
 
  913                                                        $value = substr($value, 1, 2).
":".substr($value, 3, 2);
 
  919                                                $value = date(
"d.m.Y H:i", $value);
 
  922                                $csv->addColumn(strip_tags($value));
 
  928                $filename .= 
"session_statistics_".date(
"Ymd", $now).
".csv";
 
  929                header(
"Content-type: text/comma-separated-values");
 
  930                header(
"Content-Disposition: attachment; filename=\"".
$filename.
"\"");
 
  931                header(
"Expires: 0");
 
  932                header(
"Cache-Control: must-revalidate, post-check=0,pre-check=0");
 
  933                header(
"Pragma: public");               
 
  934                echo $csv->getCSVString();              
 
Helper class to generate CSV files.
static _numericDayToString($a_day, $a_long=true)
get
static getInstanceByType($a_type, $a_id)
Get type instance.
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
static setUseRelativeDates($a_status)
set use relative dates
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
static $session_types_controlled
const DEFAULT_MAX_IDLE_AFTER_FIRST_REQUEST
static getExistingSessionCount(array $a_types)
returns number of valid sessions relating to given session types
const DEFAULT_MAX_COUNT
default value for settings that have not been defined in setup or administration yet
Class ilSessionStatisticsGUI.
const SCALE_PERIODIC_WEEK
getChart($a_data, $a_title, $a_scale=self::SCALE_DAY, $a_measure=null)
Build chart for active sessions.
buildData($a_time_from, $a_time_to, $a_title)
render($a_data, $a_scale, $a_measure=null)
periodic($a_export=false)
exportCSV(array $a_data, $a_scale)
adaptDataToScale($a_scale, array $a_data)
static getActiveSessions($a_from, $a_to)
Get active sessions aggregated data.
static getLastAggregation()
Get timestamp of last aggregation.
static getMaxedOutDuration($a_from, $a_to)
Get maxed out duration in given timeframe.
static getLastMaxedOut()
Get latest slot during which sessions were maxed out.
static getNumberOfSessionsByType($a_from, $a_to)
Get session counters by type (opened, closed)
static aggretateRaw($a_now)
static _destroyExpiredSessions()
Destroy expired sessions.
special template class to simplify handling of ITX/PEAR
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']