Permalink
Browse files

Merge pull request #136 from frgithubaccount/timestamp_added_to_csv_e…

…xport

address behaviour of rrdtool1.5+ to not export timestamp by default
  • Loading branch information...
lingej committed Jul 25, 2017
2 parents 9b236ab + a6d949d commit 1480aa02a0873ffb8611c1f53d29ff124bc6de42
Showing with 11 additions and 1 deletion.
  1. +11 −1 share/pnp/application/models/data.php
@@ -1019,13 +1019,23 @@ public function xml2csv($string){
foreach($xml->meta->legend->entry as $key=>$value){
$csv .= ";" . $value ;
}
/*
* from rrdtool 1.5 on, timestamp ( value->t ) is not set anymore
* from 1.6 on it can be reactivated by -- showrime option to rrdtool xport
* here we take care of the timestamp ourselves regardless which
* rrdtool version is used
*/
$timestamp2 = $xml->meta->start;
$step = $xml->meta->step;
$csv .= "\n";
foreach($xml->data->row as $key=>$value){
$csv .= (string) $value->t ;
$csv .= $timestamp2;
foreach($value->v as $item){
$csv .= ";".floatval((string) $item);
}
$csv .= "\n";
$timestamp2 = $timestamp2 + $step;
}
return $csv;
}

0 comments on commit 1480aa0

Please sign in to comment.