diff --git a/doc.md b/doc.md index 1b08aec..5f85248 100644 --- a/doc.md +++ b/doc.md @@ -319,7 +319,7 @@ w.postMessage('start {"url_dl": "newGarbageURL", "url_ul": "newEmptyURL", "url_p Telemetry currently requires PHP and either MySQL, PostgreSQL or SQLite. To set up the telemetry, we need to do 4 things: * copy `telemetry.php` and `telemetry_settings.php` -* edit `telemetry_settings.php` to add your database settings +* edit `telemetry_settings.php` to add your database settings or the csv filename and date timezone if CSV is used instead of database storage. * create the database * enable telemetry @@ -352,6 +352,12 @@ $PostgreSql_hostname="DB_HOSTNAME"; //database address, usually localhost $PostgreSql_databasename="DB_NAME"; //the name of the database where you loaded telemetry_postgresql.sql ``` +If you choose to use CSV file, you must set the Csv_File and timezone variables. +```php +$Csv_File="myReportFile.csv"; +$timezone='Europe/Paris'; +``` + ### Enabling telemetry Edit your test page; where you start the worker, you need to specify the `telemetry_level`. There are 3 levels: diff --git a/telemetry.php b/telemetry.php index 5a5ab32..ce456ec 100644 --- a/telemetry.php +++ b/telemetry.php @@ -52,18 +52,18 @@ if($db_type=="mysql"){ elseif($db_type=="csv"){ // Prepare the csv formatted string date_default_timezone_set($timezone); - $date = date('Y-m-d H:M:S'); - $str = '"' . $ip . '",'; + $date = date('Y-m-d H:i:s'); + $str = '"' . $date . '",'; + $str .= '"' . $ip . '",'; $str .= '"' . $ua . '",'; $str .= '"' . $dl . '",'; $str .= '"' . $ul . '",'; $str .= '"' . $ping . '",'; - $str .= '"' . $jitter . '",'; - $str .= '"' . $$log . '"' . "\n"; + $str .= '"' . $jitter . '"' . "\n"; // Set header if this is a new file if (!file_exists($Csv_File)) { - $header = '"ip","ua","download","upload","ping","jitter","log"' . "\n"; + $header = '"date","ip","ua","download","upload","ping","jitter"' . "\n"; file_put_contents($Csv_File, $header, FILE_APPEND); }