This repository has been archived by the owner on Dec 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
updateperfstats.php
46 lines (41 loc) · 1.56 KB
/
updateperfstats.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Script originally copied over from updateviewcount.php
*/
set_time_limit( 0 );
if ( !$isQuiet )
$cli->output( "Updating perf counters..." );
$contentArray = array();
$logFilePath = '';
$plIni = eZINI::instance( 'ezperformancelogger.ini' );
$logTo = $plIni->variable( 'GeneralSettings', 'LogMethods' );
if ( in_array( 'apache', $logTo ) && !in_array( 'logfile', $logTo ) )
{
$logFileIni = eZINI::instance( 'logfile.ini' );
$logFilePath = $logFileIni->variable( 'AccessLogFileSettings', 'StorageDir' ) . '/' . $logFileIni->variable( 'AccessLogFileSettings', 'LogFileName' );
}
else if ( !in_array( 'apache', $logTo ) && in_array( 'logfile', $logTo ) )
{
$logFilePath = $plIni->variable( 'logfileSettings', 'FileName' );
}
else
{
$cli->output( "Warning: Cannot decide which log-file to open for reading, please enable either apache-based logging or file-based logging." );
}
if ( $logFilePath != '' )
{
$storageClass = $plIni->variable( 'ParsingSettings', 'StorageClass' );
$excludeRegexps = $plIni->variable( 'ParsingSettings', 'ExcludeUrls' );
$ok = eZPerfLoggerLogManager::updateStatsFromLogFile( $logFilePath, 'eZPerfLoggerApacheLogger', $storageClass, 'updateperfstats.log', $excludeRegexps );
if ( $ok === false )
{
$cli->output( "Error parsing file $logFilePath. Please run cronjob in debug mode for more info" );
}
else
{
if ( !$isQuiet )
$cli->output( "{$ok['counted']} lines parsed in file $logFilePath" );
}
}
if ( !$isQuiet )
$cli->output( "Perf counters have been updated" );