Skip to content

Commit

Permalink
修复流量统计与带宽统计算法
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklin committed May 15, 2019
1 parent 3b78dc9 commit 43fd288
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Tool/LogAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public static function analysisLogFile($logFile,$outFile='./analysis_log.csv'){
}
ksort(self::$ret);
foreach (self::$ret as $value) {
$bandwidth = round($value['rate']/1000/128/self::$preTime,2);//单位Mbps
$flow = round($value['rate']/1000/1000/1024,3);//单位GB
$bandwidth = round($value['rate']/1000/125/self::$preTime,2);//单位Mbps
$flow = round($value['rate']/1000/1000/1000,3);//单位GB
$txt = $value['date']."\t".$flow."GB\t".$bandwidth."Mbps".PHP_EOL;//时间点
try{
file_put_contents($outFile,$txt, FILE_APPEND | LOCK_EX);
Expand Down
4 changes: 2 additions & 2 deletions test/LogAnalysisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
class LogAnalysisTest extends TestCase
{
public function testAnalysisLogFile(){
$inputFile = '/usr/local/src/apk-auth.cdn.7723.cn_2019-04-29.log';
$outputFile = '/usr/local/src/apk-auth.cdn.7723.cn_2019-04-29.log.cvs';
$inputFile = '/usr/local/src/apk-auth.cdn.7723.cn_2019-05-11.log/apk-auth.cdn.7723.cn_2019-05-11.log';
$outputFile = '/usr/local/src/apk-auth.cdn.7723.cn_2019-05-11.log/apk-auth.cdn.7723.cn_2019-05-11.log.cvs';
LogAnalysis::setFlowLine(6);//设置日志行流量的列数;默认为4
LogAnalysis::setTimeLine(2);//设置日志行时间的列数;默认为1
LogAnalysis::setTimeFormat("d\/M\/Y:H:i:s");//设置日志行时间的格式
Expand Down

0 comments on commit 43fd288

Please sign in to comment.