wrong date on csv export data file
Moderators: Developers, Moderators
wrong date on csv export data file
Hi all,
I'm just discovering cacti after a fresh install of Version 0.8.8g on a fedora23 server.
[root@traprecv log]# uname -a
Linux traprecv.example.com 4.3.5-300.fc23.x86_64 #1 SMP Mon Feb 1 03:18:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@traprecv log]#
Just in case, the cacti install was on a virtual machine Qemu (qemu-system-x86-2.4.1-7.fc23.x86_64) , but I'm not sure it's so relevant.
I just enjoy all the funcionalities of cacti, but I got some trouble with the export csv button of the graph.
The generated csv file is almost perfect, except the date of the datas, which is always the default php date:
[herve@guatape Downloads]$ head -13 "'physical Host - Traffic - wlp3s0'.csv"
"Title:","'physical Host - Traffic - wlp3s0'"
"Vertical Label:","'bits per second'"
"Start Date:","2016-02-28 08:55:00"
"End Date:","2016-02-29 08:55:00"
"Step:","300"
"Total Rows:","288"
"Graph ID:","13"
"Host ID:","2"
""
"Date","Inbound","Outbound"
"1969-12-31 19:00:00","3.8013287756e+04","7.5824262562e+03"
"1969-12-31 19:00:00","1.8801671916e+05","1.5989914057e+04"
"1969-12-31 19:00:00","3.0164052876e+03","8.1488967611e+02"
[herve@guatape Downloads]$
All is perfect , start and end date, number of row, the datas are there, but the date of each data couldn't be hanlded by Cacti...
Having a look on the rrd data file, the date is correct, and i can dump everithing I want:
[root@traprecv rra]# rrdtool fetch physical_host_traffic_in_23.rrd AVERAGE | head -7
traffic_in traffic_out
1456668300: 2.3502089895e+04 1.9987392572e+03
1456668600: 3.7705066094e+02 1.0186120951e+02
1456668900: 3.1312247722e+04 1.8431117889e+03
1456669200: 1.1111214504e+03 2.0665874814e+02
1456669500: 3.8302737607e+03 6.0788368520e+02
[root@traprecv rra]#
Obviously, I wouldn't be able to get the beautiful cacti's graphs if this file wasn't correct
Having a closer look inside the dataflow, I saw the export was generated by this file:
[root@traprecv rra]# ll /var/www/html/cacti/graph_xport.php
-rw-rw-r--. 1 herve herve 6480 Feb 29 08:53 /var/www/html/cacti/graph_xport.php
[root@traprecv rra]#
and the data lines by this portion of the code
140 if (is_array($xport_array["data"])) {
141 foreach($xport_array["data"] as $row) {
142 $data = '"' . date("Y-m-d H:i:s", $row["timestamp"]) . '"';
143 for($i=1;$i<=$xport_array["meta"]["columns"];$i++) {
144 $data .= ',"' . $row["col" . $i] . '"';
145 }
146 print $data . "\n";
147 }
Since the problem only occurs with the data's date , the real issue is at the line 142, while we try to format the date.
I just try to display directly $row["timestamp"], but it appeared to be an empty variable, and it seems it's the reason why the conversion failed and why I got this default date in each line of the csv file.
I tried to get a closer look inside the "rrdtool_function_xport", to see where is the problem between the rrdtool datafile and the csv exported file,
but I must admit I'm not strong enough in PHP to sort out the issue.
I 'm not even sure there is a problem in the code: It looks like I'm the first to notice that, and may be it's just a mistake with my settings, but i can't find exactly where did something wrong.
I'm afraid it 's just me who couldn't see the right information in the documentation..;
Anybody can show me a way just to get more informations to resolve the issue ?
regards
Hervé
I'm just discovering cacti after a fresh install of Version 0.8.8g on a fedora23 server.
[root@traprecv log]# uname -a
Linux traprecv.example.com 4.3.5-300.fc23.x86_64 #1 SMP Mon Feb 1 03:18:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@traprecv log]#
Just in case, the cacti install was on a virtual machine Qemu (qemu-system-x86-2.4.1-7.fc23.x86_64) , but I'm not sure it's so relevant.
I just enjoy all the funcionalities of cacti, but I got some trouble with the export csv button of the graph.
The generated csv file is almost perfect, except the date of the datas, which is always the default php date:
[herve@guatape Downloads]$ head -13 "'physical Host - Traffic - wlp3s0'.csv"
"Title:","'physical Host - Traffic - wlp3s0'"
"Vertical Label:","'bits per second'"
"Start Date:","2016-02-28 08:55:00"
"End Date:","2016-02-29 08:55:00"
"Step:","300"
"Total Rows:","288"
"Graph ID:","13"
"Host ID:","2"
""
"Date","Inbound","Outbound"
"1969-12-31 19:00:00","3.8013287756e+04","7.5824262562e+03"
"1969-12-31 19:00:00","1.8801671916e+05","1.5989914057e+04"
"1969-12-31 19:00:00","3.0164052876e+03","8.1488967611e+02"
[herve@guatape Downloads]$
All is perfect , start and end date, number of row, the datas are there, but the date of each data couldn't be hanlded by Cacti...
Having a look on the rrd data file, the date is correct, and i can dump everithing I want:
[root@traprecv rra]# rrdtool fetch physical_host_traffic_in_23.rrd AVERAGE | head -7
traffic_in traffic_out
1456668300: 2.3502089895e+04 1.9987392572e+03
1456668600: 3.7705066094e+02 1.0186120951e+02
1456668900: 3.1312247722e+04 1.8431117889e+03
1456669200: 1.1111214504e+03 2.0665874814e+02
1456669500: 3.8302737607e+03 6.0788368520e+02
[root@traprecv rra]#
Obviously, I wouldn't be able to get the beautiful cacti's graphs if this file wasn't correct
Having a closer look inside the dataflow, I saw the export was generated by this file:
[root@traprecv rra]# ll /var/www/html/cacti/graph_xport.php
-rw-rw-r--. 1 herve herve 6480 Feb 29 08:53 /var/www/html/cacti/graph_xport.php
[root@traprecv rra]#
and the data lines by this portion of the code
140 if (is_array($xport_array["data"])) {
141 foreach($xport_array["data"] as $row) {
142 $data = '"' . date("Y-m-d H:i:s", $row["timestamp"]) . '"';
143 for($i=1;$i<=$xport_array["meta"]["columns"];$i++) {
144 $data .= ',"' . $row["col" . $i] . '"';
145 }
146 print $data . "\n";
147 }
Since the problem only occurs with the data's date , the real issue is at the line 142, while we try to format the date.
I just try to display directly $row["timestamp"], but it appeared to be an empty variable, and it seems it's the reason why the conversion failed and why I got this default date in each line of the csv file.
I tried to get a closer look inside the "rrdtool_function_xport", to see where is the problem between the rrdtool datafile and the csv exported file,
but I must admit I'm not strong enough in PHP to sort out the issue.
I 'm not even sure there is a problem in the code: It looks like I'm the first to notice that, and may be it's just a mistake with my settings, but i can't find exactly where did something wrong.
I'm afraid it 's just me who couldn't see the right information in the documentation..;
Anybody can show me a way just to get more informations to resolve the issue ?
regards
Hervé
Re: wrong date on csv export data file
Hi,
Is this problem solved in ver. 0.8.8h?
Jan
Is this problem solved in ver. 0.8.8h?
Jan
Re: wrong date on csv export data file
0.8.8h here and same problem
On gentoo with rrdtool-1.6.0-r1
With same error in generated csv before the date which is always "1970-01-01 01:00:00"
Undefined index: timestamp in cacti/graph_xport.php on line 142
On gentoo with rrdtool-1.6.0-r1
With same error in generated csv before the date which is always "1970-01-01 01:00:00"
Undefined index: timestamp in cacti/graph_xport.php on line 142
Re: wrong date on csv export data file
I'm not sure since when but timestamp are not enabled by default in xml result, data from rrdtool xport contains only values
There is an option '-t' in rrdtool to display timestamps, perhaps default behavior before rrdtool 1.6
I modify lib/rrd.php on line 1615
with
and it works again
There is an option '-t' in rrdtool to display timestamps, perhaps default behavior before rrdtool 1.6
I modify lib/rrd.php on line 1615
Code: Select all
"--maxrows=10000" . RRD_NL;
Code: Select all
"--maxrows=10000" . RRD_NL.
"-t" . RRD_NL;
Re: wrong date on csv export data file
Adding the -t option is not working for me. I don't see that as an option on rrdtool xport. Don't get any data, just header info when I add it, so I assume export is failing.
Has anyone found a solution to this. This worked great on 0.8.8b Ubuntu version. We upgraded to 0.8.8f (supported by Ubuntu) and found it broke.
Any suggestions greatly appreciated!
Has anyone found a solution to this. This worked great on 0.8.8b Ubuntu version. We upgraded to 0.8.8f (supported by Ubuntu) and found it broke.
Any suggestions greatly appreciated!
Re: wrong date on csv export data file
I was able to resolve this by changing code in graph_xport.php at line 155 to the following:
Problem cause was rrdtool 1.5.5-4 used in Ubuntu 16.04 no longer generates timestamps on 'rrdtool xport'. Code above derives the timestamps using start time and step value. In later versions of rrdtool a --showtime option is added.
A couple of links that might be useful:
https://github.com/oetiker/rrdtool-1.x/issues/672
https://lists.oetiker.ch/pipermail/rrd- ... 20525.html
Code: Select all
if (is_array($xport_array["data"])) {
$derived_time = $xport_array["meta"]["start"];
foreach($xport_array["data"] as $row) {
# $data = '"' . date("Y-m-d H:i:s", $row["timestamp"]) . '"';
$derived_time = $derived_time + $xport_array["meta"]["step"];
$data = '"' . date("Y-m-d H:i:s", $derived_time) . '"';
for($i=1;$i<=$xport_array["meta"]["columns"];$i++) {
$data .= ',"' . $row["col" . $i] . '"';
}
print $data . "\n";
}
A couple of links that might be useful:
https://github.com/oetiker/rrdtool-1.x/issues/672
https://lists.oetiker.ch/pipermail/rrd- ... 20525.html
-
- Posts: 4
- Joined: Wed Aug 09, 2017 2:36 am
Re: wrong date on csv export data file
Oh man!!!! Thank you very much. You are my savior. Its work for me on cacti 0.8.8.h and rrd tool 1.6.0
Re: wrong date on csv export data file
Good to hear it worked!
Who is online
Users browsing this forum: No registered users and 1 guest