|
static | isActive () |
| Is session statistics active at all? More...
|
|
static | createRawEntry ($a_session_id, $a_session_type, $a_timestamp, $a_user_id) |
| Create raw data entry. More...
|
|
static | closeRawEntry ($a_session_id, $a_context=null, $a_expired_at=null) |
| Close raw data entry. More...
|
|
static | aggretateRaw ($a_now) |
| Aggregate raw session data (older than given time) More...
|
|
static | aggregateRawHelper ($a_begin, $a_end) |
| Aggregate statistics data for one slot. More...
|
|
static | getLastMaxedOut () |
| Get latest slot during which sessions were maxed out. More...
|
|
static | getMaxedOutDuration ($a_from, $a_to) |
| Get maxed out duration in given timeframe. More...
|
|
static | getNumberOfSessionsByType ($a_from, $a_to) |
| Get session counters by type (opened, closed) More...
|
|
static | getActiveSessions ($a_from, $a_to) |
| Get active sessions aggregated data. More...
|
|
static | getLastAggregation () |
| Get timestamp of last aggregation. More...
|
|
static | getLimitForSlot ($a_timestamp) |
| Get max session setting for given timestamp. More...
|
|
static | updateLimitLog ($a_new_value) |
| Log max session setting. More...
|
|
◆ aggregateRawHelper()
static ilSessionStatistics::aggregateRawHelper |
( |
|
$a_begin, |
|
|
|
$a_end |
|
) |
| |
|
static |
Aggregate statistics data for one slot.
- Parameters
-
timestamp | $a_begin | |
timestamp | $a_end | |
Definition at line 290 of file class.ilSessionStatistics.php.
References $ilDB, $ilSetting, array, ilSession\SESSION_CLOSE_EXPIRE, ilSession\SESSION_CLOSE_FIRST, ilSession\SESSION_CLOSE_IDLE, ilSession\SESSION_CLOSE_LIMIT, ilSession\SESSION_CLOSE_LOGIN, and ilSession\SESSION_CLOSE_USER.
303 $closed_counter = $events =
array();
305 foreach(self::getRawData($a_begin, $a_end) as $item)
315 if($item[
"start_time"] >= $a_begin)
318 $events[$item[
"start_time"]][] = 1;
321 if($item[
"end_time"] && $item[
"end_time"] <= $a_end)
323 if(in_array($item[
"end_context"], $separate_closed))
325 $closed_counter[$item[
"end_context"]]++;
329 $closed_counter[0]++;
331 $events[$item[
"end_time"]][] = -1;
336 $active_begin = self::getNumberOfActiveRawSessions($a_begin-1);
337 $active_end = $active_min = $active_max = $active_avg = $active_begin;
342 $last_update_avg = $a_begin-1;
343 $slot_seconds = self::SLOT_SIZE*60;
348 foreach($events as $ts => $actions)
351 foreach($actions as $action)
366 if($active_end > $active_max)
368 $active_max = $active_end;
372 if($active_end < $active_min)
374 $active_min = $active_end;
378 $diff = $ts-$last_update_avg;
379 $active_avg += $diff/$slot_seconds*$active_end;
380 $last_update_avg = $ts;
385 if($last_update_avg < $a_end)
387 $diff = $a_end-$last_update_avg;
388 $active_avg += $diff/$slot_seconds*$active_end;
391 $active_avg = round($active_avg);
398 $max_sessions = self::getLimitForSlot($a_begin);
402 "active_min" =>
array(
"integer", $active_min),
403 "active_max" =>
array(
"integer", $active_max),
404 "active_avg" =>
array(
"integer", $active_avg),
405 "active_end" =>
array(
"integer", $active_end),
406 "opened" =>
array(
"integer", $opened_counter),
413 "closed_misc" =>
array(
"integer", (
int)$closed_counter[0]),
414 "max_sessions" =>
array(
"integer", (
int)$max_sessions)
416 $ilDB->update(
"usr_session_stats", $fields,
417 array(
"slot_begin" =>
array(
"integer", $a_begin),
418 "slot_end" =>
array(
"integer", $a_end)));
const SESSION_CLOSE_LOGIN
const SESSION_CLOSE_EXPIRE
const SESSION_CLOSE_LIMIT
Create styles array
The data for the language used.
const SESSION_CLOSE_FIRST
◆ aggretateRaw()
static ilSessionStatistics::aggretateRaw |
( |
|
$a_now | ) |
|
|
static |
Aggregate raw session data (older than given time)
- Parameters
-
Definition at line 266 of file class.ilSessionStatistics.php.
Referenced by ilSession\_writeData(), and ilSessionStatisticsGUI\adminSync().
268 if(!self::isActive())
273 $slot = self::createNewAggregationSlot($a_now);
274 while(is_array($slot))
276 self::aggregateRawHelper($slot[0], $slot[1]);
277 $slot = self::createNewAggregationSlot($a_now);
281 self::deleteAggregatedRaw($a_now);
◆ closeRawEntry()
static ilSessionStatistics::closeRawEntry |
( |
|
$a_session_id, |
|
|
|
$a_context = null , |
|
|
|
$a_expired_at = null |
|
) |
| |
|
static |
Close raw data entry.
- Parameters
-
int | array | $a_session_id | |
int | $a_context | |
int | bool | $a_expired_at | |
Definition at line 72 of file class.ilSessionStatistics.php.
References $ilDB, and time.
Referenced by ilSession\_destroy().
82 if(!is_array($a_session_id))
86 $end_time = $a_expired_at;
92 $sql =
"UPDATE usr_session_stats_raw".
93 " SET end_time = ".$ilDB->quote($end_time,
"integer");
96 $sql .=
",end_context = ".$ilDB->quote($a_context,
"integer");
98 $sql .=
" WHERE session_id = ".$ilDB->quote($a_session_id,
"text").
99 " AND end_time IS NULL";
100 $ilDB->manipulate($sql);
103 else if(!$a_expired_at)
105 $sql =
"UPDATE usr_session_stats_raw".
106 " SET end_time = ".$ilDB->quote(
time(),
"integer");
109 $sql .=
",end_context = ".$ilDB->quote($a_context,
"integer");
111 $sql .=
" WHERE ".$ilDB->in(
"session_id", $a_session_id,
false,
"text").
112 " AND end_time IS NULL";
113 $ilDB->manipulate($sql);
118 foreach($a_session_id as $id => $ts)
120 $sql =
"UPDATE usr_session_stats_raw".
121 " SET end_time = ".$ilDB->quote($ts,
"integer");
124 $sql .=
",end_context = ".$ilDB->quote($a_context,
"integer");
126 $sql .=
" WHERE session_id = ".$ilDB->quote($id,
"text").
127 " AND end_time IS NULL";
128 $ilDB->manipulate($sql);
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ createNewAggregationSlot()
static ilSessionStatistics::createNewAggregationSlot |
( |
|
$a_now | ) |
|
|
staticprotected |
Create new slot (using table lock)
- Parameters
-
- Returns
- array begin, end
Definition at line 230 of file class.ilSessionStatistics.php.
References $ilDB, array, and ilDBInterface\insert().
234 $ilAtomQuery = $ilDB->buildAtomQuery();
235 $ilAtomQuery->addTableLock(
"usr_session_stats");
237 $ilAtomQuery->addQueryCallable(
function(
ilDBInterface $ilDB) use ($a_now, &$slot){
240 $slot = self::getCurrentSlot($a_now);
249 "slot_begin" =>
array(
"integer", $slot[0]),
250 "slot_end" =>
array(
"integer", $slot[1]),
252 $ilDB->
insert(
"usr_session_stats", $fields);
Create styles array
The data for the language used.
insert($table_name, $values)
◆ createRawEntry()
static ilSessionStatistics::createRawEntry |
( |
|
$a_session_id, |
|
|
|
$a_session_type, |
|
|
|
$a_timestamp, |
|
|
|
$a_user_id |
|
) |
| |
|
static |
◆ deleteAggregatedRaw()
static ilSessionStatistics::deleteAggregatedRaw |
( |
|
$a_now | ) |
|
|
staticprotected |
Remove already aggregated raw data.
- Parameters
-
Definition at line 426 of file class.ilSessionStatistics.php.
References $ilDB.
431 $cut = $a_now-(60*60*24*7);
433 $ilDB->manipulate(
"DELETE FROM usr_session_stats_raw".
434 " WHERE start_time <= ".$ilDB->quote($cut,
"integer"));
◆ getActiveSessions()
static ilSessionStatistics::getActiveSessions |
( |
|
$a_from, |
|
|
|
$a_to |
|
) |
| |
|
static |
Get active sessions aggregated data.
- Parameters
-
- Returns
- array
Definition at line 510 of file class.ilSessionStatistics.php.
References $ilDB, $res, $row, and array.
Referenced by ilSessionStatisticsGUI\buildData().
514 $sql =
"SELECT slot_begin, slot_end, active_min, active_max, active_avg,".
516 " FROM usr_session_stats".
517 " WHERE slot_end > ".$ilDB->quote($a_from,
"integer").
518 " AND slot_begin < ".$ilDB->quote($a_to,
"integer").
519 " ORDER BY slot_begin";
520 $res = $ilDB->query($sql);
522 while(
$row = $ilDB->fetchAssoc(
$res))
Create styles array
The data for the language used.
◆ getCurrentSlot()
static ilSessionStatistics::getCurrentSlot |
( |
|
$a_now | ) |
|
|
staticprotected |
Get next slot to aggregate.
- Parameters
-
- Returns
- array begin, end
Definition at line 139 of file class.ilSessionStatistics.php.
References $ilDB, $res, $row, array, and date.
144 $sql =
"SELECT MAX(slot_end) previous_slot_end".
145 " FROM usr_session_stats";
146 $res = $ilDB->query($sql);
148 $previous_slot_end =
$row[
"previous_slot_end"];
152 if(!$previous_slot_end)
154 $slot = floor(
date(
"i")/self::SLOT_SIZE);
158 $current_slot_begin = mktime(
date(
"H", $a_now)-1, 60-self::SLOT_SIZE, 0);
163 $current_slot_begin = mktime(
date(
"H", $a_now), ($slot-1)*self::SLOT_SIZE, 0);
168 $current_slot_begin = $previous_slot_end+1;
171 $current_slot_end = $current_slot_begin+(60*self::SLOT_SIZE)-1;
174 if($current_slot_end < $a_now)
176 return array($current_slot_begin, $current_slot_end);
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
◆ getLastAggregation()
static ilSessionStatistics::getLastAggregation |
( |
| ) |
|
|
static |
◆ getLastMaxedOut()
static ilSessionStatistics::getLastMaxedOut |
( |
| ) |
|
|
static |
◆ getLimitForSlot()
static ilSessionStatistics::getLimitForSlot |
( |
|
$a_timestamp | ) |
|
|
static |
Get max session setting for given timestamp.
- Parameters
-
- Returns
- int
Definition at line 553 of file class.ilSessionStatistics.php.
References $ilDB, $ilSetting, $res, and ilSessionControl\DEFAULT_MAX_COUNT.
558 $sql =
"SELECT maxval FROM usr_session_log".
559 " WHERE tstamp <= ".$ilDB->quote($a_timestamp,
"integer").
560 " ORDER BY tstamp DESC";
561 $res = $ilDB->query($sql);
562 $val = $ilDB->fetchAssoc(
$res);
565 return (
int)$val[
"maxval"];
const DEFAULT_MAX_COUNT
default value for settings that have not been defined in setup or administration yet ...
◆ getMaxedOutDuration()
static ilSessionStatistics::getMaxedOutDuration |
( |
|
$a_from, |
|
|
|
$a_to |
|
) |
| |
|
static |
Get maxed out duration in given timeframe.
- Parameters
-
- Returns
- int seconds
Definition at line 464 of file class.ilSessionStatistics.php.
References $ilDB, $res, and $row.
Referenced by ilSessionStatisticsGUI\buildData().
468 $sql =
"SELECT SUM(slot_end-slot_begin) dur FROM usr_session_stats".
469 " WHERE active_max >= max_sessions".
470 " AND max_sessions > ".$ilDB->quote(0,
"integer").
471 " AND slot_end > ".$ilDB->quote($a_from,
"integer").
472 " AND slot_begin < ".$ilDB->quote($a_to,
"integer");
473 $res = $ilDB->query($sql);
◆ getNumberOfActiveRawSessions()
static ilSessionStatistics::getNumberOfActiveRawSessions |
( |
|
$a_time | ) |
|
|
staticprotected |
Count number of active sessions at given time.
- Parameters
-
- Returns
- integer
Definition at line 186 of file class.ilSessionStatistics.php.
References $ilDB, $res, $row, and ilSessionControl\$session_types_controlled.
190 $sql =
"SELECT COUNT(*) counter FROM usr_session_stats_raw".
191 " WHERE (end_time IS NULL OR end_time >= ".$ilDB->quote($a_time,
"integer").
")".
192 " AND start_time <= ".$ilDB->quote($a_time,
"integer").
194 $res = $ilDB->query($sql);
196 return $row[
"counter"];
static $session_types_controlled
◆ getNumberOfSessionsByType()
static ilSessionStatistics::getNumberOfSessionsByType |
( |
|
$a_from, |
|
|
|
$a_to |
|
) |
| |
|
static |
Get session counters by type (opened, closed)
- Parameters
-
- Returns
- array
Definition at line 488 of file class.ilSessionStatistics.php.
References $ilDB, and $res.
Referenced by ilSessionStatisticsGUI\buildData().
492 $sql =
"SELECT SUM(opened) opened, SUM(closed_manual) closed_manual,".
493 " SUM(closed_expire) closed_expire, SUM(closed_idle) closed_idle,".
494 " SUM(closed_idle_first) closed_idle_first, SUM(closed_limit) closed_limit,".
495 " SUM(closed_login) closed_login, SUM(closed_misc) closed_misc".
496 " FROM usr_session_stats".
497 " WHERE slot_end > ".$ilDB->quote($a_from,
"integer").
498 " AND slot_begin < ".$ilDB->quote($a_to,
"integer");
499 $res = $ilDB->query($sql);
500 return $ilDB->fetchAssoc(
$res);
◆ getRawData()
static ilSessionStatistics::getRawData |
( |
|
$a_begin, |
|
|
|
$a_end |
|
) |
| |
|
staticprotected |
Read raw data for timespan.
- Parameters
-
integer | $a_begin | |
integer | $a_end | |
- Returns
- array
Definition at line 206 of file class.ilSessionStatistics.php.
References $ilDB, $res, $row, ilSessionControl\$session_types_controlled, and array.
210 $sql =
"SELECT start_time,end_time,end_context FROM usr_session_stats_raw".
211 " WHERE start_time <= ".$ilDB->quote($a_end,
"integer").
212 " AND (end_time IS NULL OR end_time >= ".$ilDB->quote($a_begin,
"integer").
")".
214 " ORDER BY start_time";
215 $res = $ilDB->query($sql);
217 while(
$row = $ilDB->fetchAssoc(
$res))
static $session_types_controlled
Create styles array
The data for the language used.
◆ isActive()
static ilSessionStatistics::isActive |
( |
| ) |
|
|
static |
◆ updateLimitLog()
static ilSessionStatistics::updateLimitLog |
( |
|
$a_new_value | ) |
|
|
static |
◆ SLOT_SIZE
const ilSessionStatistics::SLOT_SIZE = 15 |
The documentation for this class was generated from the following file: