|There's more than one way to do things|
Web moniitoring with Perl, comments and suggestions on general approach pleaseby predrag (Beadle)
|on Jan 23, 2017 at 22:27 UTC||Need Help??|
predrag has asked for the wisdom of the Perl Monks concerning the following question:
Dear Perl Monks,
This is an idea I bear over 10 years, to have a web moniitoring on my beekeeping website, to show bee hive weight, temperature and moisture in and out of hive etc. I am a big fan of data acquisition in general, but never realized something like that yet.
During all that time, I've been passing through different phases. First were about purchasing a professional web monitoring device, I even made a contact with producer. Hopefully I didn't have money for that. Later, the idea to buy some small separate devices and some software and put all that together. Then the idea of realizing hardware with microcontrollers (without previous experience with these), that will sent data to the MySQL base on the server, and read data using a PHP script and create a table in HTML page, etc.
Last year, I've came into Perl, but till recently wasn't aware of what all one can do with it. When joined perlmonks I began to meet surprises, one after another. Excuse me for such long introduction but I think can be useful and stimulating for beginners like me
My conditions on the server: My website will be moved on Cloud server, with probably 1CPU, 1GB RAM in the beginning and maybe 2GB later. I am offered Centos (x64), Debian, Fedora… but the aplication among offered that I prefer is Cloud LAMP server: CentOS 6.x, Apache, MySQL, PHP… How it is about Perl installation and version? I expect Perl 5.10.1 installed On CentOS
Is 1 or 2GB RAM enough for this my application? Till now maximum number of site visits was around 1000 visits in a day in the peak of beekeeping season, but with a completelly new desing, new content and web monitoring I think it can be easily increased 10 or more times
I plan to move home soon and need to move bees too, but still didn't find the place. Because of that I still don't know the conditions for monitoring device on that place
My data for monitoring:
Measuring with several sensors and sending data two times in a day will be enough. Later, next projects may be more ambitious, with more frequent and different data and also, from 2-3 or even more locations.
There is 3 solutions for the hadrware, as I can see:
1. It is with PIC microcontroller on a remote place. It will connect to the server two times a day and send data to MySQL base. A general question: I wonder if there is anything between Perl and PICs? Although this solution is more complex, I would not easily refuse it as PICs can be used in some other projects
2. The opposite: To create a small web server with PICs on the remote place, with MySQL base, so the website server should have to connect to it and read data two times a day.
3. If a power supply and internet connection would be present on the remote place there is a solution that I don't need PICs. Instead I could have a computer there, accept data to the serial port (?) and write Perl scripts that read data and present in a form of graphs and tables on HTML pages. In that case I would also need a Perl script that makes internet connection or maintains continuous connection in the case of some other projects with more frequent data.
Regarding MySQL base, I don't have any experience with it yet. I know about modules DBI and DBD:: mysql. Any recommendations for these or something other?
Thanks to perl monk Hauke D, I have one possible solution for further processing:
To use Chart::Clicker and to write a script that reads data (from MySQL or?), plots a graph and saves on the server as an image file. Then, to make a cron job calling that Perl script that generates the charts twice a day and saves them as image files. All these images should be saved under the same file name and image file will be inserted in html page. When data change, new image will be saved and automatically will become visible in html page after page refreshing or a new visiting
In order to have data in a table too, the same principle can be applied to HTML pages as well: In the same script that generates charts, I can generate a HTML page that includes data and to save it on the web server directory.
But if I would like to do monitoring during the whole year, I have to find a solutions for that. I believe that there are some Perl modules for that.
Other ideas for further processing
Just two days ago, I came onto RRDTool and also, found out about RRD-Simple module. I find the tutorial for RRDTool very good. Of course, all that may be not so simple, especially for me, but I believe that I could cope with it myself.
I see that RRDTool is powerful and maybe it is a good solution for me to easily have graphs for each month or year (I still don't know if it a solution for tables too?). But again, maybe there is a Perl module that allso can help with that?
I don't ask for any code but will be really very thankful for any, whether general or more concrete comment or a suggestion on any part of the project, or for some useful links. Comments on compatibility between elements of the project will be very useful too. Especially because I feel I will not stop here and I already dream about doing some other things, so I will probably try most of your sugestions.