Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Sun Nov 19, 2017 9:20 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: wrong date on csv export data file
PostPosted: Mon Feb 29, 2016 10:01 am 
Offline

Joined: Sun Feb 28, 2016 9:21 pm
Posts: 1
Hi all,

I'm just discovering cacti after a fresh install of Version 0.8.8g on a fedora23 server.
[[email protected] 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
[[email protected] 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:
[[email protected] 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"
[[email protected] 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:
[[email protected] 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
[[email protected] 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:
[[email protected] 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
[[email protected] 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é


Top
 Profile  
 
 Post subject: Re: wrong date on csv export data file
PostPosted: Wed Dec 07, 2016 3:53 am 
Offline

Joined: Fri Jan 13, 2012 6:44 am
Posts: 15
Hi,
Is this problem solved in ver. 0.8.8h?
Jan


Top
 Profile  
 
 Post subject: Re: wrong date on csv export data file
PostPosted: Tue Feb 14, 2017 3:10 am 
Offline

Joined: Tue Feb 14, 2017 3:05 am
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: wrong date on csv export data file
PostPosted: Mon Feb 20, 2017 4:20 am 
Offline

Joined: Tue Feb 14, 2017 3:05 am
Posts: 2
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
Code:
"--maxrows=10000" . RRD_NL;

with
Code:
"--maxrows=10000" . RRD_NL.
"-t" . RRD_NL;


and it works again


Top
 Profile  
 
 Post subject: Re: wrong date on csv export data file
PostPosted: Fri Jul 21, 2017 2:12 pm 
Offline
Cacti User

Joined: Fri Sep 14, 2007 12:43 pm
Posts: 66
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!


Top
 Profile  
 
 Post subject: Re: wrong date on csv export data file
PostPosted: Mon Jul 24, 2017 7:12 am 
Offline
Cacti User

Joined: Fri Sep 14, 2007 12:43 pm
Posts: 66
I was able to resolve this by changing code in graph_xport.php at line 155 to the following:

Code:
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";
        }

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-users/2017-February/020525.html


Top
 Profile  
 
 Post subject: Re: wrong date on csv export data file
PostPosted: Tue Nov 14, 2017 3:00 am 
Offline

Joined: Wed Aug 09, 2017 2:36 am
Posts: 4
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


Top
 Profile  
 
 Post subject: Re: wrong date on csv export data file
PostPosted: Tue Nov 14, 2017 11:37 am 
Offline
Cacti User

Joined: Fri Sep 14, 2007 12:43 pm
Posts: 66
Good to hear it worked!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group