CSV support for telemetry
This commit is contained in:
parent
b197e2fc78
commit
d9f999168d
8
doc.md
8
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.
|
Telemetry currently requires PHP and either MySQL, PostgreSQL or SQLite.
|
||||||
To set up the telemetry, we need to do 4 things:
|
To set up the telemetry, we need to do 4 things:
|
||||||
* copy `telemetry.php` and `telemetry_settings.php`
|
* 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
|
* create the database
|
||||||
* enable telemetry
|
* 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
|
$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
|
### Enabling telemetry
|
||||||
Edit your test page; where you start the worker, you need to specify the `telemetry_level`.
|
Edit your test page; where you start the worker, you need to specify the `telemetry_level`.
|
||||||
There are 3 levels:
|
There are 3 levels:
|
||||||
|
|
|
@ -52,18 +52,18 @@ if($db_type=="mysql"){
|
||||||
elseif($db_type=="csv"){
|
elseif($db_type=="csv"){
|
||||||
// Prepare the csv formatted string
|
// Prepare the csv formatted string
|
||||||
date_default_timezone_set($timezone);
|
date_default_timezone_set($timezone);
|
||||||
$date = date('Y-m-d H:M:S');
|
$date = date('Y-m-d H:i:s');
|
||||||
$str = '"' . $ip . '",';
|
$str = '"' . $date . '",';
|
||||||
|
$str .= '"' . $ip . '",';
|
||||||
$str .= '"' . $ua . '",';
|
$str .= '"' . $ua . '",';
|
||||||
$str .= '"' . $dl . '",';
|
$str .= '"' . $dl . '",';
|
||||||
$str .= '"' . $ul . '",';
|
$str .= '"' . $ul . '",';
|
||||||
$str .= '"' . $ping . '",';
|
$str .= '"' . $ping . '",';
|
||||||
$str .= '"' . $jitter . '",';
|
$str .= '"' . $jitter . '"' . "\n";
|
||||||
$str .= '"' . $$log . '"' . "\n";
|
|
||||||
|
|
||||||
// Set header if this is a new file
|
// Set header if this is a new file
|
||||||
if (!file_exists($Csv_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);
|
file_put_contents($Csv_File, $header, FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue