Page 1 of 1

Realtime.log for Highcharts

Posted: Sat 02 Mar 2013 8:20 am
by Stuart2007
Thanks to Mark and others for the realtime charts using Highcharts.

I am uploading on a data-limited 3g link. The 248 byte realtime.txt is no problem every minute, while a 30kb 120 minute log file is, so I'm uploading that every 15 mins at present. But user has a variable length datagap (upto 15 mins depending on the time they load the webpage).

http://www.oldlandwindmill.co.uk/newsit ... umulus.htm

Why not build the log file at the server to avoid resending the data 120 times?

I am trawling around trying to get my head around php etc, but in principle is there any reason one could not run a php script after each upload of txt, reading the last (say) 119 records in it, writing then to a tmp file, adding on the new record at the end of the log file, then closing/deleting the log file and renaming the temp file to .log??

I'm guessing there must be a reason this can't be done, because I'm sure it would be mentioned somewhere in the Forum history, and I can't find it. Or perhaps the answer is so obvious I've overlooked it. Probably the latter.

Stuart

Re: Realtime.log for Highcharts

Posted: Sat 02 Mar 2013 10:46 am
by steve
I think one of Kevin's scripts does something like that?

https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=130

Re: Realtime.log for Highcharts

Posted: Sat 02 Mar 2013 10:59 am
by beteljuice
Edit: Steve posted whilst I was typing - yes that article is a good guide to the basics of what you want ..
... but in principle is there any reason one could not run a php script after each upload of txt
In principle - OK

... but you would have to run a 'cron' job on the server every 15 min (or less) because you have no way of the (new) upload to trigger the log update script. ie. the script runs regardless and checks either the file timestamp or the data entry timestamps in both the realtime.txt and the log file.

A poor work-around would be to call the script from a browser with an auto-refresh (as a cosmetic - the script would o/p to browser success / fail and timestamp). This is a technique I use when grabbing other peoples data for beteljuice prototypes etc.

Re: Realtime.log for Highcharts

Posted: Sat 02 Mar 2013 2:21 pm
by water01
Or you could use Cumulus Toolbox to run a Remote Command to run the php. I do this to update my historic graphs MySQL databse at 00:15 every night and it works well.

Re: Realtime.log for Highcharts

Posted: Sat 02 Mar 2013 4:50 pm
by Stuart2007
Thanks all, that will get me going.

Stuart

Re: Realtime.log for Highcharts

Posted: Sun 03 Mar 2013 12:42 pm
by mcrossley
Stuart

I have the advantage of running Cumulus on my web server, but I stuff the realtime.txt into a SQL database on the web server by running a PHP script from the command line every minute (my realtime update interval is also 1 minute). The realtime SQL table is indexed on the date/time field so duplicate entries are not recorded.

The script can be run as a command line via cron, or run remotely via a http call.